File tree Expand file tree Collapse file tree
vortex_utils_ros/include/vortex/utils/ros
vortex_utils/include/vortex/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -400,6 +400,29 @@ struct LineSegment2D {
400400 }
401401};
402402
403+ /* *
404+ * @brief Enum class for operation modes.
405+ */
406+ enum class Mode : uint8_t { manual, autonomous, reference };
407+
408+ /* *
409+ * @brief Convert Mode enum to string for logging or display purposes.
410+ * @param mode Mode enum value
411+ * @return std::string representation of the mode
412+ */
413+ inline std::string mode_to_string (Mode mode) {
414+ switch (mode) {
415+ case Mode::manual:
416+ return " manual mode" ;
417+ case Mode::autonomous:
418+ return " autonomous mode" ;
419+ case Mode::reference:
420+ return " reference mode" ;
421+ default :
422+ throw std::runtime_error (" Invalid operation mode." );
423+ }
424+ }
425+
403426} // namespace vortex::utils::types
404427
405428#endif // VORTEX_UTILS_TYPES_HPP
Original file line number Diff line number Diff line change 1414#include < geometry_msgs/msg/pose_with_covariance.hpp>
1515#include < geometry_msgs/msg/pose_with_covariance_stamped.hpp>
1616#include < vortex_msgs/msg/landmark_array.hpp>
17+ #include < vortex_msgs/msg/operation_mode.hpp>
1718
1819#include < vortex/utils/concepts.hpp>
1920#include < vortex/utils/math.hpp>
@@ -176,6 +177,25 @@ inline std::vector<vortex::utils::types::Pose> ros_to_pose_vec(
176177 return poses;
177178}
178179
180+ /* *
181+ * @brief Converts a ROS vortex_msgs::msg::OperationMode to an internal Mode
182+ * enum.
183+ * @param mode_msg vortex_msgs::msg::OperationMode
184+ * @return vortex::utils::types::Mode Internal mode representation
185+ */
186+ inline vortex::utils::types::Mode convert_from_ros (
187+ const vortex_msgs::msg::OperationMode& mode_msg) {
188+ switch (mode_msg.operation_mode ) {
189+ case vortex_msgs::msg::OperationMode::MANUAL :
190+ return vortex::utils::types::Mode::manual;
191+ case vortex_msgs::msg::OperationMode::AUTONOMOUS :
192+ return vortex::utils::types::Mode::autonomous;
193+ case vortex_msgs::msg::OperationMode::REFERENCE :
194+ return vortex::utils::types::Mode::reference;
195+ }
196+ throw std::runtime_error (" Invalid operation mode." );
197+ }
198+
179199} // namespace vortex::utils::ros_conversions
180200
181201#endif // VORTEX_UTILS__ROS_CONVERSIONS_HPP_
You can’t perform that action at this time.
0 commit comments