mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 15:51:36 +08:00
code-style fixes
This commit is contained in:
committed by
Simon Wilks
parent
1b894c3af9
commit
9aca1701f4
@@ -2374,7 +2374,7 @@ private:
|
|||||||
|
|
||||||
/* do not allow top copying this class */
|
/* do not allow top copying this class */
|
||||||
MavlinkStreamVtolState(MavlinkStreamVtolState &);
|
MavlinkStreamVtolState(MavlinkStreamVtolState &);
|
||||||
MavlinkStreamVtolState& operator = (const MavlinkStreamVtolState &);
|
MavlinkStreamVtolState &operator = (const MavlinkStreamVtolState &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit MavlinkStreamVtolState(Mavlink *mavlink) : MavlinkStream(mavlink),
|
explicit MavlinkStreamVtolState(Mavlink *mavlink) : MavlinkStream(mavlink),
|
||||||
@@ -2388,25 +2388,25 @@ protected:
|
|||||||
if (_status_sub->update(&status)) {
|
if (_status_sub->update(&status)) {
|
||||||
mavlink_vtol_state_t msg;
|
mavlink_vtol_state_t msg;
|
||||||
|
|
||||||
if (status.is_vtol)
|
if (status.is_vtol) {
|
||||||
{
|
if (status.is_rotary_wing) {
|
||||||
if (status.is_rotary_wing)
|
|
||||||
{
|
|
||||||
if (status.in_transition_mode) {
|
if (status.in_transition_mode) {
|
||||||
msg.state = MAV_VTOL_STATE_TRANSITION_TO_FW;
|
msg.state = MAV_VTOL_STATE_TRANSITION_TO_FW;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
msg.state = MAV_VTOL_STATE_MC;
|
msg.state = MAV_VTOL_STATE_MC;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
if (status.in_transition_mode) {
|
if (status.in_transition_mode) {
|
||||||
msg.state = MAV_VTOL_STATE_TRANSITION_TO_MC;
|
msg.state = MAV_VTOL_STATE_TRANSITION_TO_MC;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
msg.state = MAV_VTOL_STATE_FW;
|
msg.state = MAV_VTOL_STATE_FW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
msg.state = MAV_VTOL_STATE_UNDEFINED;
|
msg.state = MAV_VTOL_STATE_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,8 @@ VtolAttitudeControl::vehicle_local_pos_poll()
|
|||||||
* Check for command updates.
|
* Check for command updates.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
VtolAttitudeControl::vehicle_cmd_poll() {
|
VtolAttitudeControl::vehicle_cmd_poll()
|
||||||
|
{
|
||||||
bool updated;
|
bool updated;
|
||||||
orb_check(_vehicle_cmd_sub, &updated);
|
orb_check(_vehicle_cmd_sub, &updated);
|
||||||
|
|
||||||
@@ -332,7 +333,8 @@ VtolAttitudeControl::vehicle_cmd_poll() {
|
|||||||
* Check received command
|
* Check received command
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
VtolAttitudeControl::handle_command() {
|
VtolAttitudeControl::handle_command()
|
||||||
|
{
|
||||||
// update transition command if necessary
|
// update transition command if necessary
|
||||||
if (_vehicle_cmd.command == vehicle_command_s::VEHICLE_CMD_DO_VTOL_TRANSITION) {
|
if (_vehicle_cmd.command == vehicle_command_s::VEHICLE_CMD_DO_VTOL_TRANSITION) {
|
||||||
_transition_command = int(_vehicle_cmd.param1 + 0.5f);
|
_transition_command = int(_vehicle_cmd.param1 + 0.5f);
|
||||||
@@ -347,10 +349,12 @@ bool
|
|||||||
VtolAttitudeControl::is_fixed_wing_requested()
|
VtolAttitudeControl::is_fixed_wing_requested()
|
||||||
{
|
{
|
||||||
bool to_fw = _manual_control_sp.aux1 > 0.0f;
|
bool to_fw = _manual_control_sp.aux1 > 0.0f;
|
||||||
if (_v_control_mode.flag_control_offboard_enabled) {
|
|
||||||
to_fw = _transition_command == vehicle_status_s::VEHICLE_VTOL_STATE_FW;
|
if (_v_control_mode.flag_control_offboard_enabled) {
|
||||||
}
|
to_fw = _transition_command == vehicle_status_s::VEHICLE_VTOL_STATE_FW;
|
||||||
return to_fw;
|
}
|
||||||
|
|
||||||
|
return to_fw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -531,12 +535,11 @@ void VtolAttitudeControl::task_main()
|
|||||||
_vtol_type->update_vtol_state();
|
_vtol_type->update_vtol_state();
|
||||||
|
|
||||||
// reset transition command if not in offboard control
|
// reset transition command if not in offboard control
|
||||||
if (!_v_control_mode.flag_control_offboard_enabled)
|
if (!_v_control_mode.flag_control_offboard_enabled) {
|
||||||
{
|
|
||||||
if (_vtol_type->get_mode() == ROTARY_WING) {
|
if (_vtol_type->get_mode() == ROTARY_WING) {
|
||||||
_transition_command = vehicle_status_s::VEHICLE_VTOL_STATE_MC;
|
_transition_command = vehicle_status_s::VEHICLE_VTOL_STATE_MC;
|
||||||
}
|
|
||||||
else if (_vtol_type->get_mode() == FIXED_WING) {
|
} else if (_vtol_type->get_mode() == FIXED_WING) {
|
||||||
_transition_command = vehicle_status_s::VEHICLE_VTOL_STATE_FW;
|
_transition_command = vehicle_status_s::VEHICLE_VTOL_STATE_FW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,6 +558,7 @@ void VtolAttitudeControl::task_main()
|
|||||||
|
|
||||||
fill_mc_att_rates_sp();
|
fill_mc_att_rates_sp();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (_vtol_type->get_mode() == FIXED_WING) {
|
} else if (_vtol_type->get_mode() == FIXED_WING) {
|
||||||
// vehicle is in fw mode
|
// vehicle is in fw mode
|
||||||
_vtol_vehicle_status.vtol_in_rw_mode = false;
|
_vtol_vehicle_status.vtol_in_rw_mode = false;
|
||||||
@@ -569,11 +573,13 @@ void VtolAttitudeControl::task_main()
|
|||||||
|
|
||||||
fill_fw_att_rates_sp();
|
fill_fw_att_rates_sp();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (_vtol_type->get_mode() == TRANSITION) {
|
} else if (_vtol_type->get_mode() == TRANSITION) {
|
||||||
// vehicle is doing a transition
|
// vehicle is doing a transition
|
||||||
_vtol_vehicle_status.vtol_in_trans_mode = true;
|
_vtol_vehicle_status.vtol_in_trans_mode = true;
|
||||||
|
|
||||||
bool got_new_data = false;
|
bool got_new_data = false;
|
||||||
|
|
||||||
if (fds[0].revents & POLLIN) {
|
if (fds[0].revents & POLLIN) {
|
||||||
orb_copy(ORB_ID(actuator_controls_virtual_mc), _actuator_inputs_mc, &_actuators_mc_in);
|
orb_copy(ORB_ID(actuator_controls_virtual_mc), _actuator_inputs_mc, &_actuators_mc_in);
|
||||||
got_new_data = true;
|
got_new_data = true;
|
||||||
@@ -598,29 +604,30 @@ void VtolAttitudeControl::task_main()
|
|||||||
_vtol_type->fill_actuator_outputs();
|
_vtol_type->fill_actuator_outputs();
|
||||||
|
|
||||||
/* Only publish if the proper mode(s) are enabled */
|
/* Only publish if the proper mode(s) are enabled */
|
||||||
if(_v_control_mode.flag_control_attitude_enabled ||
|
if (_v_control_mode.flag_control_attitude_enabled ||
|
||||||
_v_control_mode.flag_control_rates_enabled ||
|
_v_control_mode.flag_control_rates_enabled ||
|
||||||
_v_control_mode.flag_control_manual_enabled)
|
_v_control_mode.flag_control_manual_enabled) {
|
||||||
{
|
|
||||||
if (_actuators_0_pub != nullptr) {
|
if (_actuators_0_pub != nullptr) {
|
||||||
orb_publish(ORB_ID(actuator_controls_0), _actuators_0_pub, &_actuators_out_0);
|
orb_publish(ORB_ID(actuator_controls_0), _actuators_0_pub, &_actuators_out_0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_actuators_0_pub = orb_advertise(ORB_ID(actuator_controls_0), &_actuators_out_0);
|
_actuators_0_pub = orb_advertise(ORB_ID(actuator_controls_0), &_actuators_out_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_actuators_1_pub != nullptr) {
|
if (_actuators_1_pub != nullptr) {
|
||||||
orb_publish(ORB_ID(actuator_controls_1), _actuators_1_pub, &_actuators_out_1);
|
orb_publish(ORB_ID(actuator_controls_1), _actuators_1_pub, &_actuators_out_1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_actuators_1_pub = orb_advertise(ORB_ID(actuator_controls_1), &_actuators_out_1);
|
_actuators_1_pub = orb_advertise(ORB_ID(actuator_controls_1), &_actuators_out_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish the attitude rates setpoint
|
// publish the attitude rates setpoint
|
||||||
if(_v_rates_sp_pub != nullptr) {
|
if (_v_rates_sp_pub != nullptr) {
|
||||||
orb_publish(ORB_ID(vehicle_rates_setpoint),_v_rates_sp_pub,&_v_rates_sp);
|
orb_publish(ORB_ID(vehicle_rates_setpoint), _v_rates_sp_pub, &_v_rates_sp);
|
||||||
}
|
|
||||||
else {
|
} else {
|
||||||
_v_rates_sp_pub = orb_advertise(ORB_ID(vehicle_rates_setpoint),&_v_rates_sp);
|
_v_rates_sp_pub = orb_advertise(ORB_ID(vehicle_rates_setpoint), &_v_rates_sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user