@@ -24,13 +24,33 @@ WaypointMode string_to_waypoint_mode(const std::string& str) {
2424
2525namespace {
2626
27+ WaypointMode int_to_waypoint_mode (int value) {
28+ switch (value) {
29+ case static_cast <int >(WaypointMode::FULL_POSE ):
30+ return WaypointMode::FULL_POSE ;
31+ case static_cast <int >(WaypointMode::ONLY_POSITION ):
32+ return WaypointMode::ONLY_POSITION ;
33+ case static_cast <int >(WaypointMode::FORWARD_HEADING ):
34+ return WaypointMode::FORWARD_HEADING ;
35+ case static_cast <int >(WaypointMode::ONLY_ORIENTATION ):
36+ return WaypointMode::ONLY_ORIENTATION ;
37+ case static_cast <int >(WaypointMode::POSITION_AND_YAW ):
38+ return WaypointMode::POSITION_AND_YAW ;
39+ case static_cast <int >(WaypointMode::XY_AND_YAW ):
40+ return WaypointMode::XY_AND_YAW ;
41+ default :
42+ throw std::runtime_error (" Unknown WaypointMode numeric value: " +
43+ std::to_string (value));
44+ }
45+ }
46+
2747WaypointMode load_mode (const YAML ::Node& node) {
28- const auto & m = node[" mode" ];
48+ const auto m = node[" mode" ];
2949 if (!m) {
3050 throw std::runtime_error (" Missing required field 'mode'" );
3151 }
3252 try {
33- return static_cast <WaypointMode> (m.as <uint8_t >());
53+ return int_to_waypoint_mode (m.as <int >());
3454 } catch (const YAML ::BadConversion&) {
3555 return string_to_waypoint_mode (m.as <std::string>());
3656 }
0 commit comments