Skip to content

Commit

Permalink
navigator: refactor naming of break instead of brake functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MaEtUgR authored and sfuhrer committed Oct 25, 2024
1 parent b8a6024 commit 37190d4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/modules/navigator/land.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Land::on_activation()

if (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
&& _navigator->get_local_position()->xy_global) { // only execute if global position is valid
_navigator->calculate_breaking_stop(_mission_item.lat, _mission_item.lon);
_navigator->preproject_stop_point(_mission_item.lat, _mission_item.lon);
}

mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current);
Expand Down Expand Up @@ -89,8 +89,7 @@ Land::on_active()
struct position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();

// create a wp in front of the VTOL while in back-transition, based on MPC settings that will apply in MC phase afterwards
_navigator->calculate_breaking_stop(pos_sp_triplet->current.lat, pos_sp_triplet->current.lon);

_navigator->preproject_stop_point(pos_sp_triplet->current.lat, pos_sp_triplet->current.lon);
_navigator->set_position_setpoint_triplet_updated();
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigator/loiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Loiter::set_loiter_position()
setLoiterItemFromCurrentPositionSetpoint(&_mission_item);

} else if (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) {
setLoiterItemFromCurrentPositionWithBreaking(&_mission_item);
setLoiterItemFromCurrentPositionWithBraking(&_mission_item);

} else {
setLoiterItemFromCurrentPosition(&_mission_item);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/navigator/mission_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,11 @@ MissionBlock::setLoiterItemFromCurrentPosition(struct mission_item_s *item)
}

void
MissionBlock::setLoiterItemFromCurrentPositionWithBreaking(struct mission_item_s *item)
MissionBlock::setLoiterItemFromCurrentPositionWithBraking(struct mission_item_s *item)
{
setLoiterItemCommonFields(item);

_navigator->calculate_breaking_stop(item->lat, item->lon);
_navigator->preproject_stop_point(item->lat, item->lon);

item->altitude = _navigator->get_global_position()->alt;
item->loiter_radius = _navigator->get_loiter_radius();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigator/mission_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class MissionBlock : public NavigatorMode
void setLoiterItemFromCurrentPositionSetpoint(struct mission_item_s *item);

void setLoiterItemFromCurrentPosition(struct mission_item_s *item);
void setLoiterItemFromCurrentPositionWithBreaking(struct mission_item_s *item);
void setLoiterItemFromCurrentPositionWithBraking(struct mission_item_s *item);

void setLoiterItemCommonFields(struct mission_item_s *item);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigator/navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class Navigator : public ModuleBase<Navigator>, public ModuleParams
void release_gimbal_control();
void set_gimbal_neutral();

void calculate_breaking_stop(double &lat, double &lon);
void preproject_stop_point(double &lat, double &lon);

void stop_capturing_images();
void disable_camera_trigger();
Expand Down
6 changes: 3 additions & 3 deletions src/modules/navigator/navigator_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void Navigator::run()
if (_vstatus.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
&& (get_position_setpoint_triplet()->current.type != position_setpoint_s::SETPOINT_TYPE_TAKEOFF)) {

calculate_breaking_stop(rep->current.lat, rep->current.lon);
preproject_stop_point(rep->current.lat, rep->current.lon);

} else {
// For fixedwings we can use the current vehicle's position to define the loiter point
Expand Down Expand Up @@ -467,7 +467,7 @@ void Navigator::run()
if (_vstatus.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
&& (get_position_setpoint_triplet()->current.type != position_setpoint_s::SETPOINT_TYPE_TAKEOFF)) {

calculate_breaking_stop(rep->current.lat, rep->current.lon);
preproject_stop_point(rep->current.lat, rep->current.lon);
}

if (PX4_ISFINITE(curr->current.loiter_radius) && curr->current.loiter_radius > FLT_EPSILON) {
Expand Down Expand Up @@ -1588,7 +1588,7 @@ bool Navigator::geofence_allows_position(const vehicle_global_position_s &pos)
return true;
}

void Navigator::calculate_breaking_stop(double &lat, double &lon)
void Navigator::preproject_stop_point(double &lat, double &lon)
{
// For multirotors we need to account for the braking distance, otherwise the vehicle will overshoot and go back
const float course_over_ground = atan2f(_local_pos.vy, _local_pos.vx);
Expand Down

0 comments on commit 37190d4

Please sign in to comment.