PX4 Firmware
PX4 Autopilot Software http://px4.io
mission_block.h
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.h
35  *
36  * Helper class to use mission items
37  *
38  * @author Julian Oes <julian@oes.ch>
39  */
40 
41 #pragma once
42 
43 #include "navigator_mode.h"
44 #include "navigation.h"
45 
46 #include <drivers/drv_hrt.h>
47 #include <systemlib/mavlink_log.h>
48 #include <uORB/Publication.hpp>
50 #include <uORB/topics/mission.h>
55 
56 class Navigator;
57 
59 {
60 public:
61  /**
62  * Constructor
63  */
65  virtual ~MissionBlock() = default;
66 
67  MissionBlock(const MissionBlock &) = delete;
68  MissionBlock &operator=(const MissionBlock &) = delete;
69 
70  static bool item_contains_position(const mission_item_s &item);
71 
72 protected:
73  /**
74  * Check if mission item has been reached
75  * @return true if successfully reached
76  */
78 
79  /**
80  * Reset all reached flags
81  */
83 
84  /**
85  * Convert a mission item to a position setpoint
86  *
87  * @param the mission item to convert
88  * @param the position setpoint that needs to be set
89  */
91 
92  /**
93  * Set a loiter mission item, if possible reuse the position setpoint, otherwise take the current position
94  */
95  void set_loiter_item(struct mission_item_s *item, float min_clearance = -1.0f);
96 
97  /**
98  * Set a takeoff mission item
99  */
100  void set_takeoff_item(struct mission_item_s *item, float abs_altitude, float min_pitch = 0.0f);
101 
102  /**
103  * Set a land mission item
104  */
105  void set_land_item(struct mission_item_s *item, bool at_current_location);
106 
107  /**
108  * Set idle mission item
109  */
110  void set_idle_item(struct mission_item_s *item);
111 
112  /**
113  * Set vtol transition item
114  */
115  void set_vtol_transition_item(struct mission_item_s *item, const uint8_t new_mode);
116 
117  /**
118  * General function used to adjust the mission item based on vehicle specific limitations
119  */
121 
122  void issue_command(const mission_item_s &item);
123 
124  float get_time_inside(const mission_item_s &item) const ;
125 
126  float get_absolute_altitude_for_item(const mission_item_s &mission_item) const;
127 
129 
133 
137 
139 };
Global position setpoint in WGS84 coordinates.
Definition: navigation.h:145
bool _waypoint_position_reached_previously
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...
bool _waypoint_position_reached
virtual ~MissionBlock()=default
float get_absolute_altitude_for_item(const mission_item_s &mission_item) const
MissionBlock(Navigator *navigator)
Constructor.
High-resolution timer with callouts and timekeeping.
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
uORB::Publication< actuator_controls_s > _actuator_pub
void set_takeoff_item(struct mission_item_s *item, float abs_altitude, float min_pitch=0.0f)
Set a takeoff mission item.
mission_item_s _mission_item
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.
void reset_mission_item_reached()
Reset all reached flags.
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
float get_time_inside(const mission_item_s &item) const
hrt_abstime _time_wp_reached
void issue_command(const mission_item_s &item)
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.
static bool item_contains_position(const mission_item_s &item)
bool _waypoint_yaw_reached
MissionBlock & operator=(const MissionBlock &)=delete
hrt_abstime _time_first_inside_orbit
void set_land_item(struct mission_item_s *item, bool at_current_location)
Set a land mission item.
void set_idle_item(struct mission_item_s *item)
Set idle mission item.
hrt_abstime _action_start
void set_vtol_transition_item(struct mission_item_s *item, const uint8_t new_mode)
Set vtol transition item.