utils.h
Go to the documentation of this file.
1 
10 /*
11  * Copyright 2014,2015,2016 Vladimir Ermakov.
12  *
13  * This file is part of the mavros package and subject to the license terms
14  * in the top-level LICENSE file of the mavros repository.
15  * https://github.com/mavlink/mavros/tree/master/LICENSE.md
16  */
17 
18 #pragma once
19 
20 #include <Eigen/Geometry>
21 #include <mavconn/thread_utils.h>
23 #include <mavconn/mavlink_dialect.h>
24 
25 #include <ros/console.h>
26 
27 // OS X compat: missing error codes
28 #ifdef __APPLE__
29 #define EBADE 50 /* Invalid exchange */
30 #define EBADFD 81 /* File descriptor in bad state */
31 #define EBADRQC 54 /* Invalid request code */
32 #define EBADSLT 55 /* Invalid slot */
33 #endif
34 
35 namespace mavros {
36 namespace utils {
38 
44 enum class timesync_mode {
45  NONE = 0,
46  MAVLINK,
47  ONBOARD,
49 };
50 
54 template<typename _T>
55 constexpr typename std::underlying_type<_T>::type enum_value(_T e)
56 {
57  return static_cast<typename std::underlying_type<_T>::type>(e);
58 }
59 
63 std::string to_string(timesync_mode e);
64 
68 std::string to_string(mavlink::common::MAV_SENSOR_ORIENTATION e);
69 
70 std::string to_string(mavlink::minimal::MAV_AUTOPILOT e);
71 std::string to_string(mavlink::minimal::MAV_TYPE e);
72 std::string to_string(mavlink::minimal::MAV_STATE e);
73 std::string to_string(mavlink::minimal::MAV_COMPONENT e);
74 std::string to_string(mavlink::common::MAV_ESTIMATOR_TYPE e);
75 std::string to_string(mavlink::common::ADSB_ALTITUDE_TYPE e);
76 std::string to_string(mavlink::common::ADSB_EMITTER_TYPE e);
77 std::string to_string(mavlink::common::MAV_MISSION_RESULT e);
78 std::string to_string(mavlink::common::MAV_FRAME e);
79 std::string to_string(mavlink::common::MAV_DISTANCE_SENSOR e);
80 std::string to_string(mavlink::common::LANDING_TARGET_TYPE e);
84 template<typename _T>
85 std::string to_string_enum(int e)
86 {
87  return to_string(static_cast<_T>(e));
88 }
89 
94 Eigen::Quaterniond sensor_orientation_matching(mavlink::common::MAV_SENSOR_ORIENTATION orientation);
95 
99 int sensor_orientation_from_str(const std::string &sensor_orientation);
100 
104 timesync_mode timesync_mode_from_str(const std::string &mode);
105 
109 mavlink::common::MAV_FRAME mav_frame_from_str(const std::string &mav_frame);
110 
114 mavlink::minimal::MAV_TYPE mav_type_from_str(const std::string &mav_type);
115 
119 mavlink::common::LANDING_TARGET_TYPE landing_target_type_from_str(const std::string &landing_target_type);
120 
121 } // namespace utils
122 } // namespace mavros
mavlink::common::MAV_FRAME mav_frame_from_str(const std::string &mav_frame)
Retreive MAV_FRAME from name.
std::string format(const std::string &fmt, Args...args)
Eigen::Quaterniond sensor_orientation_matching(mavlink::common::MAV_SENSOR_ORIENTATION orientation)
Function to match the received orientation received by MAVLink msg and the rotation of the sensor rel...
mavlink::minimal::MAV_TYPE mav_type_from_str(const std::string &mav_type)
Retreive MAV_TYPE from name.
std::string to_string_enum(int e)
Definition: utils.h:85
std::string to_string(timesync_mode e)
timesync_mode timesync_mode_from_str(const std::string &mode)
Retrieve timesync mode from name.
int sensor_orientation_from_str(const std::string &sensor_orientation)
Retrieve sensor orientation number from alias name.
mavlink::common::LANDING_TARGET_TYPE landing_target_type_from_str(const std::string &landing_target_type)
Retrieve landing target type from alias name.
constexpr std::underlying_type< _T >::type enum_value(_T e)
Definition: utils.h:55


mavros
Author(s): Vladimir Ermakov
autogenerated on Tue Jun 1 2021 02:36:26