51 #include <mathlib/mathlib.h> 138 float dist_xy = -1.0f;
139 float dist_z = -1.0f;
160 && (dist_xy < 2 * _navigator->get_loiter_radius())) {
163 if (curr_sp->
type == position_setpoint_s::SETPOINT_TYPE_POSITION) {
164 curr_sp->
type = position_setpoint_s::SETPOINT_TYPE_LOITER;
172 if (curr_sp->
type == position_setpoint_s::SETPOINT_TYPE_LOITER) {
175 && (dist_z < _navigator->get_loiter_radius())
176 && (dist_xy <= _navigator->get_loiter_radius() * 1.2
f)) {
178 curr_sp->
type = position_setpoint_s::SETPOINT_TYPE_POSITION;
199 if (takeoff_alt > 0 && takeoff_alt < altitude_acceptance_radius) {
200 altitude_acceptance_radius = takeoff_alt / 2.0f;
205 altitude_amsl - altitude_acceptance_radius) {
211 if (dist >= 0.0
f && dist <= _navigator->get_acceptance_radius()
226 && dist_z <= _navigator->get_altitude_acceptance_radius()) {
257 curr_sp->
alt = altitude_amsl;
263 && dist_z <= _navigator->get_altitude_acceptance_radius()) {
274 next_sp.
lat, next_sp.
lon);
310 mission_acceptance_radius = ((velocity / back_trans_dec / 2) * velocity) + reverse_delay *
velocity;
316 if (dist_xy >= 0.0
f && dist_xy <= mission_acceptance_radius
317 && dist_z <= _navigator->get_altitude_acceptance_radius()) {
392 float inner_angle = M_PI_2_F - asinf(ratio);
396 bearing -= inner_angle;
399 bearing += inner_angle;
405 &curr_sp.
lat, &curr_sp.
lon);
441 PX4_INFO(
"DO_SET_SERVO command");
541 sp->
type = position_setpoint_s::SETPOINT_TYPE_IDLE;
550 sp->
type = position_setpoint_s::SETPOINT_TYPE_POSITION;
553 sp->
type = position_setpoint_s::SETPOINT_TYPE_TAKEOFF;
562 sp->
type = position_setpoint_s::SETPOINT_TYPE_TAKEOFF;
567 sp->
type = position_setpoint_s::SETPOINT_TYPE_LAND;
584 sp->
type = position_setpoint_s::SETPOINT_TYPE_LOITER;
588 sp->
type = position_setpoint_s::SETPOINT_TYPE_POSITION;
664 vcmd.
param1 = vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC;
672 if (at_current_location) {
673 item->
lat = (double)NAN;
674 item->
lon = (double)NAN;
713 item->
params[0] = (float) new_mode;
#define VEHICLE_TYPE_FIXED_WING
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
Global position setpoint in WGS84 coordinates.
float get_distance_to_point_global_wgs84(double lat_now, double lon_now, float alt_now, double lat_next, double lon_next, float alt_next, float *dist_xy, float *dist_z)
float get_default_altitude_acceptance_radius()
Get the default altitude acceptance radius (i.e.
Helper class to access missions.
float get_acceptance_radius()
Get the acceptance radius.
API for the uORB lightweight object broker.
Definition of geo / math functions to perform geodesic calculations.
float altitude
altitude in meters (AMSL)
uint16_t autocontinue
true if next waypoint should follow after this one
float acceptance_radius
default radius in which the mission is accepted as reached in meters
bool _waypoint_position_reached_previously
float get_loiter_min_alt() const
float get_distance_to_next_waypoint(double lat_now, double lon_now, double lat_next, double lon_next)
Returns the distance to the next waypoint in meters.
float get_vtol_back_trans_deceleration() const
void set_loiter_item(struct mission_item_s *item, float min_clearance=-1.0f)
Set a loiter mission item, if possible reuse the position setpoint, otherwise take the current positi...
float get_cruising_throttle()
Get the target throttle.
struct position_setpoint_s next
Helper class to use mission items.
bool _waypoint_position_reached
struct home_position_s * get_home_position()
Getters.
uint16_t vtol_back_transition
part of the vtol back transition sequence
uint16_t origin
how the mission item was generated
float get_absolute_altitude_for_item(const mission_item_s &mission_item) const
MissionBlock(Navigator *navigator)
Constructor.
struct vehicle_land_detected_s * get_land_detected()
float get_yaw_timeout() const
bool get_can_loiter_at_sp()
double lon
longitude in degrees
struct position_setpoint_s current
uORB::Publication< actuator_controls_s > _actuator_pub
bool publish(const T &data)
Publish the struct.
void set_takeoff_item(struct mission_item_s *item, float abs_altitude, float min_pitch=0.0f)
Set a takeoff mission item.
struct vehicle_global_position_s * get_global_position()
void waypoint_from_heading_and_distance(double lat_start, double lon_start, float bearing, float dist, double *lat_target, double *lon_target)
Creates a waypoint from given waypoint, distance and bearing see http://www.movable-type.co.uk/scripts/latlong.html.
float get_cruising_speed()
Get the cruising speed.
mission_item_s _mission_item
uint16_t nav_cmd
navigation command
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
void mission_apply_limitation(mission_item_s &item)
General function used to adjust the mission item based on vehicle specific limitations.
float get_bearing_to_next_waypoint(double lat_now, double lon_now, double lat_next, double lon_next)
Returns the bearing to the next waypoint in radians.
void reset_mission_item_reached()
Reset all reached flags.
float time_inside
time that the MAV should stay inside the radius before advancing in seconds
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
float params[7]
array to store mission command values for MAV_FRAME_MISSION
Type wrap_pi(Type x)
Wrap value in range [-π, π)
float get_time_inside(const mission_item_s &item) const
struct position_setpoint_triplet_s * get_position_setpoint_triplet()
hrt_abstime _time_wp_reached
void issue_command(const mission_item_s &item)
constexpr _Tp max(_Tp a, _Tp b)
#define NAV_EPSILON_POSITION
Anything smaller than this is considered zero.
bool mission_item_to_position_setpoint(const mission_item_s &item, position_setpoint_s *sp)
Convert a mission item to a position setpoint.
bool is_mission_item_reached()
Check if mission item has been reached.
void publish_vehicle_cmd(vehicle_command_s *vcmd)
float get_loiter_radius()
static bool item_contains_position(const mission_item_s &item)
float get_default_acceptance_radius()
Returns the default acceptance radius defined by the parameter.
float get_yaw_acceptance(float mission_item_yaw)
Get the yaw acceptance given the current mission item.
bool _waypoint_yaw_reached
float pitch_min
minimal pitch angle for fixed wing takeoff waypoints
uint16_t loiter_exit_xtrack
exit xtrack location: 0 for center of loiter wp, 1 for exit location
hrt_abstime _time_first_inside_orbit
struct vehicle_status_s * get_vstatus()
void set_land_item(struct mission_item_s *item, bool at_current_location)
Set a land mission item.
uint16_t force_heading
heading needs to be reached
float yaw
in radians NED -PI..+PI, NAN means don't change yaw
float loiter_radius
loiter radius in meters, 0 for a VTOL to hover, negative for counter-clockwise
void set_mission_failure(const char *reason)
void set_position_setpoint_triplet_updated()
float get_altitude_acceptance_radius()
Get the altitude acceptance radius.
float get_yaw_threshold() const
void set_idle_item(struct mission_item_s *item)
Set idle mission item.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
struct vehicle_local_position_s * get_local_position()
float get_vtol_reverse_delay() const
uint16_t altitude_is_relative
true if altitude is relative from start point
hrt_abstime _action_start
void set_vtol_transition_item(struct mission_item_s *item, const uint8_t new_mode)
Set vtol transition item.
double lat
latitude in degrees