-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] FW navigation first order hold move to position controller #8883
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2b6ab93
FW navigation first order hold move to position controller
dagar acf5457
navigator move get_absolute_altitude_for_item to MissionBlock
dagar a74bba6
FW move climb via loiter to position controller
dagar 6e6f478
Navigator MissionBlock split is_mission_item_reached()
dagar d0bf212
Navigator MissionBlock refactor
dagar 4bd174f
FW handle TAKEOFF like a regular POSITION setpoint if already flying
dagar 4ded523
Navigator MissionBlock cast double conversion
dagar 885ee4f
fw_pos_control_l1 cast double conversion
dagar 54ad73d
FW restore FOH min distance latch and cleanup
dagar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
#include <systemlib/mavlink_log.h> | ||
#include <systemlib/err.h> | ||
#include <lib/ecl/geo/geo.h> | ||
#include <lib/mathlib/mathlib.h> | ||
#include <navigator/navigation.h> | ||
#include <uORB/uORB.h> | ||
#include <uORB/topics/mission.h> | ||
|
@@ -228,10 +229,6 @@ Mission::on_active() | |
set_mission_items(); | ||
} | ||
|
||
} else if (_mission_type != MISSION_TYPE_NONE && _param_altmode.get() == MISSION_ALTMODE_FOH) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Param no longer exists |
||
|
||
altitude_sp_foh_update(); | ||
|
||
} else { | ||
/* if waypoint position reached allow loiter on the setpoint */ | ||
if (_waypoint_position_reached && _mission_item.nav_cmd != NAV_CMD_IDLE) { | ||
|
@@ -444,13 +441,12 @@ Mission::landing() | |
void | ||
Mission::update_offboard_mission() | ||
{ | ||
|
||
bool failed = true; | ||
|
||
/* reset triplets */ | ||
_navigator->reset_triplets(); | ||
|
||
struct mission_s old_offboard_mission = _offboard_mission; | ||
mission_s old_offboard_mission = _offboard_mission; | ||
|
||
if (orb_copy(ORB_ID(mission), _navigator->get_offboard_mission_sub(), &_offboard_mission) == OK) { | ||
/* determine current index */ | ||
|
@@ -571,9 +567,6 @@ Mission::advance_mission() | |
void | ||
Mission::set_mission_items() | ||
{ | ||
/* reset the altitude foh (first order hold) logic, if altitude foh is enabled (param) a new foh element starts now */ | ||
_min_current_sp_distance_xy = FLT_MAX; | ||
|
||
/* the home dist check provides user feedback, so we initialize it to this */ | ||
bool user_feedback_done = false; | ||
|
||
|
@@ -1048,14 +1041,6 @@ Mission::set_mission_items() | |
pos_sp_triplet->next.valid = false; | ||
} | ||
|
||
/* Save the distance between the current sp and the previous one */ | ||
if (pos_sp_triplet->current.valid && pos_sp_triplet->previous.valid) { | ||
|
||
_distance_current_previous = get_distance_to_next_waypoint( | ||
pos_sp_triplet->current.lat, pos_sp_triplet->current.lon, | ||
pos_sp_triplet->previous.lat, pos_sp_triplet->previous.lon); | ||
} | ||
|
||
_navigator->set_position_setpoint_triplet_updated(); | ||
} | ||
|
||
|
@@ -1240,81 +1225,6 @@ Mission::heading_sp_update() | |
} | ||
} | ||
|
||
void | ||
Mission::altitude_sp_foh_update() | ||
{ | ||
struct position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet(); | ||
|
||
/* Don't change setpoint if last and current waypoint are not valid | ||
* or if the previous altitude isn't from a position or loiter setpoint or | ||
* if rotary wing since that is handled in the mc_pos_control | ||
*/ | ||
|
||
|
||
if (!pos_sp_triplet->previous.valid || !pos_sp_triplet->current.valid || !PX4_ISFINITE(pos_sp_triplet->previous.alt) | ||
|| !(pos_sp_triplet->previous.type == position_setpoint_s::SETPOINT_TYPE_POSITION || | ||
pos_sp_triplet->previous.type == position_setpoint_s::SETPOINT_TYPE_LOITER) || | ||
_navigator->get_vstatus()->is_rotary_wing) { | ||
|
||
return; | ||
} | ||
|
||
// Calculate acceptance radius, i.e. the radius within which we do not perform a first order hold anymore | ||
float acc_rad = _navigator->get_acceptance_radius(_mission_item.acceptance_radius); | ||
|
||
if (pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_LOITER) { | ||
acc_rad = _navigator->get_acceptance_radius(fabsf(_mission_item.loiter_radius) * 1.2f); | ||
} | ||
|
||
/* Do not try to find a solution if the last waypoint is inside the acceptance radius of the current one */ | ||
if (_distance_current_previous - acc_rad < FLT_EPSILON) { | ||
return; | ||
} | ||
|
||
/* Don't do FOH for non-missions, landing and takeoff waypoints, the ground may be near | ||
* and the FW controller has a custom landing logic | ||
* | ||
* NAV_CMD_LOITER_TO_ALT doesn't change altitude until reaching desired lat/lon | ||
* */ | ||
if (_mission_item.nav_cmd == NAV_CMD_LAND | ||
|| _mission_item.nav_cmd == NAV_CMD_VTOL_LAND | ||
|| _mission_item.nav_cmd == NAV_CMD_TAKEOFF | ||
|| _mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT | ||
|| !_navigator->is_planned_mission()) { | ||
|
||
return; | ||
} | ||
|
||
/* Calculate distance to current waypoint */ | ||
float d_current = get_distance_to_next_waypoint(_mission_item.lat, _mission_item.lon, | ||
_navigator->get_global_position()->lat, _navigator->get_global_position()->lon); | ||
|
||
/* Save distance to waypoint if it is the smallest ever achieved, however make sure that | ||
* _min_current_sp_distance_xy is never larger than the distance between the current and the previous wp */ | ||
_min_current_sp_distance_xy = math::min(math::min(d_current, _min_current_sp_distance_xy), | ||
_distance_current_previous); | ||
|
||
/* if the minimal distance is smaller then the acceptance radius, we should be at waypoint alt | ||
* navigator will soon switch to the next waypoint item (if there is one) as soon as we reach this altitude */ | ||
if (_min_current_sp_distance_xy < acc_rad) { | ||
pos_sp_triplet->current.alt = get_absolute_altitude_for_item(_mission_item); | ||
|
||
} else { | ||
/* update the altitude sp of the 'current' item in the sp triplet, but do not update the altitude sp | ||
* of the mission item as it is used to check if the mission item is reached | ||
* The setpoint is set linearly and such that the system reaches the current altitude at the acceptance | ||
* radius around the current waypoint | ||
**/ | ||
float delta_alt = (get_absolute_altitude_for_item(_mission_item) - pos_sp_triplet->previous.alt); | ||
float grad = -delta_alt / (_distance_current_previous - acc_rad); | ||
float a = pos_sp_triplet->previous.alt - grad * _distance_current_previous; | ||
pos_sp_triplet->current.alt = a + grad * _min_current_sp_distance_xy; | ||
} | ||
|
||
// we set altitude directly so we can run this in parallel to the heading update | ||
_navigator->set_position_setpoint_triplet_updated(); | ||
} | ||
|
||
void | ||
Mission::cruising_speed_sp_update() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why two times the acceptance radius?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enough distance to cleanly enter the loiter radius. It's a bit arbitrary.
@tstastny might be cleaner to use L1 distance here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I would. This is anyway when the controller would start commanding a turn.