VSM C++ SDK
Vehicle Specific Modules SDK
task_attributes_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 _TASK_ATTRIBUTES_ACTION_H_
9 #define _TASK_ATTRIBUTES_ACTION_H_
10 
11 #include <ugcs/vsm/action.h>
12 #include <ugcs/vsm/mavlink.h>
13 #include <ugcs/vsm/property.h>
14 
15 namespace ugcs {
16 namespace vsm {
17 
22 
23 public:
24 
37  };
38 
42  Action(Type::TASK_ATTRIBUTES),
43  safe_altitude(safe_altitude), rc_loss(rc_loss),
44  gnss_loss(gnss_loss), low_battery(low_battery) {}
45 
48  Action(Type::TASK_ATTRIBUTES)
49  {
50  if (params.at("safe_altitude")->Is_value_na()) {
51  safe_altitude = NAN;
52  } else {
53  params.at("safe_altitude")->Get_value(safe_altitude);
54  }
55  int tmp;
56  if (params.at("rc_loss_action")->Get_value(tmp)) {
57  rc_loss = static_cast<Emergency_action>(tmp);
58  } else {
60  }
61  if (params.at("gps_loss_action")->Get_value(tmp)) {
62  gnss_loss = static_cast<Emergency_action>(tmp);
63  } else {
65  }
66  if (params.at("low_battery_action")->Get_value(tmp)) {
67  low_battery = static_cast<Emergency_action>(tmp);
68  } else {
70  }
71  }
72 
78  Task_attributes_action(const mavlink::ugcs::Pld_mission_item_ex& item) :
79  Action(Type::TASK_ATTRIBUTES),
80  safe_altitude(item->param1),
81  rc_loss(Mavlink_to_emergency_action(item->param2)),
82  gnss_loss(Mavlink_to_emergency_action(item->param3)),
83  low_battery(Mavlink_to_emergency_action(item->param4))
84  {
85  ASSERT(item->command == mavlink::ugcs::MAV_CMD::MAV_CMD_DO_SET_ROUTE_ATTRIBUTES);
86  }
87 
88 public:
89 
91  double safe_altitude;
92 
95 
100 
103 
104 private:
105 
109  static Emergency_action
110  Mavlink_to_emergency_action(double mav_param);
111 };
112 
113 
115 template<>
119 };
120 
121 } /* namespace vsm */
122 } /* namespace ugcs */
123 
124 #endif /* _TASK_ATTRIBUTES_ACTION_H_ */
UGCS root namespace.
Definition: android-linux/ugcs/vsm/platform_sockets.h:27
Return and land at the home position.
Definition: task_attributes_action.h:28
Definition: property.h:191
Emergency_action low_battery
Type of action to perform in case of low battery.
Definition: task_attributes_action.h:102
Type
Types of vehicle actions as part of task (mission).
Definition: action.h:30
Emergency_action rc_loss
Type of action to perform in case of remote control loss.
Definition: task_attributes_action.h:94
Generic action.
Definition: action.h:22
#define ASSERT(x)
No action in release.
Definition: debug.h:68
Emergency_action
Action to perform in case of emergency.
Definition: task_attributes_action.h:26
Task_attributes_action(double safe_altitude, Emergency_action rc_loss, Emergency_action gnss_loss, Emergency_action low_battery)
Construct task attributes action explicitly.
Definition: task_attributes_action.h:40
Generic action.
Map Action type enum value to specific Action type class.
Definition: action.h:117
Continue the task.
Definition: task_attributes_action.h:34
Task_attributes_action type
Real type.
Definition: task_attributes_action.h:118
Task_attributes_action(const mavlink::ugcs::Pld_mission_item_ex &item)
Construct task attributes action from Mavlink mission item.
Definition: task_attributes_action.h:78
Emergency_action gnss_loss
Type of action to perform in case of GNSS signal loss (i.e.
Definition: task_attributes_action.h:99
Hover at the current position.
Definition: task_attributes_action.h:32
double safe_altitude
Safe altitude in meters (MSL).
Definition: task_attributes_action.h:91
Task_attributes_action(const Property_list &params)
Construct action from new style params.
Definition: task_attributes_action.h:47
#define DEFINE_COMMON_CLASS(__class_name,...)
Use this macro to define some common attributes for a class.
Definition: utils.h:25
do not change
Definition: task_attributes_action.h:36
Task attributes action.
Definition: task_attributes_action.h:20
Land at the current position.
Definition: task_attributes_action.h:30
Task attributes action ugcs::vsm::Task_attributes_action.