Conversation
rcl/test/rcl/test_parameters.cpp
Outdated
| delete this->wait_set; | ||
|
|
||
| ret = rcl_parameter_service_fini(this->parameter_service); | ||
| delete this->parameter_service; |
There was a problem hiding this comment.
You should probably delete these in reverse order, i.e. you should probably fini and delete the parameter service before the node.
|
For the functions in rcl_ret_t
rcl_parameter_set_integer(
void * parameter,
rcl_parameter_type_support_t * ts,
const char * parameter_name,
int value);Where the typedef struct rcl_parameter_type_support_t
{
rcl_ret_t (*set_integer) (void * parameter, const char * name, int value);
rcl_ret_t (*set_double) (void * parameter, const char * name, double value);
// And so on...
} rcl_parameter_type_support_t;There would be a version of this structure for each language supported and could live in a static (not generated) header in the What this lets you do is use either C or C++ versions of the Parameter messages, for example C++: #include <rcl_interfaces/msg/Parameter.hpp>
#include <rcl_interfaces/cpp/type_support.hpp>
rcl_interfaces::msg::Parameter param;
rcl_parameter_set_integer(
¶m,
rcl_interfaces::get_cpp_parameter_type_support(),
"foo", 42);And the same for C using the same #include <rcl_interfaces/msg/Parameter.hpp>
#include <rcl_interfaces/c/type_support.h>
rcl_interfaces__msg__Parameter param;
rcl_parameter_set_integer(
¶m,
rcl_interfaces_get_c_parameter_type_support(),
"foo", 42);And in the rcl_ret_t
rcl_parameter_set_integer(
void * param,
rcl_parameter_type_support_t * ts,
const char * name,
int value)
{
return ts->set_integer(param, name, value);
}This is all sort of roundabout, but allows you to add new language types (maybe I suppose it's also worth taking a step back to consider if it is necessary to support more than just C messages in this parameter API. I don't have a high enough level view yet to say one way or the other. |
|
For the functions in However, I think my above argument about using type erasure and type support structures to delegate work for different types applies more to functions like this: RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_parameter_client_take_set_response(
const rcl_parameter_client_t * parameter_client,
rmw_request_id_t * request_header,
rcl_interfaces__msg__SetParametersResult__Array * set_parameters_result);This function only supports the C type, and as you mentioned offline, it would be nice to use this interface in RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_parameter_client_take_set_response(
const rcl_parameter_client_t * parameter_client,
rmw_request_id_t * request_header,
void * set_parameters_result,
rcl_message_type_support_t * set_parameters_result_ts);Not sure about the types and stuff, but you get the idea. In this way these functions would emulate the underlying functions like |
rcl/include/rcl/parameter_client.h
Outdated
| { | ||
| // the parameter client provides storage and utility functions for parameter event subscription | ||
| // Should instead have a create_parameter_event_subscription function for this parameter client? | ||
| // rcl_subscription_t * parameter_event_subscription; |
There was a problem hiding this comment.
Naively, I'd say that the fact that a subscription is involved is an implementation detail of parameters. A related question is whether or not the user can get a handle on the subscription object that the client uses or change the QoS options of that subscription.
If we don't expose these "details" of how parameters work, then I think it's clear that the subscription should be created and destroyed within rcl without extra action from the client library.
I think you've already done the other necessary bits to "abstract" the implementation of the parameter client and server from the user of rcl with rcl_wait_set_add_parameter_client and the matching take functions.
More to your question, can you describe in more detail what create_parameter_event_subscription would do and what the alternative default behavior is?
|
Ok, I've finished my first review. I tried to give some useful feedback on any questions I saw and raise questions where I didn't understand, but now I'm just hoping it was more help than hindrance 😄. |
0d8b0c4 to
8a703b0
Compare
| rcl_interfaces__msg__Parameter * prior_entry = &prior_state->data[prior_idx]; | ||
| for (new_idx = 0; new_idx < new_state->size; ++new_idx) { | ||
| rcl_interfaces__msg__Parameter * new_entry = &new_state->data[new_idx]; | ||
| // If the parameter has the same name but a different type or value, count it as changed. |
There was a problem hiding this comment.
Here we assume uniqueness of parameter name in parameter arrays. Is there a place where we prevent user to have duplicated parameter names in a given Parameter__Array ?
For example if one append a new parameter with the same name at the end of the array but different type or value, this parameter won't appear in the parameter event message (given that it wont be catched neither as a changed one nor a new one)
I agree that parameter names should be unique for a given node, I just can't find a place where it's enforced.
There was a problem hiding this comment.
Where would you suggest adding the check for uniqueness of parameter keys?
There was a problem hiding this comment.
I'm not sure what the right place would be. I have trouble to figure the scope of this feature. If it's going to be only used for parameters and nowhere else I would put it in the send request client macro so that the client ensure the integrity of the data before interacting with the server and the server never has to deal with duplicates
|
bf05549 will ignore the parameters test for Connext Dynamic. With the |
|
|
||
| #include "rcl_interfaces/srv/set_parameters.h" | ||
| #include "rcl_interfaces/msg/set_parameters_result.h" | ||
| #include "rcl_interfaces/msg/parameter.h" |
update style to match latest uncrustify
|
Closing, as it's a bit outdated (same as ros2/rclcpp#276 (comment)). |
This is currently an API stub, NOT a fully functional implementation.
I'm submitting this PR to get initial feedback on the approach before I fully implement the API. I'm making an effort to make sure this branch builds and links so that I can also prototype how it will be used in
rclcpp.I suggest starting with
test_parameters.cpp, which lays out how the API calls will be used.Here are the remaining items to address before I will consider this ready for merging:
rclcppand refine API as neededrosidl_generator_crcl_interfaces::msg::ParameterValueto allow arrays of primitives (bool, int, float). (optional, but I think this would be useful!)convert_changes_to_eventconvenience functionSome questions that came up while prototyping this:
rclcppimplementation, the parameter events topic is global. That is, all nodes publish parameter event changes to the topic"parameter_events". Should the topic instead be node local (e.g."node_name__parameter_events")? Should this be a configuration option?set_parameters_atomicallybe a special case ofset_parametersor should they use separate services and clients as they do in this current prototype?rclfor managing parameter namespacing? In this implementation,rclcurrently has no conception of parameter namespaces, it simply passes a "prefixes" option tolist_parameters.Connects to #28