-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for action topic and services (ROS2) #214
Conversation
Adds support for parsing .action files to add message definitions for the various action subtypes (feedback message and service request / response message for SendGoal and GetResult)
namespace foxglove { | ||
|
||
// Match datatype names (foo_msgs/Bar or foo_msgs/msg/Bar or foo_msgs/srv/Bar) | ||
static const std::regex PACKAGE_TYPENAME_REGEX{ | ||
R"(^([a-zA-Z0-9_]+)/(?:msg/|srv/|action/)?([a-zA-Z0-9_]+)$)"}; | ||
R"(^([a-zA-Z0-9_]+)/((?:msg|srv|action)?)/?([a-zA-Z0-9_]+)$)"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the /
after the subtype name should not be optional
// These type definitions may include additional fields such as the goal_id. | ||
// See also https://design.ros2.org/articles/actions.html | ||
const std::map<std::string, std::string> action_type_definitions = { | ||
{"_FeedbackMessage", "unique_identifier_msgs/UUID goal_id\n" + feedbackDef}, | ||
{"_GetResult_Request", "unique_identifier_msgs/UUID goal_id\n"}, | ||
{"_GetResult_Response", "int8 status\n" + resultDef}, | ||
{"_SendGoal_Request", "unique_identifier_msgs/UUID goal_id\n" + goalDef}, | ||
{"_SendGoal_Response", "bool accepted\nbuiltin_interfaces/msg/Time stamp"}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linked design doc discusses these fields at a high level, but where is it documented that these are actually added to the definitions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have not found proper documentation for that. Best documentation I could find is the source code that generates the action types:
|
||
// Create a MessageSpec instance for every action subtype and add it to the cache. | ||
for (const auto& [action_suffix, definition] : action_type_definitions) { | ||
DefinitionIdentifier definitionIdentifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see mixed snake & camel case in this file, can we standardize on one?
|
||
// The action type name includes the subtype which we have to remove to get the action name. | ||
// Type name: Fibonacci_FeedbackMessage -> Action name: Fibonacci | ||
const std::string action_name = type_name.substr(0UL, type_name.find('_')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to handle type names that also contain underscores? do we need to verify that the suffix we stripped off is actually one of the suffixes we support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should. Will do that
constexpr char SEP[] = "---"; | ||
|
||
const auto definitions = split_string(action_definition, SEP); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if one of the segments has a string constant with ---
in it? e.g. string FOO=---
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems alright. I do think we should put this behind an explicit cli flag because it's a niche/advanced/experimental use case for which we don't provide a great UX in studio.
I have submitted #216 for that purpose. Separate PR, since certain hidden action topics (e.g. |
Public-Facing Changes
Description
Adds support for parsing .action files to retrieve message definitions for the following action subtypes:
_FeedbackMessage
) *_SendGoal_Request
) *_SendGoal_Response
)_GetResult_Request
)_GetResult_Response
) *Unfortunately, the action definition in the .action file does not include other fields such as the goal_id which are sent as part of the feedback message or SendGoal_Request and GetResult_Response. These types are therefore added to the message definition such that the entire schema is generated correctly.
Parsing IDL action definitions is currently not supported.
Example usage in Studio:
![image](https://user-images.githubusercontent.com/9250155/231853814-06533812-4c1f-449c-9d9a-68885ad54ebb.png)