Skip to content

Commit e916400

Browse files
JacopoPanhamishwillee
authored andcommitted
Use VehicleCommand heading for VTOL transition
1 parent 0539416 commit e916400

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/modules/navigator/navigator_main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,12 @@ void Navigator::run()
652652

653653
_vtol_takeoff.setTransitionAltitudeAbsolute(cmd.param7);
654654

655+
float epsilon = 1e-6f;
656+
if (std::fabs(cmd.param2 - 3.0f) < epsilon) { // Specified transition direction
657+
PX4_WARN("[Navigator::run] setTransitionDirecton from cmd.param4");
658+
_vtol_takeoff.setTransitionDirection(cmd.param4);
659+
}
660+
655661
// after the transition the vehicle will establish on a loiter at this position
656662
_vtol_takeoff.setLoiterLocation(matrix::Vector2d(cmd.param5, cmd.param6));
657663

src/modules/navigator/vtol_takeoff.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ VtolTakeoff::on_active()
7171
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
7272

7373
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
74-
_mission_item.yaw = wrap_pi(get_bearing_to_next_waypoint(_mission_item.lat,
75-
_mission_item.lon, _loiter_location(0), _loiter_location(1)));
74+
if (std::isnan(_transition_direction_deg)) {
75+
_mission_item.yaw = wrap_pi(get_bearing_to_next_waypoint(_navigator->get_home_position()->lat,
76+
_navigator->get_home_position()->lon, _loiter_location(0), _loiter_location(1)));
77+
} else {
78+
PX4_WARN("[VtolTakeoff] Transition direction from Command");
79+
_mission_item.yaw = wrap_pi(math::radians(_transition_direction_deg));
80+
}
7681
_mission_item.force_heading = true;
7782
mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current);
7883
pos_sp_triplet->current.cruising_speed = -1.f;

src/modules/navigator/vtol_takeoff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class VtolTakeoff : public MissionBlock, public ModuleParams
5555
void on_active() override;
5656

5757
void setTransitionAltitudeAbsolute(const float alt_amsl) {_transition_alt_amsl = alt_amsl; }
58+
void setTransitionDirection(const float tran_bear) {_transition_direction_deg = tran_bear; }
5859

5960
void setLoiterLocation(matrix::Vector2d loiter_location) { _loiter_location = loiter_location; }
6061
void setLoiterHeight(const float height_m) { _loiter_height = height_m; }
@@ -73,6 +74,7 @@ class VtolTakeoff : public MissionBlock, public ModuleParams
7374
float _takeoff_alt_msl{0.f};
7475
matrix::Vector2d _loiter_location;
7576
float _loiter_height{0};
77+
float _transition_direction_deg{NAN};
7678

7779
DEFINE_PARAMETERS(
7880
(ParamFloat<px4::params::VTO_LOITER_ALT>) _param_loiter_alt

0 commit comments

Comments
 (0)