VSM C++ SDK
Vehicle Specific Modules SDK
set_home_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 _SET_HOME_ACTION_H_
9 #define _SET_HOME_ACTION_H_
10 
11 #include <ugcs/vsm/action.h>
12 #include <ugcs/vsm/coordinates.h>
13 #include <ugcs/vsm/mavlink.h>
14 
15 namespace ugcs {
16 namespace vsm {
17 
19 class Set_home_action: public Action {
21 
22 public:
23 
26  double elevation) :
27  Action(Type::SET_HOME),
28  use_current_position(use_current_position),
29  home_position(home_position),
31 
37  Set_home_action(const mavlink::ugcs::Pld_mission_item_ex& item) :
38  Action(Type::SET_HOME),
39  use_current_position(item->param1 == 1),
40  home_position(Geodetic_tuple(item->x * M_PI / 180.0,
41  item->y * M_PI / 180.0,
42  item->z)),
43  elevation(item->elevation)
44  {
45  ASSERT(item->command == mavlink::MAV_CMD::MAV_CMD_DO_SET_HOME);
46  }
47 
52  Action(Type::SET_HOME),
53  use_current_position(false),
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  home_position = Geodetic_tuple(lat, lon, alt);
70  p.at("ground_elevation")->Get_value(elevation);
71  }
72 
79 
84 
88  double elevation;
89 };
90 
92 template<>
96 };
97 
98 } /* namespace vsm */
99 } /* namespace ugcs */
100 
101 #endif /* _SET_HOME_ACTION_H_ */
UGCS root namespace.
Definition: android-linux/ugcs/vsm/platform_sockets.h:27
Definition: property.h:191
Coordinates tuple for geodetic CS.
Definition: coordinates.h:41
Type
Types of vehicle actions as part of task (mission).
Definition: action.h:30
Set home position action.
Definition: set_home_action.h:19
Set_home_action(const Property_list &p)
Construct action from protobuf command.
Definition: set_home_action.h:51
Generic action.
Definition: action.h:22
bool use_current_position
If set, current vehicle position should be set as the home/base position on the action occurrence...
Definition: set_home_action.h:78
Wgs84_position home_position
Global position, that should be used as the home/base position.
Definition: set_home_action.h:83
#define ASSERT(x)
No action in release.
Definition: debug.h:68
double elevation
Elevation in meters (i.e.
Definition: set_home_action.h:88
Generic action.
Map Action type enum value to specific Action type class.
Definition: action.h:117
Set_home_action(const mavlink::ugcs::Pld_mission_item_ex &item)
Construct set home action from Mavlink extended mission item.
Definition: set_home_action.h:37
#define M_PI
PI constant.
Definition: coordinates.h:21
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.
Set_home_action type
Real type.
Definition: set_home_action.h:95