mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 05:33:33 +08:00
drivers/modules: changes after mavlink_log change
The mavlink_log API changes lead to changes in all drivers/modules using it.
This commit is contained in:
@@ -67,10 +67,10 @@
|
||||
#include <systemlib/systemlib.h>
|
||||
#include <systemlib/param/param.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <geo/geo.h>
|
||||
#include <dataman/dataman.h>
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <mavlink/mavlink_log.h>
|
||||
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
private:
|
||||
bool _task_should_exit; /**< if true, task should exit */
|
||||
int _main_task; /**< handle for task */
|
||||
int _mavlink_fd;
|
||||
orb_advert_t _mavlink_log_pub;
|
||||
|
||||
int _command_sub;
|
||||
int _wind_estimate_sub;
|
||||
@@ -174,7 +174,6 @@ BottleDrop::BottleDrop() :
|
||||
|
||||
_task_should_exit(false),
|
||||
_main_task(-1),
|
||||
_mavlink_fd(-1),
|
||||
_command_sub(-1),
|
||||
_wind_estimate_sub(-1),
|
||||
_command {},
|
||||
@@ -341,8 +340,7 @@ void
|
||||
BottleDrop::task_main()
|
||||
{
|
||||
|
||||
_mavlink_fd = px4_open(MAVLINK_LOG_DEVICE, 0);
|
||||
mavlink_log_info(_mavlink_fd, "[bottle_drop] started");
|
||||
mavlink_log_info(&_mavlink_log_pub, "[bottle_drop] started");
|
||||
|
||||
_command_sub = orb_subscribe(ORB_ID(vehicle_command));
|
||||
_wind_estimate_sub = orb_subscribe(ORB_ID(wind_estimate));
|
||||
@@ -533,7 +531,7 @@ BottleDrop::task_main()
|
||||
approach_error = _wrap_pi(ground_direction - approach_direction);
|
||||
|
||||
if (counter % 90 == 0) {
|
||||
mavlink_log_info(_mavlink_fd, "drop distance %u, heading error %u", (unsigned)distance_real,
|
||||
mavlink_log_info(&_mavlink_log_pub, "drop distance %u, heading error %u", (unsigned)distance_real,
|
||||
(unsigned)math::degrees(approach_error));
|
||||
}
|
||||
}
|
||||
@@ -638,7 +636,7 @@ BottleDrop::task_main()
|
||||
|
||||
float approach_direction = get_bearing_to_next_waypoint(flight_vector_s.lat, flight_vector_s.lon, flight_vector_e.lat,
|
||||
flight_vector_e.lon);
|
||||
mavlink_log_critical(_mavlink_fd, "position set, approach heading: %u", (unsigned)distance_real,
|
||||
mavlink_log_critical(&_mavlink_log_pub, "position set, approach heading: %u", (unsigned)distance_real,
|
||||
(unsigned)math::degrees(approach_direction + M_PI_F));
|
||||
|
||||
_drop_state = DROP_STATE_TARGET_SET;
|
||||
@@ -662,7 +660,7 @@ BottleDrop::task_main()
|
||||
fabsf(approach_error) < math::radians(20.0f)) {
|
||||
open_bay();
|
||||
_drop_state = DROP_STATE_BAY_OPEN;
|
||||
mavlink_log_info(_mavlink_fd, "#audio: opening bay");
|
||||
mavlink_log_info(&_mavlink_log_pub, "#audio: opening bay");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -680,7 +678,7 @@ BottleDrop::task_main()
|
||||
(distance_real < precision) && ((distance_real < future_distance))) {
|
||||
drop();
|
||||
_drop_state = DROP_STATE_DROPPED;
|
||||
mavlink_log_info(_mavlink_fd, "#audio: payload dropped");
|
||||
mavlink_log_info(&_mavlink_log_pub, "#audio: payload dropped");
|
||||
|
||||
} else {
|
||||
|
||||
@@ -704,7 +702,7 @@ BottleDrop::task_main()
|
||||
_drop_approval = false;
|
||||
lock_release();
|
||||
close_bay();
|
||||
mavlink_log_info(_mavlink_fd, "#audio: closing bay");
|
||||
mavlink_log_info(&_mavlink_log_pub, "#audio: closing bay");
|
||||
|
||||
// remove onboard mission
|
||||
_onboard_mission.current_seq = -1;
|
||||
@@ -751,16 +749,16 @@ BottleDrop::handle_command(struct vehicle_command_s *cmd)
|
||||
if (cmd->param1 > 0.5f && cmd->param2 > 0.5f) {
|
||||
open_bay();
|
||||
drop();
|
||||
mavlink_log_critical(_mavlink_fd, "drop bottle");
|
||||
mavlink_log_critical(&_mavlink_log_pub, "drop bottle");
|
||||
|
||||
} else if (cmd->param1 > 0.5f) {
|
||||
open_bay();
|
||||
mavlink_log_critical(_mavlink_fd, "opening bay");
|
||||
mavlink_log_critical(&_mavlink_log_pub, "opening bay");
|
||||
|
||||
} else {
|
||||
lock_release();
|
||||
close_bay();
|
||||
mavlink_log_critical(_mavlink_fd, "closing bay");
|
||||
mavlink_log_critical(&_mavlink_log_pub, "closing bay");
|
||||
}
|
||||
|
||||
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
@@ -771,12 +769,12 @@ BottleDrop::handle_command(struct vehicle_command_s *cmd)
|
||||
switch ((int)(cmd->param1 + 0.5f)) {
|
||||
case 0:
|
||||
_drop_approval = false;
|
||||
mavlink_log_critical(_mavlink_fd, "got drop position, no approval");
|
||||
mavlink_log_critical(&_mavlink_log_pub, "got drop position, no approval");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
_drop_approval = true;
|
||||
mavlink_log_critical(_mavlink_fd, "got drop position and approval");
|
||||
mavlink_log_critical(&_mavlink_log_pub, "got drop position and approval");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -791,7 +789,7 @@ BottleDrop::handle_command(struct vehicle_command_s *cmd)
|
||||
_target_position.lon = cmd->param6;
|
||||
_target_position.alt = cmd->param7;
|
||||
_drop_state = DROP_STATE_TARGET_VALID;
|
||||
mavlink_log_info(_mavlink_fd, "got target: %8.4f, %8.4f, %8.4f", (double)_target_position.lat,
|
||||
mavlink_log_info(&_mavlink_log_pub, "got target: %8.4f, %8.4f, %8.4f", (double)_target_position.lat,
|
||||
(double)_target_position.lon, (double)_target_position.alt);
|
||||
map_projection_init(&ref, _target_position.lat, _target_position.lon);
|
||||
answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
@@ -820,7 +818,7 @@ BottleDrop::handle_command(struct vehicle_command_s *cmd)
|
||||
|
||||
case 1:
|
||||
_drop_approval = true;
|
||||
mavlink_log_info(_mavlink_fd, "#audio: got drop approval");
|
||||
mavlink_log_info(&_mavlink_log_pub, "#audio: got drop approval");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -846,19 +844,19 @@ BottleDrop::answer_command(struct vehicle_command_s *cmd, unsigned result)
|
||||
break;
|
||||
|
||||
case vehicle_command_s::VEHICLE_CMD_RESULT_DENIED:
|
||||
mavlink_log_critical(_mavlink_fd, "command denied: %u", cmd->command);
|
||||
mavlink_log_critical(&_mavlink_log_pub, "command denied: %u", cmd->command);
|
||||
break;
|
||||
|
||||
case vehicle_command_s::VEHICLE_CMD_RESULT_FAILED:
|
||||
mavlink_log_critical(_mavlink_fd, "command failed: %u", cmd->command);
|
||||
mavlink_log_critical(&_mavlink_log_pub, "command failed: %u", cmd->command);
|
||||
break;
|
||||
|
||||
case vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED:
|
||||
mavlink_log_critical(_mavlink_fd, "command temporarily rejected: %u", cmd->command);
|
||||
mavlink_log_critical(&_mavlink_log_pub, "command temporarily rejected: %u", cmd->command);
|
||||
break;
|
||||
|
||||
case vehicle_command_s::VEHICLE_CMD_RESULT_UNSUPPORTED:
|
||||
mavlink_log_critical(_mavlink_fd, "command unsupported: %u", cmd->command);
|
||||
mavlink_log_critical(&_mavlink_log_pub, "command unsupported: %u", cmd->command);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user