29 #ifndef HECTOR_UAV_MSGS_RC_FUNCTIONS_H 30 #define HECTOR_UAV_MSGS_RC_FUNCTIONS_H 32 #include <hector_uav_msgs/RC.h> 40 case RC::ROLL:
return "ROLL";
41 case RC::PITCH:
return "PITCH";
42 case RC::YAW:
return "YAW";
43 case RC::STEER:
return "STEER";
44 case RC::HEIGHT:
return "HEIGHT";
45 case RC::THRUST:
return "THRUST";
46 case RC::BRAKE:
return "BRAKE";
51 static inline bool hasAxis(
const RC& rc, RC::_axis_function_type::value_type
function)
53 return std::find(rc.axis_function.begin(), rc.axis_function.end(),
function) != rc.axis_function.end();
56 static inline bool getAxis(
const RC& rc, RC::_axis_function_type::value_type
function, RC::_axis_type::value_type& value)
58 if (!rc.valid)
return false;
59 const RC::_axis_function_type::const_iterator it = std::find(rc.axis_function.begin(), rc.axis_function.end(),
function);
60 if (it == rc.axis_function.end())
return false;
61 value = rc.axis.at(it - rc.axis_function.begin());
65 static inline void setAxis(RC& rc, RC::_axis_function_type::value_type
function, RC::_axis_type::value_type value)
67 const RC::_axis_function_type::iterator it = std::find(rc.axis_function.begin(), rc.axis_function.end(),
function);
68 if (it == rc.axis_function.end()) {
69 rc.axis_function.push_back(
function);
70 rc.axis.push_back(value);
72 rc.axis.at(it - rc.axis_function.begin()) = value;
76 static inline bool hasSwitch(
const RC& rc, RC::_swit_function_type::value_type
function)
78 return std::find(rc.swit_function.begin(), rc.swit_function.end(),
function) != rc.swit_function.end();
81 static inline bool getSwitch(
const RC& rc, RC::_swit_function_type::value_type
function, RC::_swit_type::value_type& value)
83 if (!rc.valid)
return false;
84 const RC::_swit_function_type::const_iterator it = std::find(rc.swit_function.begin(), rc.swit_function.end(),
function);
85 if (it == rc.swit_function.end())
return false;
86 value = rc.swit.at(it - rc.swit_function.begin());
90 static inline void setSwitch(RC& rc, RC::_swit_function_type::value_type
function, RC::_swit_type::value_type value)
92 const RC::_swit_function_type::iterator it = std::find(rc.swit_function.begin(), rc.swit_function.end(),
function);
93 if (it == rc.swit_function.end()) {
94 rc.swit_function.push_back(
function);
95 rc.swit.push_back(value);
97 rc.swit.at(it - rc.swit_function.begin()) = value;
103 #endif // HECTOR_UAV_MSGS_RC_FUNCTIONS_H static bool hasSwitch(const RC &rc, RC::_swit_function_type::value_type function)
static bool hasAxis(const RC &rc, RC::_axis_function_type::value_type function)
static void setAxis(RC &rc, RC::_axis_function_type::value_type function, RC::_axis_type::value_type value)
static void setSwitch(RC &rc, RC::_swit_function_type::value_type function, RC::_swit_type::value_type value)
static const char * getFunctionString(uint8_t function)
static bool getAxis(const RC &rc, RC::_axis_function_type::value_type function, RC::_axis_type::value_type &value)
static bool getSwitch(const RC &rc, RC::_swit_function_type::value_type function, RC::_swit_type::value_type &value)