mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-22 06:14:14 +08:00
@@ -47,6 +47,7 @@ static constexpr int kMaxNodes = 100;
|
||||
static constexpr int kCircleApproxVertices = 8;
|
||||
|
||||
struct PlannedPath {
|
||||
// does not include the start and the end, just intermediate points
|
||||
static constexpr int kMaxPathPoints = 32;
|
||||
matrix::Vector2<double> points[kMaxPathPoints];
|
||||
int num_points{0};
|
||||
@@ -64,19 +65,20 @@ struct PlannedPath {
|
||||
|
||||
}
|
||||
|
||||
matrix::Vector2<double> getNextPoint()
|
||||
matrix::Vector2<double> getAndPopCurrentPoint()
|
||||
{
|
||||
if (current_index < num_points) {
|
||||
return points[current_index++];
|
||||
|
||||
} else {
|
||||
return points[num_points - 1];
|
||||
return matrix::Vector2d{NAN, NAN};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
matrix::Vector2d getCurrentPoint()
|
||||
{
|
||||
// returns the current points but does not increase the index
|
||||
if (current_index < num_points) {
|
||||
return points[current_index];
|
||||
}
|
||||
|
||||
@@ -250,7 +250,14 @@ void RtlDirect::set_rtl_item()
|
||||
|
||||
case RTLState::MOVE_TO_INTERMEDIATE_POINT: {
|
||||
|
||||
const matrix::Vector2d point = _geofence_aware_return_path.getNextPoint();
|
||||
matrix::Vector2d point = _geofence_aware_return_path.getAndPopCurrentPoint();
|
||||
|
||||
if (point.isAllNan()) {
|
||||
// should never happen
|
||||
point(0) = _land_approach.lat;
|
||||
point(1) = _land_approach.lon;
|
||||
}
|
||||
|
||||
PositionYawSetpoint pos_yaw_sp {
|
||||
.lat = point(0),
|
||||
.lon = point(1),
|
||||
|
||||
Reference in New Issue
Block a user