Skip to content
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

mission block: fix incorrectly calculated ccw loiter exit #19487

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/modules/navigator/mission_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,10 @@ MissionBlock::is_mission_item_reached()
_mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT)) {

float bearing = get_bearing_to_next_waypoint(curr_sp.lat, curr_sp.lon, next_sp.lat, next_sp.lon);
// We should not use asinf outside of [-1..1].
const float ratio = math::constrain(_mission_item.loiter_radius / range, -1.0f, 1.0f);
float inner_angle = M_PI_2_F - asinf(ratio);

// calculate (positive) angle between current bearing vector (orbit center to next waypoint) and vector pointing to tangent exit location
const float ratio = math::min(fabsf(_mission_item.loiter_radius / range), 1.0f);
float inner_angle = acosf(ratio);
tstastny marked this conversation as resolved.
Show resolved Hide resolved

// Compute "ideal" tangent origin
if (curr_sp.loiter_direction > 0) {
Expand Down