@@ -19,6 +19,8 @@ WaypointMode string_to_waypoint_mode(const std::string& str) {
1919 return WaypointMode::POSITION_AND_YAW ;
2020 if (str == " XY_AND_YAW" || str == " xy_and_yaw" )
2121 return WaypointMode::XY_AND_YAW ;
22+ if (str == " XY_FORWARD_DIR" || str == " xy_forward_dir" )
23+ return WaypointMode::XY_FORWARD_DIR ;
2224 throw std::runtime_error (" Unknown WaypointMode string: '" + str + " '" );
2325}
2426
@@ -38,6 +40,8 @@ WaypointMode int_to_waypoint_mode(int value) {
3840 return WaypointMode::POSITION_AND_YAW ;
3941 case static_cast <int >(WaypointMode::XY_AND_YAW ):
4042 return WaypointMode::XY_AND_YAW ;
43+ case static_cast <int >(WaypointMode::XY_FORWARD_DIR ):
44+ return WaypointMode::XY_FORWARD_DIR ;
4145 default :
4246 throw std::runtime_error (" Unknown WaypointMode numeric value: " +
4347 std::to_string (value));
@@ -63,7 +67,8 @@ Pose load_pose_for_mode(const YAML::Node& node, WaypointMode mode) { //
6367 mode == WaypointMode::ONLY_POSITION ||
6468 mode == WaypointMode::FORWARD_HEADING ||
6569 mode == WaypointMode::POSITION_AND_YAW ||
66- mode == WaypointMode::XY_AND_YAW );
70+ mode == WaypointMode::XY_AND_YAW ||
71+ mode == WaypointMode::XY_FORWARD_DIR );
6772 const bool needs_orientation = (mode == WaypointMode::FULL_POSE ||
6873 mode == WaypointMode::ONLY_ORIENTATION ||
6974 mode == WaypointMode::POSITION_AND_YAW ||
@@ -152,6 +157,16 @@ Pose compute_waypoint_goal(const Pose& incoming_waypoint,
152157 Eigen::AngleAxisd (yaw, Eigen::Vector3d::UnitZ ())));
153158 break ;
154159 }
160+
161+ case WaypointMode::XY_FORWARD_DIR : {
162+ waypoint_out.z = current_state.z ;
163+ const double dx = incoming_waypoint.x - current_state.x ;
164+ const double dy = incoming_waypoint.y - current_state.y ;
165+ const double forward_heading = std::atan2 (dy, dx);
166+ waypoint_out.set_ori (Eigen::Quaterniond (
167+ Eigen::AngleAxisd (forward_heading, Eigen::Vector3d::UnitZ ())));
168+ break ;
169+ }
155170 }
156171
157172 return waypoint_out;
@@ -178,6 +193,8 @@ bool has_converged(const Pose& state,
178193 return std::sqrt (ep.squaredNorm () + ea (2 ) * ea (2 ));
179194 case WaypointMode::XY_AND_YAW :
180195 return std::sqrt (ep.head <2 >().squaredNorm () + ea (2 ) * ea (2 ));
196+ case WaypointMode::XY_FORWARD_DIR :
197+ return ep.head <2 >().norm ();
181198 case WaypointMode::FULL_POSE :
182199 default :
183200 return std::sqrt (ep.squaredNorm () + ea.squaredNorm ());
0 commit comments