PX4 Firmware
PX4 Autopilot Software http://px4.io
mission_block.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2014 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 /**
34  * @file mission_block.cpp
35  *
36  * Helper class to use mission items
37  *
38  * @author Julian Oes <julian@oes.ch>
39  * @author Sander Smeets <sander@droneslab.com>
40  * @author Andreas Antener <andreas@uaventure.com>
41  */
42 
43 #include "mission_block.h"
44 #include "navigator.h"
45 
46 #include <math.h>
47 #include <float.h>
48 
49 #include <lib/ecl/geo/geo.h>
50 #include <systemlib/mavlink_log.h>
51 #include <mathlib/mathlib.h>
52 #include <uORB/uORB.h>
56 
57 using matrix::wrap_pi;
58 
60  NavigatorMode(navigator)
61 {
62  _mission_item.lat = (double)NAN;
63  _mission_item.lon = (double)NAN;
64  _mission_item.yaw = NAN;
70 }
71 
72 bool
74 {
75  /* handle non-navigation or indefinite waypoints */
76 
77  switch (_mission_item.nav_cmd) {
79  return true;
80 
81  case NAV_CMD_LAND: /* fall through */
82  case NAV_CMD_VTOL_LAND:
84 
85  case NAV_CMD_IDLE: /* fall through */
87  return false;
88 
98  case NAV_CMD_DO_SET_ROI:
105  return true;
106 
108 
109  /*
110  * We wait half a second to give the transition command time to propagate.
111  * Then monitor the transition status for completion.
112  */
113  // TODO: check desired transition state achieved and drop _action_start
114  if (hrt_absolute_time() - _action_start > 500000 &&
116 
117  _action_start = 0;
118  return true;
119 
120  } else {
121  return false;
122  }
123 
125  case NAV_CMD_DO_SET_HOME:
126  return true;
127 
128  default:
129  /* do nothing, this is a 3D waypoint */
130  break;
131  }
132 
134 
136 
137  float dist = -1.0f;
138  float dist_xy = -1.0f;
139  float dist_z = -1.0f;
140 
141  float altitude_amsl = _mission_item.altitude_is_relative
144 
149  &dist_xy, &dist_z);
150 
151  /* FW special case for NAV_CMD_WAYPOINT to achieve altitude via loiter */
154 
156 
157  /* close to waypoint, but altitude error greater than twice acceptance */
158  if ((dist >= 0.0f)
159  && (dist_z > 2 * _navigator->get_altitude_acceptance_radius())
160  && (dist_xy < 2 * _navigator->get_loiter_radius())) {
161 
162  /* SETPOINT_TYPE_POSITION -> SETPOINT_TYPE_LOITER */
163  if (curr_sp->type == position_setpoint_s::SETPOINT_TYPE_POSITION) {
164  curr_sp->type = position_setpoint_s::SETPOINT_TYPE_LOITER;
166  curr_sp->loiter_direction = 1;
168  }
169 
170  } else {
171  /* restore SETPOINT_TYPE_POSITION */
172  if (curr_sp->type == position_setpoint_s::SETPOINT_TYPE_LOITER) {
173  /* loiter acceptance criteria required to revert back to SETPOINT_TYPE_POSITION */
174  if ((dist >= 0.0f)
175  && (dist_z < _navigator->get_loiter_radius())
176  && (dist_xy <= _navigator->get_loiter_radius() * 1.2f)) {
177 
178  curr_sp->type = position_setpoint_s::SETPOINT_TYPE_POSITION;
180  }
181  }
182  }
183  }
184 
186  && _navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) {
187 
188  /* We want to avoid the edge case where the acceptance radius is bigger or equal than
189  * the altitude of the takeoff waypoint above home. Otherwise, we do not really follow
190  * take-off procedures like leaving the landing gear down. */
191 
192  float takeoff_alt = _mission_item.altitude_is_relative ?
195 
196  float altitude_acceptance_radius = _navigator->get_altitude_acceptance_radius();
197 
198  /* It should be safe to just use half of the takoeff_alt as an acceptance radius. */
199  if (takeoff_alt > 0 && takeoff_alt < altitude_acceptance_radius) {
200  altitude_acceptance_radius = takeoff_alt / 2.0f;
201  }
202 
203  /* require only altitude for takeoff for multicopter */
205  altitude_amsl - altitude_acceptance_radius) {
207  }
208 
209  } else if (_mission_item.nav_cmd == NAV_CMD_TAKEOFF) {
210  /* for takeoff mission items use the parameter for the takeoff acceptance radius */
211  if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius()
212  && dist_z <= _navigator->get_altitude_acceptance_radius()) {
214  }
215 
219  /* Loiter mission item on a non rotary wing: the aircraft is going to circle the
220  * coordinates with a radius equal to the loiter_radius field. It is not flying
221  * through the waypoint center.
222  * Therefore the item is marked as reached once the system reaches the loiter
223  * radius (+ some margin). Time inside and turn count is handled elsewhere.
224  */
225  if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius(fabsf(_mission_item.loiter_radius) * 1.2f)
226  && dist_z <= _navigator->get_altitude_acceptance_radius()) {
227 
229 
230  } else {
232  }
233 
236 
237 
238  // NAV_CMD_LOITER_TO_ALT only uses mission item altitude once it's in the loiter
239  // first check if the altitude setpoint is the mission setpoint
241 
242  if (fabsf(curr_sp->alt - altitude_amsl) >= FLT_EPSILON) {
243  // check if the initial loiter has been accepted
244  dist_xy = -1.0f;
245  dist_z = -1.0f;
246 
251  &dist_xy, &dist_z);
252 
253  if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius(fabsf(_mission_item.loiter_radius) * 1.2f)
255 
256  // now set the loiter to the final altitude in the NAV_CMD_LOITER_TO_ALT mission item
257  curr_sp->alt = altitude_amsl;
259  }
260 
261  } else {
262  if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius(fabsf(_mission_item.loiter_radius) * 1.2f)
263  && dist_z <= _navigator->get_altitude_acceptance_radius()) {
264 
266 
267  // set required yaw from bearing to the next mission item
270 
271  if (next_sp.valid) {
274  next_sp.lat, next_sp.lon);
275 
276  _waypoint_yaw_reached = false;
277 
278  } else {
279  _waypoint_yaw_reached = true;
280  }
281  }
282  }
283  }
284 
285  } else if (_mission_item.nav_cmd == NAV_CMD_DELAY) {
287  _waypoint_yaw_reached = true;
288  _time_wp_reached = now;
289 
290  } else {
291  /* for normal mission items used their acceptance radius */
292  float mission_acceptance_radius = _navigator->get_acceptance_radius(_mission_item.acceptance_radius);
293 
294  /* if set to zero use the default instead */
295  if (mission_acceptance_radius < NAV_EPSILON_POSITION) {
296  mission_acceptance_radius = _navigator->get_acceptance_radius();
297  }
298 
299  /* for vtol back transition calculate acceptance radius based on time and ground speed */
302 
305 
306  const float back_trans_dec = _navigator->get_vtol_back_trans_deceleration();
307  const float reverse_delay = _navigator->get_vtol_reverse_delay();
308 
309  if (back_trans_dec > FLT_EPSILON && velocity > FLT_EPSILON) {
310  mission_acceptance_radius = ((velocity / back_trans_dec / 2) * velocity) + reverse_delay * velocity;
311 
312  }
313 
314  }
315 
316  if (dist_xy >= 0.0f && dist_xy <= mission_acceptance_radius
317  && dist_z <= _navigator->get_altitude_acceptance_radius()) {
319  }
320  }
321 
323  // reached just now
324  _time_wp_reached = now;
325  }
326  }
327 
328  /* Check if the waypoint and the requested yaw setpoint. */
329 
331 
332  if ((_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
333  && PX4_ISFINITE(_navigator->get_yaw_acceptance(_mission_item.yaw)))
335  && PX4_ISFINITE(_mission_item.yaw))) {
336 
337  /* check course if defined only for rotary wing except takeoff */
338  float cog = (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) ?
340  atan2f(
343  );
344 
345  float yaw_err = wrap_pi(_mission_item.yaw - cog);
346 
347  /* accept yaw if reached or if timeout is set in which case we ignore not forced headings */
348  if (fabsf(yaw_err) < _navigator->get_yaw_threshold()
350 
351  _waypoint_yaw_reached = true;
352  }
353 
354  /* if heading needs to be reached, the timeout is enabled and we don't make it, abort mission */
357  (now - _time_wp_reached >= (hrt_abstime)_navigator->get_yaw_timeout() * 1e6f)) {
358 
359  _navigator->set_mission_failure("unable to reach heading within timeout");
360  }
361 
362  } else {
363  _waypoint_yaw_reached = true;
364  }
365  }
366 
367  /* Once the waypoint and yaw setpoint have been reached we can start the loiter time countdown */
369 
370  if (_time_first_inside_orbit == 0) {
372  }
373 
374  /* check if the MAV was long enough inside the waypoint orbit */
377 
380 
381  const float range = get_distance_to_next_waypoint(curr_sp.lat, curr_sp.lon, next_sp.lat, next_sp.lon);
382 
383  // exit xtrack location
384  // reset lat/lon of loiter waypoint so vehicle follows a tangent
385  if (_mission_item.loiter_exit_xtrack && next_sp.valid && PX4_ISFINITE(range) &&
388 
389  float bearing = get_bearing_to_next_waypoint(curr_sp.lat, curr_sp.lon, next_sp.lat, next_sp.lon);
390  // We should not use asinf outside of [-1..1].
391  const float ratio = math::constrain(_mission_item.loiter_radius / range, -1.0f, 1.0f);
392  float inner_angle = M_PI_2_F - asinf(ratio);
393 
394  // Compute "ideal" tangent origin
395  if (curr_sp.loiter_direction > 0) {
396  bearing -= inner_angle;
397 
398  } else {
399  bearing += inner_angle;
400  }
401 
402  // Replace current setpoint lat/lon with tangent coordinate
403  waypoint_from_heading_and_distance(curr_sp.lat, curr_sp.lon,
404  bearing, curr_sp.loiter_radius,
405  &curr_sp.lat, &curr_sp.lon);
406  }
407 
408  return true;
409  }
410  }
411 
412  // all acceptance criteria must be met in the same iteration
415  _waypoint_yaw_reached = false;
416  return false;
417 }
418 
419 void
421 {
423  _waypoint_yaw_reached = false;
425  _time_wp_reached = 0;
426 }
427 
428 void
430 {
431  if (item_contains_position(item)) {
432  return;
433  }
434 
435  // NAV_CMD_DO_LAND_START is only a marker
436  if (item.nav_cmd == NAV_CMD_DO_LAND_START) {
437  return;
438  }
439 
440  if (item.nav_cmd == NAV_CMD_DO_SET_SERVO) {
441  PX4_INFO("DO_SET_SERVO command");
442 
443  // XXX: we should issue a vehicle command and handle this somewhere else
444  actuator_controls_s actuators = {};
445  actuators.timestamp = hrt_absolute_time();
446 
447  // params[0] actuator number to be set 0..5 (corresponds to AUX outputs 1..6)
448  // params[1] new value for selected actuator in ms 900...2000
449  actuators.control[(int)item.params[0]] = 1.0f / 2000 * -item.params[1];
450 
451  _actuator_pub.publish(actuators);
452 
453  } else {
455 
456  // mission_item -> vehicle_command
457 
458  // we're expecting a mission command item here so assign the "raw" inputs to the command
459  // (MAV_FRAME_MISSION mission item)
460  vehicle_command_s vcmd = {};
461  vcmd.command = item.nav_cmd;
462  vcmd.param1 = item.params[0];
463  vcmd.param2 = item.params[1];
464  vcmd.param3 = item.params[2];
465  vcmd.param4 = item.params[3];
466 
468  vcmd.param5 = item.lat;
469  vcmd.param6 = item.lon;
470  vcmd.param7 = item.altitude + _navigator->get_home_position()->alt;
471 
472  } else {
473  vcmd.param5 = (double)item.params[4];
474  vcmd.param6 = (double)item.params[5];
475  vcmd.param7 = item.params[6];
476  }
477 
479  }
480 }
481 
482 float
484 {
485  if ((item.nav_cmd == NAV_CMD_WAYPOINT
486  && _navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) ||
488  item.nav_cmd == NAV_CMD_DELAY) {
489 
490  // a negative time inside would be invalid
491  return math::max(item.time_inside, 0.0f);
492  }
493 
494  return 0.0f;
495 }
496 
497 bool
499 {
500  return item.nav_cmd == NAV_CMD_WAYPOINT ||
503  item.nav_cmd == NAV_CMD_LAND ||
504  item.nav_cmd == NAV_CMD_TAKEOFF ||
505  item.nav_cmd == NAV_CMD_LOITER_TO_ALT ||
506  item.nav_cmd == NAV_CMD_VTOL_TAKEOFF ||
507  item.nav_cmd == NAV_CMD_VTOL_LAND ||
509 }
510 
511 bool
513 {
514  /* don't change the setpoint for non-position items */
515  if (!item_contains_position(item)) {
516  return false;
517  }
518 
519  sp->lat = item.lat;
520  sp->lon = item.lon;
522  sp->yaw = item.yaw;
523  sp->yaw_valid = PX4_ISFINITE(item.yaw);
524  sp->loiter_radius = (fabsf(item.loiter_radius) > NAV_EPSILON_POSITION) ? fabsf(item.loiter_radius) :
526  sp->loiter_direction = (item.loiter_radius > 0) ? 1 : -1;
527 
528  if (item.acceptance_radius > 0.0f && PX4_ISFINITE(item.acceptance_radius)) {
529  // if the mission item has a specified acceptance radius, overwrite the default one from parameters
531 
532  } else {
534  }
535 
538 
539  switch (item.nav_cmd) {
540  case NAV_CMD_IDLE:
541  sp->type = position_setpoint_s::SETPOINT_TYPE_IDLE;
542  break;
543 
544  case NAV_CMD_TAKEOFF:
545 
546  // if already flying (armed and !landed) treat TAKEOFF like regular POSITION
547  if ((_navigator->get_vstatus()->arming_state == vehicle_status_s::ARMING_STATE_ARMED)
549 
550  sp->type = position_setpoint_s::SETPOINT_TYPE_POSITION;
551 
552  } else {
553  sp->type = position_setpoint_s::SETPOINT_TYPE_TAKEOFF;
554 
555  // set pitch and ensure that the hold time is zero
556  sp->pitch_min = item.pitch_min;
557  }
558 
559  break;
560 
562  sp->type = position_setpoint_s::SETPOINT_TYPE_TAKEOFF;
563  break;
564 
565  case NAV_CMD_LAND:
566  case NAV_CMD_VTOL_LAND:
567  sp->type = position_setpoint_s::SETPOINT_TYPE_LAND;
568  break;
569 
571 
572  // initially use current altitude, and switch to mission item altitude once in loiter position
573  if (_navigator->get_loiter_min_alt() > 0.0f) { // ignore _param_loiter_min_alt if smaller than 0 (-1)
576 
577  } else {
579  }
580 
581  // fall through
584  sp->type = position_setpoint_s::SETPOINT_TYPE_LOITER;
585  break;
586 
587  default:
588  sp->type = position_setpoint_s::SETPOINT_TYPE_POSITION;
589  break;
590  }
591 
592  sp->valid = true;
594 
595  return sp->valid;
596 }
597 
598 void
599 MissionBlock::set_loiter_item(struct mission_item_s *item, float min_clearance)
600 {
602  /* landed, don't takeoff, but switch to IDLE mode */
603  item->nav_cmd = NAV_CMD_IDLE;
604 
605  } else {
607 
609 
610  if (_navigator->get_can_loiter_at_sp() && pos_sp_triplet->current.valid) {
611  /* use current position setpoint */
612  item->lat = pos_sp_triplet->current.lat;
613  item->lon = pos_sp_triplet->current.lon;
614  item->altitude = pos_sp_triplet->current.alt;
615 
616  } else {
617  /* use current position and use return altitude as clearance */
621 
622  if (min_clearance > 0.0f && item->altitude < _navigator->get_home_position()->alt + min_clearance) {
623  item->altitude = _navigator->get_home_position()->alt + min_clearance;
624  }
625  }
626 
627  item->altitude_is_relative = false;
628  item->yaw = NAN;
631  item->time_inside = 0.0f;
632  item->autocontinue = false;
633  item->origin = ORIGIN_ONBOARD;
634  }
635 }
636 
637 void
638 MissionBlock::set_takeoff_item(struct mission_item_s *item, float abs_altitude, float min_pitch)
639 {
640  item->nav_cmd = NAV_CMD_TAKEOFF;
641 
642  /* use current position */
646 
647  item->altitude = abs_altitude;
648  item->altitude_is_relative = false;
649 
651  item->pitch_min = min_pitch;
652  item->autocontinue = false;
653  item->origin = ORIGIN_ONBOARD;
654 }
655 
656 void
657 MissionBlock::set_land_item(struct mission_item_s *item, bool at_current_location)
658 {
659  /* VTOL transition to RW before landing */
660  if (_navigator->force_vtol()) {
661 
662  vehicle_command_s vcmd = {};
664  vcmd.param1 = vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC;
666  }
667 
668  /* set the land item */
669  item->nav_cmd = NAV_CMD_LAND;
670 
671  /* use current position */
672  if (at_current_location) {
673  item->lat = (double)NAN; //descend at current position
674  item->lon = (double)NAN; //descend at current position
675  item->yaw = _navigator->get_local_position()->yaw;
676 
677  } else {
678  /* use home position */
679  item->lat = _navigator->get_home_position()->lat;
680  item->lon = _navigator->get_home_position()->lon;
681  item->yaw = _navigator->get_home_position()->yaw;
682  }
683 
684  item->altitude = 0;
685  item->altitude_is_relative = false;
688  item->time_inside = 0.0f;
689  item->autocontinue = true;
690  item->origin = ORIGIN_ONBOARD;
691 }
692 
693 void
695 {
696  item->nav_cmd = NAV_CMD_IDLE;
697  item->lat = _navigator->get_home_position()->lat;
698  item->lon = _navigator->get_home_position()->lon;
699  item->altitude_is_relative = false;
701  item->yaw = NAN;
704  item->time_inside = 0.0f;
705  item->autocontinue = true;
706  item->origin = ORIGIN_ONBOARD;
707 }
708 
709 void
710 MissionBlock::set_vtol_transition_item(struct mission_item_s *item, const uint8_t new_mode)
711 {
713  item->params[0] = (float) new_mode;
715  item->autocontinue = true;
716 }
717 
718 void
720 {
721  /*
722  * Limit altitude
723  */
724 
725  /* do nothing if altitude max is negative */
726  if (_navigator->get_land_detected()->alt_max > 0.0f) {
727 
728  /* absolute altitude */
729  float altitude_abs = item.altitude_is_relative
731  : item.altitude;
732 
733  /* limit altitude to maximum allowed altitude */
734  if ((_navigator->get_land_detected()->alt_max + _navigator->get_home_position()->alt) < altitude_abs) {
735  item.altitude = item.altitude_is_relative ?
738 
739  }
740  }
741 
742  /*
743  * Add other limitations here
744  */
745 }
746 
747 float
749 {
750  if (mission_item.altitude_is_relative) {
751  return mission_item.altitude + _navigator->get_home_position()->alt;
752 
753  } else {
754  return mission_item.altitude;
755  }
756 }
#define VEHICLE_TYPE_FIXED_WING
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
Definition: Limits.hpp:66
Global position setpoint in WGS84 coordinates.
Definition: navigation.h:145
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)
Definition: geo.cpp:523
float get_default_altitude_acceptance_radius()
Get the default altitude acceptance radius (i.e.
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)
Definition: navigation.h:160
uint16_t autocontinue
true if next waypoint should follow after this one
Definition: navigation.h:177
float acceptance_radius
default radius in which the mission is accepted as reached in meters
Definition: navigation.h:155
bool _waypoint_position_reached_previously
float get_loiter_min_alt() const
Definition: navigator.h:285
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.
Definition: geo.cpp:270
float get_vtol_back_trans_deceleration() const
Definition: navigator.h:291
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.
Definition: navigator.h:151
uint16_t vtol_back_transition
part of the vtol back transition sequence
Definition: navigation.h:177
uint16_t origin
how the mission item was generated
Definition: navigation.h:177
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()
Definition: navigator.h:157
float get_yaw_timeout() const
Definition: navigator.h:288
#define FLT_EPSILON
bool get_can_loiter_at_sp()
Definition: navigator.h:170
double lon
longitude in degrees
Definition: navigation.h:147
Navigator * _navigator
struct position_setpoint_s current
uORB::Publication< actuator_controls_s > _actuator_pub
bool publish(const T &data)
Publish the struct.
Definition: Publication.hpp:68
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()
Definition: navigator.h:156
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.
Definition: geo.cpp:303
float get_cruising_speed()
Get the cruising speed.
mission_item_s _mission_item
uint16_t nav_cmd
navigation command
Definition: navigation.h:165
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
Definition: integration.cpp:8
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.
Definition: geo.cpp:320
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
Definition: navigation.h:151
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
float params[7]
array to store mission command values for MAV_FRAME_MISSION
Definition: navigation.h:162
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()
Definition: navigator.h:153
hrt_abstime _time_wp_reached
void issue_command(const mission_item_s &item)
constexpr _Tp max(_Tp a, _Tp b)
Definition: Limits.hpp:60
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()
Definition: navigator.h:171
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
Definition: navigation.h:152
uint16_t loiter_exit_xtrack
exit xtrack location: 0 for center of loiter wp, 1 for exit location
Definition: navigation.h:177
hrt_abstime _time_first_inside_orbit
struct vehicle_status_s * get_vstatus()
Definition: navigator.h:159
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
Definition: navigation.h:177
float yaw
in radians NED -PI..+PI, NAN means don&#39;t change yaw
Definition: navigation.h:157
float loiter_radius
loiter radius in meters, 0 for a VTOL to hover, negative for counter-clockwise
Definition: navigation.h:156
void set_mission_failure(const char *reason)
void set_position_setpoint_triplet_updated()
Definition: navigator.h:145
float get_altitude_acceptance_radius()
Get the altitude acceptance radius.
float get_yaw_threshold() const
Definition: navigator.h:289
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()
Definition: navigator.h:158
float get_vtol_reverse_delay() const
Definition: navigator.h:292
uint16_t altitude_is_relative
true if altitude is relative from start point
Definition: navigation.h:177
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
Definition: navigation.h:146