VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
action.h
Go to the documentation of this file.
1 // Copyright (c) 2018, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
11 #ifndef _UGCS_VSM_ACTION_H_
12 #define _UGCS_VSM_ACTION_H_
13 
14 #include <ugcs/vsm/utils.h>
15 #include <ugcs/vsm/coordinates.h>
16 #include <ugcs/vsm/property.h>
17 
18 namespace ugcs {
19 namespace vsm {
20 
22 class Action: public std::enable_shared_from_this<Action> {
24 
25 public:
27  VSM_DEFINE_EXCEPTION(Format_exception);
28 
30  enum class Type {
32  MOVE,
34  WAIT,
36  PAYLOAD_STEERING,
38  TAKEOFF,
40  LANDING,
42  CHANGE_SPEED,
44  SET_HOME,
46  POI,
48  HEADING,
50  CAMERA_CONTROL,
52  CAMERA_TRIGGER,
54  PANORAMA,
56  TASK_ATTRIBUTES,
58  CAMERA_SERIES_BY_TIME,
60  CAMERA_SERIES_BY_DISTANCE,
62  SET_PARAMETER,
64  SET_SERVO,
66  REPEAT_SERVO,
68  VTOL_TRANSITION
69  };
70 
72  Action(Type type) : type(type) {}
73 
75  virtual ~Action() {}
76 
78  Type
79  Get_type() const
80  {
81  return type;
82  }
83 
84  void
85  Set_id(int id) {
86  command_id = id;
87  }
88 
90  std::string
92  {
93  switch (type) {
94  case Type::MOVE: return "MOVE";
95  case Type::WAIT: return "WAIT";
96  case Type::PAYLOAD_STEERING: return "PAYLOAD STEERING";
97  case Type::TAKEOFF: return "TAKEOFF";
98  case Type::LANDING: return "LANDING";
99  case Type::CHANGE_SPEED: return "CHANGE SPEED";
100  case Type::SET_HOME: return "SET HOME";
101  case Type::POI: return "POI";
102  case Type::HEADING: return "HEADING";
103  case Type::CAMERA_CONTROL: return "CAMERA CONTROL";
104  case Type::CAMERA_TRIGGER: return "CAMERA TRIGGER";
105  case Type::PANORAMA: return "PANORAMA";
106  case Type::TASK_ATTRIBUTES: return "TASK ATTRIBUTES";
107  case Type::CAMERA_SERIES_BY_TIME: return "CAMERA SERIES BY TIME";
108  case Type::CAMERA_SERIES_BY_DISTANCE: return "CAMERA SERIES BY DISTANCE";
109  case Type::SET_PARAMETER: return "SET_PARAMETER";
110  case Type::SET_SERVO: return "SET_SERVO";
111  case Type::REPEAT_SERVO: return "REPEAT_SERVO";
112  case Type::VTOL_TRANSITION: return "VTOL_TRANSITION";
113  }
114  VSM_EXCEPTION(Internal_error_exception, "Action type %d unknown.",
115  static_cast<int>(type));
116  }
117 
119  template <Type type_val>
120  struct Mapper {
122  typedef Action type;
123  };
124 
131  template<Type type_val>
133  {
134  if (type_val == type) {
135  return std::static_pointer_cast<typename Mapper<type_val>::type>(Shared_from_this());
136  } else {
137  return nullptr;
138  }
139  }
140 
141  int command_id = -1;
142 
143 private:
145  const Type type;
146 };
147 
148 } /* namespace vsm */
149 } /* namespace ugcs */
150 
151 #endif /* _UGCS_VSM_ACTION_H_ */
Camera control action ugcs::vsm::Camera_control_action.
Move action ugcs::vsm::Move_action.
Continuously shot camera in regular distance intervals.
Repeat servo movement between given PWM and 1500.
Type
Types of vehicle actions as part of task (mission).
Definition: action.h:30
Action type
By default, maps to Action itself.
Definition: action.h:122
Continuously shot camera in regular time intervals.
Generic action.
Definition: action.h:22
Action(Type type)
Construct action of specific type.
Definition: action.h:72
Type Get_type() const
Get action type.
Definition: action.h:79
Various common utilities.
VSM_DEFINE_EXCEPTION(Format_exception)
Thrown when internal action representation is in a wrong format.
Panorama action ugcs::vsm::Panorama_action.
Map Action type enum value to specific Action type class.
Definition: action.h:120
Takeoff action ugcs::vsm::Takeoff_action.
std::shared_ptr< Action > Ptr
Pointer type.
Definition: action.h:23
Change speed action ugcs::vsm::Change_speed_action.
Payload steering action ugcs::vsm::Payload_steering_action.
Camera trigger action ugcs::vsm::Camera_trigger_action.
Wait action ugcs::vsm::Wait_action.
Mapper< type_val >::type::Ptr Get_action()
Get pointer to specific action as determined by Get_type.
Definition: action.h:132
Set home action ugcs::vsm::Set_home_action.
#define DEFINE_COMMON_CLASS(__class_name,...)
Use this macro to define some common attributes for a class.
Definition: utils.h:25
Coordinates manipulation.
#define VSM_EXCEPTION(__exc_class, __msg,...)
Throw VSM exception instance.
Definition: exception.h:168
std::string Get_name()
Get human readable name of the action.
Definition: action.h:91
Point of interest ugcs::vsm::Poi_action.
virtual ~Action()
Make sure Action is polymorphic.
Definition: action.h:75
Landing action ugcs::vsm::Landing_action.
Task attributes action ugcs::vsm::Task_attributes_action.
Heading ugcs::vsm::Heading_action.