VSM C++ SDK
Vehicle Specific Modules SDK
action.h
Go to the documentation of this file.
1 // Copyright (c) 2014, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
11 #ifndef _ACTION_H_
12 #define _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 public:
25 
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,
67  };
68 
70  Action(Type type) : type(type) {}
71 
73  virtual ~Action() {}
74 
76  Type
77  Get_type() const
78  {
79  return type;
80  }
81 
82  void
83  Set_id(int id) {
84  command_id = id;
85  }
86 
88  std::string
90  {
91  switch (type) {
92  case Type::MOVE: return "MOVE";
93  case Type::WAIT: return "WAIT";
94  case Type::PAYLOAD_STEERING: return "PAYLOAD STEERING";
95  case Type::TAKEOFF: return "TAKEOFF";
96  case Type::LANDING: return "LANDING";
97  case Type::CHANGE_SPEED: return "CHANGE SPEED";
98  case Type::SET_HOME: return "SET HOME";
99  case Type::POI: return "POI";
100  case Type::HEADING: return "HEADING";
101  case Type::CAMERA_CONTROL: return "CAMERA CONTROL";
102  case Type::CAMERA_TRIGGER: return "CAMERA TRIGGER";
103  case Type::PANORAMA: return "PANORAMA";
104  case Type::TASK_ATTRIBUTES: return "TASK ATTRIBUTES";
105  case Type::CAMERA_SERIES_BY_TIME: return "CAMERA SERIES BY TIME";
106  case Type::CAMERA_SERIES_BY_DISTANCE: return "CAMERA SERIES BY DISTANCE";
107  case Type::SET_PARAMETER: return "SET_PARAMETER";
108  case Type::SET_SERVO: return "SET_SERVO";
109  case Type::REPEAT_SERVO: return "REPEAT_SERVO";
110  }
111  VSM_EXCEPTION(Internal_error_exception, "Action type %d unknown.",
112  static_cast<int>(type));
113  }
114 
116  template <Type type_val>
117  struct Mapper {
119  typedef Action type;
120  };
121 
128  template<Type type_val>
130  {
131  if (type_val == type) {
132  return std::static_pointer_cast<typename Mapper<type_val>::type>(Shared_from_this());
133  } else {
134  return nullptr;
135  }
136  }
137 
138  int command_id = -1;
139 
140 private:
141 
143  const Type type;
144 };
145 
146 } /* namespace vsm */
147 } /* namespace ugcs */
148 
149 #endif /* _ACTION_H_ */
UGCS root namespace.
Definition: android-linux/ugcs/vsm/platform_sockets.h:27
Camera control action ugcs::vsm::Camera_control_action.
Move action ugcs::vsm::Move_action.
Exception class with one parameter.
Definition: exception.h:88
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:119
Continuously shot camera in regular time intervals.
Generic action.
Definition: action.h:22
Action(Type type)
Construct action of specific type.
Definition: action.h:70
Type Get_type() const
Get action type.
Definition: action.h:77
Various common utilities.
Panorama action ugcs::vsm::Panorama_action.
Map Action type enum value to specific Action type class.
Definition: action.h:117
#define VSM_DEFINE_EXCEPTION(__exc_class,...)
Define custom exception type.
Definition: exception.h:202
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:129
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:170
std::string Get_name()
Get human readable name of the action.
Definition: action.h:89
Point of interest ugcs::vsm::Poi_action.
virtual ~Action()
Make sure Action is polymorphic.
Definition: action.h:73
Landing action ugcs::vsm::Landing_action.
Task attributes action ugcs::vsm::Task_attributes_action.
Heading ugcs::vsm::Heading_action.