@@ -76,24 +76,24 @@ Pose apply_pose_offset(const Pose& base, const Pose& offset) {
7676 return Pose::from_eigen (p_target, q_target);
7777}
7878
79- Pose load_waypoint_from_yaml (const std::string& file_path,
80- const std::string& identifier) {
79+ Pose load_pose_from_yaml (const std::string& file_path,
80+ const std::string& identifier) {
8181 YAML ::Node root = YAML::LoadFile (file_path);
8282
8383 if (!root[identifier]) {
84- throw std::runtime_error (" Waypoint '" + identifier + " ' not found in " +
84+ throw std::runtime_error (" Pose '" + identifier + " ' not found in " +
8585 file_path);
8686 }
8787
88- const auto & wp = root[identifier];
88+ const auto & pose = root[identifier];
8989
90- const double x = wp [" position" ][" x" ].as <double >();
91- const double y = wp [" position" ][" y" ].as <double >();
92- const double z = wp [" position" ][" z" ].as <double >();
90+ const double x = pose [" position" ][" x" ].as <double >();
91+ const double y = pose [" position" ][" y" ].as <double >();
92+ const double z = pose [" position" ][" z" ].as <double >();
9393
94- const double roll = wp [" orientation" ][" roll" ].as <double >();
95- const double pitch = wp [" orientation" ][" pitch" ].as <double >();
96- const double yaw = wp [" orientation" ][" yaw" ].as <double >();
94+ const double roll = pose [" orientation" ][" roll" ].as <double >();
95+ const double pitch = pose [" orientation" ][" pitch" ].as <double >();
96+ const double yaw = pose [" orientation" ][" yaw" ].as <double >();
9797
9898 const Eigen::Quaterniond q =
9999 vortex::utils::math::euler_to_quat (roll, pitch, yaw);
@@ -107,4 +107,63 @@ Pose load_waypoint_from_yaml(const std::string& file_path,
107107 .qz = q.z ()};
108108}
109109
110+ WaypointGoal load_waypoint_goal_from_yaml (const std::string& file_path,
111+ const std::string& identifier) {
112+ YAML ::Node root = YAML::LoadFile (file_path);
113+
114+ if (!root[identifier]) {
115+ throw std::runtime_error (" Waypoint '" + identifier + " ' not found in " +
116+ file_path);
117+ }
118+
119+ const auto & wp = root[identifier];
120+
121+ Pose pose = load_pose_from_yaml (file_path, identifier);
122+
123+ const auto mode = static_cast <WaypointMode>(wp[" mode" ].as <uint8_t >());
124+
125+ double convergence_threshold = 0.1 ;
126+ if (wp[" convergence_threshold" ]) {
127+ convergence_threshold = wp[" convergence_threshold" ].as <double >();
128+ }
129+
130+ return WaypointGoal{.pose = pose,
131+ .mode = mode,
132+ .convergence_threshold = convergence_threshold};
133+ }
134+
135+ LandmarkConvergenceGoal load_landmark_goal_from_yaml (
136+ const std::string& file_path,
137+ const std::string& identifier) {
138+ YAML ::Node root = YAML::LoadFile (file_path);
139+
140+ if (!root[identifier]) {
141+ throw std::runtime_error (" Landmark goal '" + identifier +
142+ " ' not found in " + file_path);
143+ }
144+
145+ const auto & entry = root[identifier];
146+
147+ Pose convergence_offset = load_pose_from_yaml (file_path, identifier);
148+
149+ const auto mode = static_cast <WaypointMode>(entry[" mode" ].as <uint8_t >());
150+
151+ double convergence_threshold = 0.1 ;
152+ if (entry[" convergence_threshold" ]) {
153+ convergence_threshold = entry[" convergence_threshold" ].as <double >();
154+ }
155+
156+ double dead_reckoning_threshold = 0.5 ;
157+ if (entry[" dead_reckoning_threshold" ]) {
158+ dead_reckoning_threshold =
159+ entry[" dead_reckoning_threshold" ].as <double >();
160+ }
161+
162+ return LandmarkConvergenceGoal{
163+ .convergence_offset = convergence_offset,
164+ .mode = mode,
165+ .convergence_threshold = convergence_threshold,
166+ .dead_reckoning_threshold = dead_reckoning_threshold};
167+ }
168+
110169} // namespace vortex::utils::waypoints
0 commit comments