@@ -26,6 +26,8 @@ std::string waypoint_mode_to_string(WaypointMode mode) {
2626 return " LEVEL_ORIENTATION" ;
2727 case WaypointMode::ONLY_Z :
2828 return " ONLY_Z" ;
29+ case WaypointMode::POS_Z_LEVEL_ORIENTATION :
30+ return " POS_Z_LEVEL_ORIENTATION" ;
2931 default :
3032 return " UNKNOWN" ;
3133 }
@@ -50,6 +52,8 @@ WaypointMode string_to_waypoint_mode(const std::string& str) {
5052 return WaypointMode::LEVEL_ORIENTATION ;
5153 if (str == " ONLY_Z" || str == " only_z" )
5254 return WaypointMode::ONLY_Z ;
55+ if (str == " POS_Z_LEVEL_ORIENTATION" || str == " pos_z_level_orientation" )
56+ return WaypointMode::POS_Z_LEVEL_ORIENTATION ;
5357 throw std::runtime_error (" Unknown WaypointMode string: '" + str + " '" );
5458}
5559
@@ -75,6 +79,8 @@ WaypointMode int_to_waypoint_mode(int value) {
7579 return WaypointMode::LEVEL_ORIENTATION ;
7680 case static_cast <int >(WaypointMode::ONLY_Z ):
7781 return WaypointMode::ONLY_Z ;
82+ case static_cast <int >(WaypointMode::POS_Z_LEVEL_ORIENTATION ):
83+ return WaypointMode::POS_Z_LEVEL_ORIENTATION ;
7884 default :
7985 throw std::runtime_error (" Unknown WaypointMode numeric value: " +
8086 std::to_string (value));
@@ -215,6 +221,16 @@ Pose compute_waypoint_goal(const Pose& incoming_waypoint,
215221 waypoint_out.y = current_state.y ;
216222 waypoint_out.set_ori (current_state.ori_quaternion ());
217223 break ;
224+
225+ case WaypointMode::POS_Z_LEVEL_ORIENTATION : {
226+ waypoint_out.x = current_state.x ;
227+ waypoint_out.y = current_state.y ;
228+ const double current_yaw = vortex::utils::math::quat_to_euler (
229+ current_state.ori_quaternion ())(2 );
230+ waypoint_out.set_ori (Eigen::Quaterniond (
231+ Eigen::AngleAxisd (current_yaw, Eigen::Vector3d::UnitZ ())));
232+ break ;
233+ }
218234 }
219235
220236 return waypoint_out;
@@ -247,6 +263,8 @@ bool has_converged(const Pose& state,
247263 return ea.head <2 >().norm ();
248264 case WaypointMode::ONLY_Z :
249265 return std::abs (ep (2 ));
266+ case WaypointMode::POS_Z_LEVEL_ORIENTATION :
267+ return std::sqrt (ep (2 ) * ep (2 ) + ea.head <2 >().squaredNorm ());
250268 case WaypointMode::FULL_POSE :
251269 default :
252270 return std::sqrt (ep.squaredNorm () + ea.squaredNorm ());
0 commit comments