-
Notifications
You must be signed in to change notification settings - Fork 330
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
demo for rclpy parameter_client #566
Conversation
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
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.
Technically, the demo looks okay to me. However, there's a lot going on this demo and I want to make sure we present the content clearly (both in code and output). Running it produces a wall of text that is a bit overwhelming.
I think it would be nicer to clean up the output so it looks something like:
Listing parameters:
zero
one
etc...
Getting parameters:
zero: 0
one: 1
etc...
Note, this also makes it easier to automate testing the expected output if we end up doing that for the Python demos in the future. We do this for the C++ demos.
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Example output:
Format is valid yaml and should be consistent in case we end up wanting to automate testing these demos |
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 cleaning up the output!
My remaining comments are mostly about trying to simplify the code. For reference, all of the other Python demos are less than 100 LOC. Though I don't think this has to be that short, I see a few ways we can reduce complexity.
context = rclpy.context.Context() | ||
rclpy.init(context=context) |
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.
Correct me if I'm wrong, but I think we can just use the default context to keep things simple,
I.e. just elide passing an explicit context everywhere.
context = rclpy.context.Context() | |
rclpy.init(context=context) | |
rclpy.init() |
target_node.declare_parameters('', [ | ||
('int_parameter', 1), | ||
('bool_parameter', False), | ||
('string_parameter', 'Hello World'), | ||
]) | ||
target_executor.add_node(target_node) |
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 the spirit of keeping the demo simple, can we just use a single node (ie. use the same node to create the parameters client and as the target node)? Then we can avoid creating an executor and spinning in a separate thread.
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.
My original intent for having two nodes and two seperate contexts is to demonstrate the new functionality of first-class support for setting a remote nodes' parameters. I feel like having only a single node in the demo defeats that purpose since a node setting parameters for itself would presumably just use self.set_parameters
.
That being said, I agree with keeping the demo simple. I think the best way to do that would be to not exhaustively run through every method offered by ParameterClient
-- it is a little repetitive and overruns this demo with boilerplate code.
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.
I suppose if we really want to demo interacting with a remote node, then that node should be run independently (i.e. in a separate process). E.g. we could add a comment to this demo that the user should first run the parameter blackboard executable (or a new python equivalent) as part of this demo.
I'm also still okay with using a single node since this is what the cpp demos do, for example.
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.
Using the parameter blackboard sounds like a good idea, I'll work something out for that
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
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.
* WIP: python examples for async parameter client Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * reorganize Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * linting & use tempfile Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * linting Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * put async_param_server node in async_param_client Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * address review comments Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * delete param demo with static and non-static param Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * tabs aren't valid yaml Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * decrease demo complexity Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * use parameter blackboard Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * add warning if wait_for_services fails to demo Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
* WIP: python examples for async parameter client Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * reorganize Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * linting & use tempfile Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * linting Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * put async_param_server node in async_param_client Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * address review comments Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * delete param demo with static and non-static param Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * tabs aren't valid yaml Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * decrease demo complexity Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * use parameter blackboard Signed-off-by: Brian Chen <brian.chen@openrobotics.org> * add warning if wait_for_services fails to demo Signed-off-by: Brian Chen <brian.chen@openrobotics.org> Signed-off-by: Bey Hao Yun <beyhy94@gmail.com>
Adds demos for parameter_client functionality introduced in ros2/rclpy#959