-
Notifications
You must be signed in to change notification settings - Fork 530
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
Porting rosapi package. #388
Porting rosapi package. #388
Conversation
- Porting service servers and auxiliary functions to ROS2. Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
- Using absolute node names. Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
@dirk-thomas this should be ready for an initial review. Some notes to consider:
That being said, my initial suggestion would be to proceed if possible without dealing with those two remaining services. Of course, comments and suggestions are welcome! |
@@ -95,7 +95,7 @@ def get_service_response_typedef_recursive(servicetype): | |||
|
|||
def _get_typedef(instance): | |||
""" Gets a typedef dict for the specified instance """ | |||
if instance is None or not hasattr(instance, "__slots__") or not hasattr(instance, "_slot_types"): | |||
if instance is None or not hasattr(instance, "__slots__") or not hasattr(instance, "_fields_and_field_types"): |
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.
Just a heads up: _fields_and_field_types
is likely going to be replaced on master soon, see ros2/rosidl_python#33.
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.
Thanks for the heads up; I'll keep an eye on that PR and update this code once it's merged.
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 seems that in the end it was not replaced (see rosidl_generator_py/_msg.py.em).
It should then be fine to keep this as is.
What are those two services being used? So how severe is it to not port them? |
Thanks for the comments @dirk-thomas! I'll be addressing them soon.
These services aren't being used in rosbridge itself; I've searched the codebase for a client for those services and I found none. In other words, a missing service might affect client code using |
Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
- Assuming that message packages are already in the path. Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
@dirk-thomas comments were addressed; this one is pending until the referenced PR is merged. |
@dirk-thomas I went through the comments once again to double check; I think this is ready to be merged to |
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
Porting rosapi package. Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
Porting rosapi package. Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
Signed-off-by: Juan Ignacio Ubeira <jubeira@ekumenlabs.com>
d = loads(value) | ||
except ValueError: | ||
raise Exception("Due to the type flexibility of the ROS parameter server, the value argument to set_param must be a JSON-formatted string.") | ||
|
||
node_name = get_absolute_node_name(node_name) | ||
with param_server_lock: | ||
rospy.set_param(name, d) | ||
|
||
|
||
def get_param(name, default, params_glob): | ||
_set_param(node_name, name, value) |
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.
@jubeira Sorry to dig up this old PR, but I'm having some trouble with a client that calls on this API and I think I've isolated the issue to this spot. It seems as though when value
is a JSON-encoded string, the later call to get_parameter_value()
sets the ParameterValue.string_value
attribute with double-quotes, meaning it's impossible to set a string parameter via this method without double quotes being applied.
If the client sends the value
without JSON encoding, the above ValueError
is thrown and set_param()
fails altogether.
I think inside the try
block, there could be a line value = d if isinstance(d, str) else value
.
This would ensure that a valid string object is later passed to get_parameter_value()
rather than a JSON-encoded one, but otherwise behaviour would stay the same. Would this potentially work?
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.
Hi @travipross!
Honestly it's been a while so I'm not sure what the actual consequences of that change could be. Your proposal makes sense but I can't be 100% sure without trying the code.
I'd suggest you to fork the repo, apply the change and check if it works for you. If it does, please feel free to contribute the change with a PR explaining what you did.
Thanks!
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.
Thanks, opened one here: #521
This PR focuses on porting
rosapi
package to ROS2.See ros2#2 for the current overall progress.