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

Orbit approach fixes #15292

Merged
merged 3 commits into from Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/lib/flight_tasks/tasks/Orbit/FlightTaskOrbit.cpp
Expand Up @@ -94,6 +94,7 @@ bool FlightTaskOrbit::applyCommandParameters(const vehicle_command_s &command)

// perpendicularly approach the orbit circle again when new parameters get commanded
_in_circle_approach = true;
_circle_approach_line.reset();

return ret;
}
Expand Down Expand Up @@ -126,6 +127,10 @@ bool FlightTaskOrbit::setRadius(float r)
_v = sign(_v) * sqrtf(_acceleration_max * r);
}

if (fabs(_r - r) > FLT_EPSILON) {
_circle_approach_line.reset();
}

_r = r;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/flight_tasks/tasks/Utility/StraightLine.cpp
Expand Up @@ -76,7 +76,7 @@ void StraightLine::generateSetpoints(matrix::Vector3f &position_setpoint, matrix

// check if we plan to go against the line direction which indicates we reached the goal
if (start_to_end * vehicle_to_end < 0) {
end_reached = true;
_end_reached = true;
}
}

Expand All @@ -85,6 +85,6 @@ void StraightLine::setLineFromTo(const Vector3f &start, const Vector3f &end)
if (PX4_ISFINITE(start.norm_squared()) && PX4_ISFINITE(end.norm_squared())) {
_start = start;
_end = end;
end_reached = false;
_end_reached = false;
}
}
6 changes: 4 additions & 2 deletions src/lib/flight_tasks/tasks/Utility/StraightLine.hpp
Expand Up @@ -66,7 +66,9 @@ class StraightLine
*
* @return false when on the way from start to end, true when end was reached
*/
bool isEndReached() { return end_reached; }
bool isEndReached() const { return _end_reached; }

void reset() { _end_reached = true; }

private:
const matrix::Vector3f &_position; /**< vehicle position (dependency injection) */
Expand All @@ -75,5 +77,5 @@ class StraightLine
matrix::Vector3f _end; /**< End point of the straight line */
float _speed = 1.f; /**< desired speed between accelerating and decelerating */

bool end_reached = true; /**< Flag to lock further movement when end is reached */
bool _end_reached = true; /**< Flag to lock further movement when end is reached */
};