mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 03:43:35 +08:00
Changed to publishing armed state in commander
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
#include <uORB/uORB.h>
|
#include <uORB/uORB.h>
|
||||||
#include <uORB/topics/vehicle_status.h>
|
#include <uORB/topics/vehicle_status.h>
|
||||||
|
#include <uORB/topics/actuator_controls.h>
|
||||||
#include <systemlib/systemlib.h>
|
#include <systemlib/systemlib.h>
|
||||||
#include <arch/board/up_hrt.h>
|
#include <arch/board/up_hrt.h>
|
||||||
#include <mavlink/mavlink_log.h>
|
#include <mavlink/mavlink_log.h>
|
||||||
@@ -198,6 +199,10 @@ int do_state_update(int status_pub, struct vehicle_status_s *current_status, con
|
|||||||
if (invalid_state == false || old_state != new_state) {
|
if (invalid_state == false || old_state != new_state) {
|
||||||
current_status->state_machine = new_state;
|
current_status->state_machine = new_state;
|
||||||
state_machine_publish(status_pub, current_status, mavlink_fd);
|
state_machine_publish(status_pub, current_status, mavlink_fd);
|
||||||
|
struct actuator_armed_s armed;
|
||||||
|
armed.armed = current_status->flag_system_armed;
|
||||||
|
orb_advert_t armed_pub = orb_advertise(ORB_ID(actuator_armed), &armed);
|
||||||
|
orb_publish(ORB_ID(actuator_armed), armed_pub, &armed);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
if (invalid_state) {
|
if (invalid_state) {
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ mc_thread_main(int argc, char *argv[])
|
|||||||
actuators.control[i] = 0.0f;
|
actuators.control[i] = 0.0f;
|
||||||
orb_advert_t actuator_pub = orb_advertise(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, &actuators);
|
orb_advert_t actuator_pub = orb_advertise(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, &actuators);
|
||||||
armed.armed = false;
|
armed.armed = false;
|
||||||
orb_advert_t armed_pub = orb_advertise(ORB_ID(actuator_armed), &armed);
|
|
||||||
orb_advert_t att_sp_pub = orb_advertise(ORB_ID(vehicle_attitude_setpoint), &att_sp);
|
orb_advert_t att_sp_pub = orb_advertise(ORB_ID(vehicle_attitude_setpoint), &att_sp);
|
||||||
|
|
||||||
/* register the perf counter */
|
/* register the perf counter */
|
||||||
@@ -151,25 +150,13 @@ mc_thread_main(int argc, char *argv[])
|
|||||||
att_sp.yaw_body = 0.0f;
|
att_sp.yaw_body = 0.0f;
|
||||||
att_sp.thrust = 0.1f;
|
att_sp.thrust = 0.1f;
|
||||||
} else {
|
} else {
|
||||||
if (state.flag_system_armed) {
|
att_sp.thrust = manual.throttle;
|
||||||
att_sp.thrust = manual.throttle;
|
|
||||||
armed.armed = true;
|
|
||||||
|
|
||||||
} else if (state.state_machine == SYSTEM_STATE_EMCY_CUTOFF) {
|
|
||||||
/* immediately cut off motors */
|
|
||||||
armed.armed = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* limit motor throttle to zero for an unknown mode */
|
|
||||||
armed.armed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
multirotor_control_attitude(&att_sp, &att, &state, &actuators, motor_test_mode);
|
multirotor_control_attitude(&att_sp, &att, &actuators);
|
||||||
|
|
||||||
/* publish the result */
|
/* publish the result */
|
||||||
orb_publish(ORB_ID(actuator_armed), armed_pub, &armed);
|
|
||||||
orb_publish(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, actuator_pub, &actuators);
|
orb_publish(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, actuator_pub, &actuators);
|
||||||
orb_publish(ORB_ID(vehicle_attitude_setpoint), att_sp_pub, &att_sp);
|
orb_publish(ORB_ID(vehicle_attitude_setpoint), att_sp_pub, &att_sp);
|
||||||
|
|
||||||
@@ -179,8 +166,6 @@ mc_thread_main(int argc, char *argv[])
|
|||||||
printf("[multirotor att control] stopping, disarming motors.\n");
|
printf("[multirotor att control] stopping, disarming motors.\n");
|
||||||
|
|
||||||
/* kill all outputs */
|
/* kill all outputs */
|
||||||
armed.armed = false;
|
|
||||||
orb_publish(ORB_ID(actuator_armed), armed_pub, &armed);
|
|
||||||
for (unsigned i = 0; i < NUM_ACTUATOR_CONTROLS; i++)
|
for (unsigned i = 0; i < NUM_ACTUATOR_CONTROLS; i++)
|
||||||
actuators.control[i] = 0.0f;
|
actuators.control[i] = 0.0f;
|
||||||
orb_publish(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, actuator_pub, &actuators);
|
orb_publish(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, actuator_pub, &actuators);
|
||||||
@@ -190,7 +175,6 @@ mc_thread_main(int argc, char *argv[])
|
|||||||
close(state_sub);
|
close(state_sub);
|
||||||
close(manual_sub);
|
close(manual_sub);
|
||||||
close(actuator_pub);
|
close(actuator_pub);
|
||||||
close(armed_pub);
|
|
||||||
close(att_sp_pub);
|
close(att_sp_pub);
|
||||||
|
|
||||||
perf_print_counter(mc_loop_perf);
|
perf_print_counter(mc_loop_perf);
|
||||||
|
|||||||
@@ -188,8 +188,7 @@ static int parameters_update(const struct mc_att_control_param_handles *h, struc
|
|||||||
}
|
}
|
||||||
|
|
||||||
void multirotor_control_attitude(const struct vehicle_attitude_setpoint_s *att_sp,
|
void multirotor_control_attitude(const struct vehicle_attitude_setpoint_s *att_sp,
|
||||||
const struct vehicle_attitude_s *att, const struct vehicle_status_s *status,
|
const struct vehicle_attitude_s *att, struct actuator_controls_s *actuators)
|
||||||
struct actuator_controls_s *actuators, bool verbose)
|
|
||||||
{
|
{
|
||||||
static uint64_t last_run = 0;
|
static uint64_t last_run = 0;
|
||||||
const float deltaT = (hrt_absolute_time() - last_run) / 1000000.0f;
|
const float deltaT = (hrt_absolute_time() - last_run) / 1000000.0f;
|
||||||
|
|||||||
@@ -54,8 +54,6 @@
|
|||||||
#include <uORB/topics/actuator_controls.h>
|
#include <uORB/topics/actuator_controls.h>
|
||||||
|
|
||||||
void multirotor_control_attitude(const struct vehicle_attitude_setpoint_s *att_sp, const struct vehicle_attitude_s *att,
|
void multirotor_control_attitude(const struct vehicle_attitude_setpoint_s *att_sp, const struct vehicle_attitude_s *att,
|
||||||
const struct vehicle_status_s *status, struct actuator_controls_s *actuators, bool verbose);
|
struct actuator_controls_s *actuators);
|
||||||
|
|
||||||
void ardrone_mixing_and_output(int ardrone_write, const struct actuator_controls_s *actuators, bool verbose);
|
|
||||||
|
|
||||||
#endif /* MULTIROTOR_ATTITUDE_CONTROL_H_ */
|
#endif /* MULTIROTOR_ATTITUDE_CONTROL_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user