Skip to content
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

Fix service definition parsing on ROS rolling #293

Merged

Conversation

achim-k
Copy link
Collaborator

@achim-k achim-k commented Apr 23, 2024

Changelog

Fix service definition parsing on ROS rolling

Description

Prior to this change, we used the auto-generated _Request.msg and _Response.msg message definitions for parsing a service's request and response definition. However, these message definitions have been removed in ros2/rosidl#753 causing foxglove bridge to raise warnings that the service definition could not be found. This PR changes the service definition parsing to lookup the service definition using the .srv file and splitting the content using the === seperator to obtain the request and response definition.

Request and Response message files are not available anymore as of ros2/rosidl#753. This patch parses the service's .srv file instead.
@achim-k achim-k requested a review from jtbandes April 23, 2024 16:28
Comment on lines 141 to 144
constexpr char SEP[] = "---\n";

const auto definitions = split_string(service_definition, SEP);
if (definitions.size() != 2) {
Copy link
Member

@jtbandes jtbandes Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it legal for the response to be totally empty (no newline) e.g. something like "int a\n---" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe that's legal, also for the request. I will test if that's an issue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if so, maybe using "---\n" as the separator won't work

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"---\n" is correct:

A service file contains two message definitions which are separated by a line which only contains three dashes:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, colcon doesn't raise an error if the service definition ends with --- without final LF. I will have to cover that case as well 😭

definition_id, MessageSpec(definition_id.format, definition, package));
}
if (subfolder == "action") {
const auto [goalDef, resultDef, feedbackDef] = split_action_msg_definition(contents);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting – didn't realize we were already doing a manual split for .action but not .srv. Why were they different?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For services it was much easier to use the _Request and _Response msg definitions which basically didn't need any additional code. For action types, these auto-generated msg definitions didn't exist.

@achim-k achim-k force-pushed the achim/fg-7402-fix-service-definition-parsing-on-rolling branch from d1c4734 to 51ef884 Compare April 24, 2024 00:25
@achim-k achim-k requested a review from jtbandes April 25, 2024 19:41
ros2_foxglove_bridge/include/foxglove_bridge/utils.hpp Outdated Show resolved Hide resolved
ros2_foxglove_bridge/src/message_definition_cache.cpp Outdated Show resolved Hide resolved
ros2_foxglove_bridge/src/message_definition_cache.cpp Outdated Show resolved Hide resolved
Comment on lines +195 to +196
// The service type name includes the subtype which we have to remove to get the service name.
// Type name: SetBool_Request -> Service name: SetBool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these don't exist anymore? Does the code have to handle both with & without the suffix because they exist in <=iron but not in >iron?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still use _Request and _Response as type name suffixes when advertising the services as we can't (or rather shouldn't) advertise request and response types with the same type name.

ros2_foxglove_bridge/src/message_definition_cache.cpp Outdated Show resolved Hide resolved
ros2_foxglove_bridge/tests/smoke_test.cpp Outdated Show resolved Hide resolved
ros2_foxglove_bridge/tests/utils_test.cpp Outdated Show resolved Hide resolved
@jtbandes jtbandes merged commit e773b92 into main May 3, 2024
8 of 10 checks passed
@jtbandes jtbandes deleted the achim/fg-7402-fix-service-definition-parsing-on-rolling branch May 3, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants