Set virtual waypoint for VTOL_TAKEOFF item

This commit is contained in:
sander
2016-04-02 21:29:27 +01:00
committed by Lorenz Meier
parent 4fc24dce60
commit cbe7bd2198
2 changed files with 15 additions and 6 deletions
+5 -5
View File
@@ -486,7 +486,7 @@ Mission::set_mission_items()
_mission_item.nav_cmd = NAV_CMD_DO_VTOL_TRANSITION; _mission_item.nav_cmd = NAV_CMD_DO_VTOL_TRANSITION;
_mission_item.params[0] = vehicle_status_s::VEHICLE_VTOL_STATE_FW; _mission_item.params[0] = vehicle_status_s::VEHICLE_VTOL_STATE_FW;
_mission_item.yaw = NAN; _mission_item.yaw = _navigator->get_global_position()->yaw;
} else { } else {
new_work_item_type = WORK_ITEM_TYPE_DEFAULT; new_work_item_type = WORK_ITEM_TYPE_DEFAULT;
_mission_item.nav_cmd = NAV_CMD_WAYPOINT; _mission_item.nav_cmd = NAV_CMD_WAYPOINT;
@@ -585,13 +585,13 @@ Mission::set_mission_items()
} else { } else {
/* turn towards next waypoint before MC to FW transition */ /* turn towards next waypoint before MC to FW transition */
if (_mission_item.nav_cmd == NAV_CMD_DO_VTOL_TRANSITION if (_mission_item.nav_cmd == NAV_CMD_DO_VTOL_TRANSITION
&& _work_item_type != WORK_ITEM_TYPE_ALIGN && _work_item_type != WORK_ITEM_TYPE_ALIGN
&& _navigator->get_vstatus()->is_rotary_wing && _navigator->get_vstatus()->is_rotary_wing
&& !_navigator->get_vstatus()->condition_landed && !_navigator->get_vstatus()->condition_landed
&& has_next_position_item) { && has_next_position_item) {
new_work_item_type = WORK_ITEM_TYPE_ALIGN; new_work_item_type = WORK_ITEM_TYPE_ALIGN;
set_align_mission_item(&_mission_item, &mission_item_next_position); set_align_mission_item(&_mission_item, &mission_item_next_position);
} }
@@ -769,7 +769,7 @@ void
Mission::heading_sp_update() Mission::heading_sp_update()
{ {
/* we don't want to be yawing during takeoff, landing or aligning for a transition */ /* we don't want to be yawing during takeoff, landing or aligning for a transition */
if (_mission_item.nav_cmd == NAV_CMD_TAKEOFF if (_mission_item.nav_cmd == NAV_CMD_TAKEOFF
|| _mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF || _mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF
|| _mission_item.nav_cmd == NAV_CMD_DO_VTOL_TRANSITION || _mission_item.nav_cmd == NAV_CMD_DO_VTOL_TRANSITION
|| _mission_item.nav_cmd == NAV_CMD_LAND || _mission_item.nav_cmd == NAV_CMD_LAND
@@ -1159,7 +1159,7 @@ Mission::reset_offboard_mission(struct mission_s &mission)
item.do_jump_current_count = 0; item.do_jump_current_count = 0;
if (dm_write(dm_current, index, DM_PERSIST_POWER_ON_RESET, if (dm_write(dm_current, index, DM_PERSIST_POWER_ON_RESET,
&item, len) != len) { &item, len) != len) {
PX4_WARN("could not save mission item during reset"); PX4_WARN("could not save mission item during reset");
break; break;
} }
+10 -1
View File
@@ -335,10 +335,19 @@ void
MissionBlock::mission_item_to_position_setpoint(const struct mission_item_s *item, struct position_setpoint_s *sp) MissionBlock::mission_item_to_position_setpoint(const struct mission_item_s *item, struct position_setpoint_s *sp)
{ {
/* set the correct setpoint for vtol transition */ /* set the correct setpoint for vtol transition */
if(item->nav_cmd == NAV_CMD_DO_VTOL_TRANSITION) {
if(item->nav_cmd == NAV_CMD_DO_VTOL_TRANSITION && PX4_ISFINITE(item->yaw)) {
sp->type = position_setpoint_s::SETPOINT_TYPE_POSITION; sp->type = position_setpoint_s::SETPOINT_TYPE_POSITION;
waypoint_from_heading_and_distance(_navigator->get_global_position()->lat,
_navigator->get_global_position()->lon,
item->yaw,
1000000.0f,
&sp->lat,
&sp->lon);
sp->alt = _navigator->get_global_position()->alt;
} }
/* don't change the setpoint for non-position items */ /* don't change the setpoint for non-position items */
if (!item_contains_position(item)) { if (!item_contains_position(item)) {
return; return;