Skip to content

Commit

Permalink
integrated PrecisionLanding
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio-Chies committed Sep 27, 2024
1 parent 2426f7c commit 1b23655
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/modules/flight_mode_manager/FlightModeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void FlightModeManager::start_flight_task()
bool matching_task_running = true;
bool task_failure = false;
const bool nav_state_descend = (_vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_DESCEND);
const bool nav_state_land = (_vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_LAND);
const bool nav_state_land = (_vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_LAND
|| _vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_PRECLAND);

// Follow me
if (_vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_FOLLOW_TARGET) {
Expand Down
25 changes: 25 additions & 0 deletions src/modules/flight_mode_manager/tasks/Land/FlightTaskLand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ FlightTaskLand::reActivate()
_position_smoothing.reset({0.f, 0.f, 0.f}, {0.f, 0.f, 0.7f}, _position);
}

bool
FlightTaskLand::updateInitialize()
{
bool ret = FlightTask::updateInitialize();
_sub_triplet_setpoint.update();

double ref_lat = _sub_vehicle_local_position.get().ref_lat;
double ref_lon = _sub_vehicle_local_position.get().ref_lon;

_reference_position.initReference(ref_lat, ref_lon);

// if we have valid current position setpoint, then we are in the precision landing mode
if (_sub_triplet_setpoint.get().current.valid) {
_precision_landing = true;
}

return ret;
}

bool
FlightTaskLand::update()
{
Expand All @@ -99,6 +118,12 @@ FlightTaskLand::update()
}

if (_landing) {
if (_precision_landing) {
// set the landing position based on the current position setpoint which gets updated by precision landing
_reference_position.project(_sub_triplet_setpoint.get().current.lat, _sub_triplet_setpoint.get().current.lon,
_land_position(0), _land_position(1));
}

_PerformLanding();

} else {
Expand Down
4 changes: 4 additions & 0 deletions src/modules/flight_mode_manager/tasks/Land/FlightTaskLand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class FlightTaskLand : public FlightTask
bool update() override;
bool activate(const trajectory_setpoint_s &last_setpoint) override;
void reActivate() override;
bool updateInitialize() override;

protected:
void updateParams() override;
Expand Down Expand Up @@ -95,12 +96,15 @@ class FlightTaskLand : public FlightTask
(ParamFloat<px4::params::NAV_MC_ALT_RAD>) _param_nav_mc_alt_rad
);
private:
MapProjection _reference_position{};

void _CalculateBrakingLocation();
void _HandleHighVelocities();
void _PerformLanding();
void _SmoothBrakingPath();
void _UpdateTrajConstraints();

bool _precision_landing{false};
bool _landing{false};
bool _is_initialized{false};
bool _exceeded_max_vel{false};
Expand Down
11 changes: 11 additions & 0 deletions src/modules/navigator/land.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ Land::on_activation()
pos_sp_triplet->previous.valid = false;
pos_sp_triplet->next.valid = false;

if (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) {
// set the lat and lon to NAN, as the target setpoint for landing is handeled in FlightTaskLand, not in the navigator.
pos_sp_triplet->current.valid = false;
pos_sp_triplet->current.lat = (double) NAN;
pos_sp_triplet->current.lon = (double) NAN;
pos_sp_triplet->previous.lat = (double) NAN;
pos_sp_triplet->previous.lon = (double) NAN;
pos_sp_triplet->next.lat = (double) NAN;
pos_sp_triplet->next.lon = (double) NAN;
}

_navigator->set_position_setpoint_triplet_updated();

// reset cruising speed to default
Expand Down

0 comments on commit 1b23655

Please sign in to comment.