|
|
@ -140,36 +140,6 @@ VtolAttitudeControl::~VtolAttitudeControl() |
|
|
|
VTOL_att_control::g_control = nullptr; |
|
|
|
VTOL_att_control::g_control = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for changes in vehicle control mode. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void VtolAttitudeControl::vehicle_control_mode_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Check if vehicle control mode has changed */ |
|
|
|
|
|
|
|
orb_check(_v_control_mode_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(vehicle_control_mode), _v_control_mode_sub, &_v_control_mode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for changes in manual inputs. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void VtolAttitudeControl::vehicle_manual_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* get pilots inputs */ |
|
|
|
|
|
|
|
orb_check(_manual_control_sp_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(manual_control_setpoint), _manual_control_sp_sub, &_manual_control_sp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Check for inputs from mc attitude controller. |
|
|
|
* Check for inputs from mc attitude controller. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -196,158 +166,18 @@ void VtolAttitudeControl::actuator_controls_fw_poll() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for airspeed updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::vehicle_airspeed_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
orb_check(_airspeed_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(airspeed), _airspeed_sub, &_airspeed); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for attitude update. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::vehicle_attitude_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* check if there is a new setpoint */ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
orb_check(_v_att_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(vehicle_attitude), _v_att_sub, &_v_att); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for sensor updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::vehicle_local_pos_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
/* Check if parameters have changed */ |
|
|
|
|
|
|
|
orb_check(_local_pos_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(vehicle_local_position), _local_pos_sub, &_local_pos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for setpoint updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::vehicle_local_pos_sp_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
/* Check if parameters have changed */ |
|
|
|
|
|
|
|
orb_check(_local_pos_sp_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(vehicle_local_position_setpoint), _local_pos_sp_sub, &_local_pos_sp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for position setpoint updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::pos_sp_triplet_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
/* Check if parameters have changed */ |
|
|
|
|
|
|
|
orb_check(_pos_sp_triplet_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(position_setpoint_triplet), _pos_sp_triplet_sub, &_pos_sp_triplet); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for mc virtual attitude setpoint updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::mc_virtual_att_sp_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orb_check(_mc_virtual_att_sp_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(mc_virtual_attitude_setpoint), _mc_virtual_att_sp_sub, &_mc_virtual_att_sp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for fw virtual attitude setpoint updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::fw_virtual_att_sp_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orb_check(_fw_virtual_att_sp_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(fw_virtual_attitude_setpoint), _fw_virtual_att_sp_sub, &_fw_virtual_att_sp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Check for command updates. |
|
|
|
* Check for command updates. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void |
|
|
|
void |
|
|
|
VtolAttitudeControl::vehicle_cmd_poll() |
|
|
|
VtolAttitudeControl::vehicle_cmd_poll() |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool updated; |
|
|
|
if (_vehicle_cmd_sub.updated()) { |
|
|
|
orb_check(_vehicle_cmd_sub, &updated); |
|
|
|
_vehicle_cmd_sub.copy(&_vehicle_cmd); |
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(vehicle_command), _vehicle_cmd_sub, &_vehicle_cmd); |
|
|
|
|
|
|
|
handle_command(); |
|
|
|
handle_command(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for TECS status updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::tecs_status_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orb_check(_tecs_status_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(tecs_status), _tecs_status_sub, &_tecs_status); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check for land detector updates. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
VtolAttitudeControl::land_detected_poll() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
bool updated; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orb_check(_land_detected_sub, &updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updated) { |
|
|
|
|
|
|
|
orb_copy(ORB_ID(vehicle_land_detected), _land_detected_sub, &_land_detected); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Check received command |
|
|
|
* Check received command |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -526,23 +356,7 @@ VtolAttitudeControl::task_main_trampoline(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
|
|
|
void VtolAttitudeControl::task_main() |
|
|
|
void VtolAttitudeControl::task_main() |
|
|
|
{ |
|
|
|
{ |
|
|
|
fflush(stdout); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* do subscriptions */ |
|
|
|
/* do subscriptions */ |
|
|
|
_mc_virtual_att_sp_sub = orb_subscribe(ORB_ID(mc_virtual_attitude_setpoint)); |
|
|
|
|
|
|
|
_fw_virtual_att_sp_sub = orb_subscribe(ORB_ID(fw_virtual_attitude_setpoint)); |
|
|
|
|
|
|
|
_v_att_sub = orb_subscribe(ORB_ID(vehicle_attitude)); |
|
|
|
|
|
|
|
_v_control_mode_sub = orb_subscribe(ORB_ID(vehicle_control_mode)); |
|
|
|
|
|
|
|
_params_sub = orb_subscribe(ORB_ID(parameter_update)); |
|
|
|
|
|
|
|
_manual_control_sp_sub = orb_subscribe(ORB_ID(manual_control_setpoint)); |
|
|
|
|
|
|
|
_local_pos_sub = orb_subscribe(ORB_ID(vehicle_local_position)); |
|
|
|
|
|
|
|
_local_pos_sp_sub = orb_subscribe(ORB_ID(vehicle_local_position_setpoint)); |
|
|
|
|
|
|
|
_pos_sp_triplet_sub = orb_subscribe(ORB_ID(position_setpoint_triplet)); |
|
|
|
|
|
|
|
_airspeed_sub = orb_subscribe(ORB_ID(airspeed)); |
|
|
|
|
|
|
|
_vehicle_cmd_sub = orb_subscribe(ORB_ID(vehicle_command)); |
|
|
|
|
|
|
|
_tecs_status_sub = orb_subscribe(ORB_ID(tecs_status)); |
|
|
|
|
|
|
|
_land_detected_sub = orb_subscribe(ORB_ID(vehicle_land_detected)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_actuator_inputs_mc = orb_subscribe(ORB_ID(actuator_controls_virtual_mc)); |
|
|
|
_actuator_inputs_mc = orb_subscribe(ORB_ID(actuator_controls_virtual_mc)); |
|
|
|
_actuator_inputs_fw = orb_subscribe(ORB_ID(actuator_controls_virtual_fw)); |
|
|
|
_actuator_inputs_fw = orb_subscribe(ORB_ID(actuator_controls_virtual_fw)); |
|
|
|
|
|
|
|
|
|
|
@ -557,13 +371,10 @@ void VtolAttitudeControl::task_main() |
|
|
|
|
|
|
|
|
|
|
|
while (!_task_should_exit) { |
|
|
|
while (!_task_should_exit) { |
|
|
|
/* only update parameters if they changed */ |
|
|
|
/* only update parameters if they changed */ |
|
|
|
bool params_updated = false; |
|
|
|
if (_params_sub.updated()) { |
|
|
|
orb_check(_params_sub, ¶ms_updated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (params_updated) { |
|
|
|
|
|
|
|
/* read from param to clear updated flag */ |
|
|
|
/* read from param to clear updated flag */ |
|
|
|
parameter_update_s update; |
|
|
|
parameter_update_s update; |
|
|
|
orb_copy(ORB_ID(parameter_update), _params_sub, &update); |
|
|
|
_params_sub.copy(&update); |
|
|
|
|
|
|
|
|
|
|
|
/* update parameters from storage */ |
|
|
|
/* update parameters from storage */ |
|
|
|
parameters_update(); |
|
|
|
parameters_update(); |
|
|
@ -598,16 +409,16 @@ void VtolAttitudeControl::task_main() |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vehicle_control_mode_poll(); |
|
|
|
_v_control_mode_sub.update(&_v_control_mode); |
|
|
|
vehicle_manual_poll(); |
|
|
|
_manual_control_sp_sub.update(&_manual_control_sp); |
|
|
|
vehicle_attitude_poll(); |
|
|
|
_v_att_sub.update(&_v_att); |
|
|
|
vehicle_local_pos_poll(); |
|
|
|
_local_pos_sub.update(&_local_pos); |
|
|
|
vehicle_local_pos_sp_poll(); |
|
|
|
_local_pos_sp_sub.update(&_local_pos_sp); |
|
|
|
pos_sp_triplet_poll(); |
|
|
|
_pos_sp_triplet_sub.update(&_pos_sp_triplet); |
|
|
|
vehicle_airspeed_poll(); |
|
|
|
_airspeed_sub.update(&_airspeed); |
|
|
|
|
|
|
|
_tecs_status_sub.update(&_tecs_status); |
|
|
|
|
|
|
|
_land_detected_sub.update(&_land_detected); |
|
|
|
vehicle_cmd_poll(); |
|
|
|
vehicle_cmd_poll(); |
|
|
|
tecs_status_poll(); |
|
|
|
|
|
|
|
land_detected_poll(); |
|
|
|
|
|
|
|
actuator_controls_fw_poll(); |
|
|
|
actuator_controls_fw_poll(); |
|
|
|
actuator_controls_mc_poll(); |
|
|
|
actuator_controls_mc_poll(); |
|
|
|
|
|
|
|
|
|
|
@ -633,7 +444,7 @@ void VtolAttitudeControl::task_main() |
|
|
|
// check in which mode we are in and call mode specific functions
|
|
|
|
// check in which mode we are in and call mode specific functions
|
|
|
|
if (_vtol_type->get_mode() == mode::ROTARY_WING) { |
|
|
|
if (_vtol_type->get_mode() == mode::ROTARY_WING) { |
|
|
|
|
|
|
|
|
|
|
|
mc_virtual_att_sp_poll(); |
|
|
|
_mc_virtual_att_sp_sub.update(&_mc_virtual_att_sp); |
|
|
|
|
|
|
|
|
|
|
|
// vehicle is in rotary wing mode
|
|
|
|
// vehicle is in rotary wing mode
|
|
|
|
_vtol_vehicle_status.vtol_in_rw_mode = true; |
|
|
|
_vtol_vehicle_status.vtol_in_rw_mode = true; |
|
|
@ -645,7 +456,7 @@ void VtolAttitudeControl::task_main() |
|
|
|
|
|
|
|
|
|
|
|
} else if (_vtol_type->get_mode() == mode::FIXED_WING) { |
|
|
|
} else if (_vtol_type->get_mode() == mode::FIXED_WING) { |
|
|
|
|
|
|
|
|
|
|
|
fw_virtual_att_sp_poll(); |
|
|
|
_fw_virtual_att_sp_sub.update(&_fw_virtual_att_sp); |
|
|
|
|
|
|
|
|
|
|
|
// 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; |
|
|
@ -656,8 +467,8 @@ void VtolAttitudeControl::task_main() |
|
|
|
|
|
|
|
|
|
|
|
} else if (_vtol_type->get_mode() == mode::TRANSITION_TO_MC || _vtol_type->get_mode() == mode::TRANSITION_TO_FW) { |
|
|
|
} else if (_vtol_type->get_mode() == mode::TRANSITION_TO_MC || _vtol_type->get_mode() == mode::TRANSITION_TO_FW) { |
|
|
|
|
|
|
|
|
|
|
|
mc_virtual_att_sp_poll(); |
|
|
|
_mc_virtual_att_sp_sub.update(&_mc_virtual_att_sp); |
|
|
|
fw_virtual_att_sp_poll(); |
|
|
|
_fw_virtual_att_sp_sub.update(&_fw_virtual_att_sp); |
|
|
|
|
|
|
|
|
|
|
|
// 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; |
|
|
|