ros2 / rclcpp

rclcpp (ROS Client Library for C++)
Apache License 2.0
536 stars 417 forks source link

rclcpp_action: Provide enum class return ClientGoalHandle::get_status #2482

Open Ryanf55 opened 6 months ago

Ryanf55 commented 6 months ago

Feature request

Feature description

rclcpp_action get_status returns an int, but I want the enum values. Enums provide better type safety. Casting from an int to an enum has the potential to invoke undefined behavior. Especially because there are multiple sensical enums that could apply to this, and the docs don't say which one to use.

https://github.com/ros2/rclcpp/blob/f9c4894f96ea083fc5acfcea4f1ea83850759e63/rclcpp_action/include/rclcpp_action/client_goal_handle.hpp#L93-L95

rclcpp_action::ResultCode currently represents the state that an action can finish in, but there is no enum that represents all the states of an action. It is my understanding that get_status can return more ints than are in ResultCode.

I would like to add a new enum class that can represent the values of the ints returned in get_status. It could live here: https://github.com/ros2/rclcpp/blob/f9c4894f96ea083fc5acfcea4f1ea83850759e63/rclcpp_action/include/rclcpp_action/types.hpp#L34

Then, add a new function similar to ClientGoalHandle::get_status() that returns this enum. I want this in humble, so breaking ABI is not an option.

Implementation considerations

Need to come up with a name for get_status that returns the enum class because you can't overload with a different return type.