-
Notifications
You must be signed in to change notification settings - Fork 430
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
Runtime Interface Reflection: rclcpp #2077
Conversation
42802ae
to
af692ec
Compare
41a2df1
to
0ee1cee
Compare
0ee1cee
to
d2b1743
Compare
a298ef5
to
dd1ab8c
Compare
86522b4
to
28ce1bf
Compare
f7f548f
to
f71bea7
Compare
8933e83
to
67a958e
Compare
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
2217287
to
b22731b
Compare
Signed-off-by: methylDragon <methylDragon@gmail.com>
ac43cb6
to
0a21288
Compare
Signed-off-by: methylDragon <methylDragon@gmail.com>
0a21288
to
29577da
Compare
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
b961350
to
32859cd
Compare
|
if (ret != RCL_RET_OK) { | ||
throw std::runtime_error("error initializing rosidl message type support"); | ||
} | ||
if (!ts) { |
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.
Can all these bad cases be true if ret == RCL_RET_OK
?
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.
🤔 probably not.
I might still leave in the typesupport identifier check though
|
|
||
RCLCPP_PUBLIC | ||
void | ||
manage_description_(rosidl_runtime_c__type_description__TypeDescription * description); |
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.
manage
is an overloaded term - this is really a make_shared
function to put ownership of the object into a shared pointer, right?
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.
Yeah that's true.. I wanted it to be like a: "We are taking ownership/managing the lifetime of the pointer now)
It's a private method though, so I don't have any issues with changing the name
ROS_MESSAGE = 1, // take message as ROS message and handle as ROS message | ||
SERIALIZED_MESSAGE = 2, // take message as serialized and handle as serialized | ||
DYNAMIC_MESSAGE_DIRECT = 3, // take message as DynamicMessage and handle as DynamicMessage | ||
DYNAMIC_MESSAGE_FROM_SERIALIZED = 4 // take message as serialized and handle as DynamicMessage |
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 distinction here isn't clear to me between dynamic message direct and serialized.
What does this wording pattern "take as X and handle as Y" mean? Does "handle" refer to the argument type for the callback?
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.
Yep, "handle" is for the callback.
The way it works with ROS is that a message has to be taken, then passed to a handle function that passes it to a callback. So take -> handle.
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 about a dynamic subscription that passes serialized data to the handler function? GenericDynamicSubscription
, perhaps. It's what we would want in rosbag2 recording. Or is that the case for DYNAMIC_MESSAGE_FROM_SERIALIZED
, I couldn't quite tell.
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.
In that case you would want to use a serialized subscription (I.e. one that takes and handles serialized data), then use the DynamicMessage class to deserialize the serialized message into the DynamicMessage inside the callback
You probably would need to subclass that subscription so you can instantiate a DynamicMessage and have it accessible inside the callback
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.
(Basically you just need a way to implement what the executor is doing here, in the callback)
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.
// Take serialized and then convert to dynamic message
case rclcpp::SubscriptionType::DYNAMIC_MESSAGE_FROM_SERIALIZED:
{
std::shared_ptr<SerializedMessage> serialized_msg =
subscription->create_serialized_message();
// NOTE(methylDragon): Is this clone necessary? If I'm following the pattern, it seems so.
DynamicMessage::SharedPtr dynamic_message = subscription->create_dynamic_message();
take_and_do_error_handling(
"taking a serialized message from topic",
subscription->get_topic_name(),
[&]() {return subscription->take_serialized(*serialized_msg.get(), message_info);},
[&]()
{
// === <<< THIS IS THE MOST IMPORTANT LINE!!! >>> ===
bool ret = dynamic_message->deserialize(&serialized_msg->get_rcl_serialized_message());
// ^^^ <<< THIS IS THE MOST IMPORTANT LINE!!! >>> ^^^
if (!ret) {
throw_from_rcl_error(ret, "Couldn't convert serialized message to dynamic data!");
}
subscription->handle_dynamic_message(dynamic_message, message_info);
}
);
subscription->return_serialized_message(serialized_msg);
subscription->return_dynamic_message(dynamic_message);
break;
}
}
Closing this in favor of #2176 |
|
This PR is part of the runtime interface reflection subscription feature of REP-2011: ros2/ros2#1374
Description
This PR includes support for runtime type subscriptions, including: