VSM C++ SDK
Vehicle Specific Modules SDK
poi_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 
8 #ifndef _POI_ACTION_H_
9 #define _POI_ACTION_H_
10 
11 #include <ugcs/vsm/action.h>
12 
13 namespace ugcs {
14 namespace vsm {
15 
17 class Poi_action:public Action {
19 
20 public:
21 
24  Action(Type::POI),
25  position(position), active(active) {}
26 
27 
34  Poi_action(const mavlink::ugcs::Pld_mission_item_ex& item) :
35  Action(Type::POI),
36  position(Geodetic_tuple(item->x * M_PI / 180.0,
37  item->y * M_PI / 180.0,
38  item->z)),
39  active(item->param1 == mavlink::MAV_ROI::MAV_ROI_LOCATION ? true : false)
40  {
41  ASSERT(item->command == mavlink::MAV_CMD::MAV_CMD_NAV_ROI);
42  if (item->param1 != mavlink::MAV_ROI::MAV_ROI_LOCATION &&
43  item->param1 != mavlink::MAV_ROI::MAV_ROI_NONE) {
44  VSM_EXCEPTION(Format_exception, "POI action unsupported type %f",
45  item->param1.Get());
46  }
47  }
48 
53  Action(Type::POI),
54  position(Geodetic_tuple(0,0,0))
55  {
56  double lat = 0, lon = 0, alt = 0;
57  auto pi = p.find("latitude");
58  if (pi != p.end()) {
59  pi->second->Get_value(lat);
60  }
61  pi = p.find("longitude");
62  if (pi != p.end()) {
63  pi->second->Get_value(lon);
64  }
65  pi = p.find("altitude_amsl");
66  if (pi != p.end()) {
67  pi->second->Get_value(alt);
68  }
69  position = Geodetic_tuple(lat, lon, alt);
70  p.at("active")->Get_value(active);
71  }
72 
75 
78  bool active;
79 };
80 
82 template<>
85  typedef Poi_action type;
86 };
87 
88 } /* namespace vsm */
89 } /* namespace ugcs */
90 
91 #endif /* _POI_ACTION_H_ */
UGCS root namespace.
Definition: android-linux/ugcs/vsm/platform_sockets.h:27
Exception class with one parameter.
Definition: exception.h:88
Definition: property.h:191
Coordinates tuple for geodetic CS.
Definition: coordinates.h:41
Point of interest (POI) for a vehicle.
Definition: poi_action.h:17
Type
Types of vehicle actions as part of task (mission).
Definition: action.h:30
bool active
true - POI is active and should be monitored, false - POI is not active and should not be anymore mon...
Definition: poi_action.h:78
Generic action.
Definition: action.h:22
Poi_action(const Property_list &p)
Construct action from protobuf command.
Definition: poi_action.h:52
#define ASSERT(x)
No action in release.
Definition: debug.h:68
Generic action.
Map Action type enum value to specific Action type class.
Definition: action.h:117
Wgs84_position position
Position of a a POI.
Definition: poi_action.h:74
#define M_PI
PI constant.
Definition: coordinates.h:21
#define DEFINE_COMMON_CLASS(__class_name,...)
Use this macro to define some common attributes for a class.
Definition: utils.h:25
Poi_action(const mavlink::ugcs::Pld_mission_item_ex &item)
Construct POI action from Mavlink mission item.
Definition: poi_action.h:34
Poi_action type
Real type.
Definition: poi_action.h:85
#define VSM_EXCEPTION(__exc_class, __msg,...)
Throw VSM exception instance.
Definition: exception.h:170
Point of interest ugcs::vsm::Poi_action.