15 #include <unordered_map> 26 typedef std::unordered_map<uint32_t, const std::string>
cmode_map;
47 { 16,
"INITIALISING" },
79 { 20,
"GUIDED_NOGPS" }
94 { 16,
"INITIALISING" }
154 auto it = cmap.find(custom_mode);
155 if (it != cmap.end())
178 return type == UAS::MAV_TYPE::QUADROTOR ||
179 type == UAS::MAV_TYPE::HEXAROTOR ||
180 type == UAS::MAV_TYPE::OCTOROTOR ||
181 type == UAS::MAV_TYPE::TRICOPTER ||
182 type == UAS::MAV_TYPE::COAXIAL;
187 if (!(base_mode &
enum_value(MAV_MODE_FLAG::CUSTOM_MODE_ENABLED)))
192 if (MAV_AUTOPILOT::ARDUPILOTMEGA == ap) {
195 else if (
type == MAV_TYPE::FIXED_WING)
197 else if (
type == MAV_TYPE::GROUND_ROVER)
199 else if (
type == MAV_TYPE::SURFACE_BOAT)
201 else if (
type == MAV_TYPE::SUBMARINE)
208 else if (MAV_AUTOPILOT::PX4 == ap)
222 for (
auto &mode : cmap) {
223 if (mode.second == cmode_str) {
232 cmode = std::stoi(cmode_str, 0, 0);
235 catch (std::invalid_argument &ex) {
240 std::ostringstream os;
241 for (
auto &mode : cmap)
242 os <<
" " << mode.second;
253 std::transform(cmode_str.begin(), cmode_str.end(), cmode_str.begin(), std::ref(toupper));
257 if (MAV_AUTOPILOT::ARDUPILOTMEGA == ap) {
260 else if (type == MAV_TYPE::FIXED_WING)
262 else if (type == MAV_TYPE::GROUND_ROVER)
264 else if (type == MAV_TYPE::SUBMARINE)
267 else if (MAV_AUTOPILOT::PX4 == ap)
static std::string str_base_mode(int base_mode)
#define ROS_WARN_COND_NAMED(cond, name,...)
bool cmode_from_str(std::string cmode_str, uint32_t &custom_mode)
Lookup custom mode for given string.
std::string format(const std::string &fmt, Args...args)
#define ROS_WARN_THROTTLE_NAMED(period, name,...)
#define ROS_ERROR_STREAM_NAMED(name, args)
static const cmode_map apmrover2_cmode_map
MAV_AUTOPILOT get_autopilot()
Returns autopilot type.
static std::string str_mode_px4(uint32_t custom_mode_int)
static bool is_apm_copter(UAS::MAV_TYPE type)
mavlink::common::MAV_TYPE MAV_TYPE
#define ROS_INFO_STREAM_NAMED(name, args)
static std::string str_custom_mode(uint32_t custom_mode)
static bool cmode_find_cmap(const cmode_map &cmap, std::string &cmode_str, uint32_t &cmode)
static const cmode_map ardusub_cmode_map
constexpr uint32_t define_mode_auto(enum custom_mode::SUB_MODE_AUTO sm)
helper function to define auto mode as uint32_t constant
std::atomic< uint8_t > type
std::string str_mode_v10(uint8_t base_mode, uint32_t custom_mode)
Represent FCU mode as string.
static const cmode_map arduplane_cmode_map
static std::string str_mode_cmap(const cmode_map &cmap, uint32_t custom_mode)
MAV_TYPE get_type()
Returns vehicle type.
static const cmode_map arducopter_cmode_map
PX4 custom mode constantsPX4 custom flight modes.
#define ROS_ERROR_NAMED(name,...)
constexpr uint32_t define_mode(enum custom_mode::MAIN_MODE mm, uint8_t sm=0)
helper function to define any mode as uint32_t constant
std::unordered_map< uint32_t, const std::string > cmode_map
constexpr std::underlying_type< _T >::type enum_value(_T e)
static const cmode_map px4_cmode_map
PX4 custom mode -> string.