-
Notifications
You must be signed in to change notification settings - Fork 33
refactor to support init options and context #308
Conversation
Ack. I will also join the chorus "do we really need Please give me an example when a context is not enough. |
|
OK, I like it. |
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.
LGTM, just some questions about pushing common implementation to shared functions.
80baf58
to
dda1b3a
Compare
rmw_connext_cpp/src/rmw_init.cpp
Outdated
context->implementation_identifier, | ||
rti_connext_identifier, | ||
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); | ||
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context->impl, RMW_RET_INVALID_ARGUMENT); |
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.
It looks like rmw_init()
sets context->impl
to nullptr
, why is this expecting it to be non-null?
context->implementation_identifier, | ||
rti_connext_dynamic_identifier, | ||
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); | ||
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context->impl, RMW_RET_INVALID_ARGUMENT); |
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.
same comment here, context->impl
is set to nullptr
in rmw_init()
Signed-off-by: William Woodall <[email protected]>
Signed-off-by: William Woodall <[email protected]>
dda1b3a
to
fa27d8b
Compare
Signed-off-by: William Woodall <[email protected]>
@wjwwood, do you have an example of a user-side customization? |
@serge-nikulin no, but I think it would look something like this: #include <rclcpp/rclcpp.hpp>
// note this next include breaks portability of ROS code
#include <rmw_connext_cpp/add_options_to_context.hpp>
auto context = std::make_shared<rclcpp::Context>()
context->init(...);
rmw_connext_cpp::add_option_to_context(context, "do_a_thing", true);
auto node = std::make_shared<rclcpp::Node>("my_node", "", context); And the implementation of the template<typename ContextT>
void
rmw_connext_cpp::add_option_to_context(
std::shared_ptr<ContextT> context,
const std::string & option_name,
bool option_value)
{
// see: http://docs.ros2.org/crystal/api/rclcpp/classrclcpp_1_1Context.html#a28596bd16aad20e057160f8a66d4697f
auto rcl_context_shared_ptr = context->get_rcl_context();
// some how assert that rcl_context_shared_ptr is not nullptr
rcl_context_t * rcl_context = rcl_context_shared_ptr.get();
// this function doesn't exist yet :'(
rmw_context_t * rmw_context = rcl_context_get_rmw_context(rcl_context);
// some how assert that rmw_context is not NULL
// now you can cast the `void *` impl pointer to the connext cpp specific version
// and then mutate it how ever you like
rmw_context_impl_t * rmw_context_impl = (rmw_context_impl_t *)rmw_context->impl;
// some how insert the option into the connext impl for later use
} And so currently you cannot 🙃. I'll add the |
Do you have an issue to address it? |
* refactor to support init options and context Signed-off-by: William Woodall <[email protected]> * style Signed-off-by: William Woodall <[email protected]> * add missing rmw_shutdown * fix incorrect check for null Signed-off-by: William Woodall <[email protected]> Signed-off-by: Devin Bonnie <[email protected]>
Connects to ros2/rmw#154
@serge-nikulin FYI this is an example of what the disruption to an existing rmw implementation will look like for the init options and context changes.