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