use current local position for land and not GPS -> e.g. flow

This commit is contained in:
ChristophTobler
2017-05-03 16:11:05 +02:00
committed by Dennis Mannhart
parent 5bfe6d7fec
commit dce28454c8
2 changed files with 25 additions and 10 deletions
@@ -755,9 +755,9 @@ MulticopterPositionControl::poll_subscriptions()
if (updated) {
orb_copy(ORB_ID(position_setpoint_triplet), _pos_sp_triplet_sub, &_pos_sp_triplet);
//Make sure that the position setpoint is valid
if (!PX4_ISFINITE(_pos_sp_triplet.current.lat) ||
!PX4_ISFINITE(_pos_sp_triplet.current.lon) ||
//set current position setpoint invalid if none of them (lat, lon and alt) is finite
if (!PX4_ISFINITE(_pos_sp_triplet.current.lat) &&
!PX4_ISFINITE(_pos_sp_triplet.current.lon) &&
!PX4_ISFINITE(_pos_sp_triplet.current.alt)) {
_pos_sp_triplet.current.valid = false;
}
@@ -1384,11 +1384,26 @@ void MulticopterPositionControl::control_auto(float dt)
if (_pos_sp_triplet.current.valid) {
/* project setpoint to local frame */
map_projection_project(&_ref_pos,
_pos_sp_triplet.current.lat, _pos_sp_triplet.current.lon,
&_curr_pos_sp.data[0], &_curr_pos_sp.data[1]);
_curr_pos_sp(2) = -(_pos_sp_triplet.current.alt - _ref_alt);
//only project setpoints if they are finite, else use current position
if (PX4_ISFINITE(_pos_sp_triplet.current.lat) &&
PX4_ISFINITE(_pos_sp_triplet.current.lon)) {
/* project setpoint to local frame */
map_projection_project(&_ref_pos,
_pos_sp_triplet.current.lat, _pos_sp_triplet.current.lon,
&_curr_pos_sp.data[0], &_curr_pos_sp.data[1]);
} else {
_curr_pos_sp(0) = _pos(0);
_curr_pos_sp(1) = _pos(1);
}
//only project setpoints if they are finite, else use current position
if (PX4_ISFINITE(_pos_sp_triplet.current.alt)) {
_curr_pos_sp(2) = -(_pos_sp_triplet.current.alt - _ref_alt);
} else {
_curr_pos_sp(2) = _pos(2);
}
if (PX4_ISFINITE(_curr_pos_sp(0)) &&
PX4_ISFINITE(_curr_pos_sp(1)) &&
+2 -2
View File
@@ -699,8 +699,8 @@ MissionBlock::set_land_item(struct mission_item_s *item, bool at_current_locatio
/* use current position */
if (at_current_location) {
item->lat = _navigator->get_global_position()->lat;
item->lon = _navigator->get_global_position()->lon;
item->lat = NAN; //descend at current position
item->lon = NAN; //descend at current position
item->yaw = _navigator->get_local_position()->yaw;
} else {