rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

rclcpp_action: Provide enum class return ClientGoalHandle::get_status

Open Ryanf55 opened this issue 1 year ago • 0 comments

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.

Ryanf55 avatar Apr 03 '24 23:04 Ryanf55