-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create maliput ros node #8
Conversation
- Creates MaliputQueryNode as a ROS2 proxy to make RoadNetwork queries. - Provides a sample configuration file use maliput_malidrive. Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
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.
Great Job! Happy to see a ros node with maliput! I left some comments, ptal.
ament_export_include_directories(include) | ||
|
||
install(DIRECTORY | ||
launch |
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.
are you missing resources
as well?
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.
Done.
/// MaliputQueryNode is a LifecycleNode that serves as proxy to a maliput::api::RoadNetwork | ||
/// set of queries. | ||
/// | ||
/// It defines the following parameters: |
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.
nit:
/// It defines the following parameters: | |
/// It defines the following ros parameters: |
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 would also comment here what is the expected format of the yaml file. Maybe linking to maliput_ros::utils::YamlParser if you don't want to copy-paste the example because of duplicating docs.
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.
Done.
MaliputQueryNode(const std::string& node_name, const std::string& namespace_, | ||
const rclcpp::NodeOptions& options = rclcpp::NodeOptions()); |
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 think that with a small change we can evolve it to be a component, we simply need to provide the constructor with the firm MyClass(const rclcpp::NodeOptions& options)
MaliputQueryNode(const std::string& node_name, const std::string& namespace_, | |
const rclcpp::NodeOptions& options = rclcpp::NodeOptions()); | |
MaliputQueryNode(const rclcpp::NodeOptions& options = rclcpp::NodeOptions()); |
For setting a different node name or different namespace the remapping could be used:
Note: I could push a commit with the suggestion if you want.
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.
If you don't mind, I'd prefer to push it to a follow up iteration. I just left one constructor with default values for the namespace to consider the other case. That way, we can decide how to configure the lifecycle node constructor which demands a node name.
BTW, I haven't seen examples of composition with lifecycle managed nodes.
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.
Sure no worries, it is just enhancement, I will create the issue(#9) and I could try to tackle this later on.
BTW, I haven't seen examples of composition with lifecycle managed nodes.
There are no ros2 examples in the docs but you can find code out there with this approach like this one
explicit MaliputQuery(std::unique_ptr<maliput::api::RoadNetwork> road_network) | ||
: road_network_(std::move(road_network)) { |
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.
QQ: Is there a reason why MaliputQuery is the owner of the RoadNetwork?
I am ok with this, at the moment there are no other applications
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.
Simply because there is no other one requiring to hold the ownership of it. The ownership lifecycle will be tied as well so even though you are right, there is no explicit ownership relationship, it sounded OK to me leave to the MaliputQuery the responsibility to own that memory and simplify the management at the node level.
target_lifecycle_node=maliput_query_server_node, goal_state='active', | ||
entities=[ | ||
launch.actions.LogInfo( | ||
msg="node 'query_server' reached the 'active' state, launching 'listener'."), |
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.
Check the msg: "... launching listener" seems to be part of an 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.
Done.
) | ||
) | ||
|
||
# Make the talker node take the 'configure' transition. |
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.
Check: "# Make the talker node take the 'configure' transition."
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.
Done.
|
||
# The query server node. | ||
maliput_query_server_node = launch_ros.actions.LifecycleNode( | ||
package='maliput_ros', executable='maliput_ros', name='query_server', output='screen', |
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.
For the name, what about maliput_query_server
instead ? So the node name is more self-describable.
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.
Also, we could provide here a namespace
so the services are advertised under the node name for example:
So the service: Like the /road_geometry
and other services when provided are better organized.
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.
Done.
|
||
MaliputQueryNode::MaliputQueryNode(const std::string& node_name, const std::string& namespace_, | ||
const rclcpp::NodeOptions& options) | ||
: rclcpp_lifecycle::LifecycleNode(node_name, namespace_, options), is_active_(false) { |
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.
As the LifeCycleNode already advertise several services for the state transition and stuff, maybe it makes sense to hide those services under a namespace so those services are left at <node_name>/lifecycle/
, while the services that this node provides are under <node_name>
.
Nowadays:
franco@9c2d60d201e3:~/maliput_ws_focal$ ros2 service list
/launch_ros_2177/describe_parameters
/launch_ros_2177/get_parameter_types
/launch_ros_2177/get_parameters
/launch_ros_2177/list_parameters
/launch_ros_2177/set_parameters
/launch_ros_2177/set_parameters_atomically
/query_server/change_state
/query_server/describe_parameters
/query_server/get_available_states
/query_server/get_available_transitions
/query_server/get_parameter_types
/query_server/get_parameters
/query_server/get_state
/query_server/get_transition_graph
/query_server/list_parameters
/query_server/set_parameters
/query_server/set_parameters_atomically
/road_geometry
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.
Done.
int Main(int argc, char* argv[]) { | ||
ForceStdoutFlush(); | ||
rclcpp::init(argc, argv); | ||
rclcpp::executors::SingleThreadedExecutor executor; |
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.
Documenting for future iterations:
Not sure if we are going to be able to handle queries in parallel. If so, at some point we will need to use a MultiTthreadedExecutor: See Executors
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.
Ack.
backend: "maliput_malidrive" | ||
parameters: | ||
road_geometry_id: "t_shape_road" | ||
opendrive_file: "/home/agalbachicar/maliput_ws_focal/install/maliput_malidrive/share/maliput_malidrive/resources/odr/TShapeRoad.xodr" |
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.
If it is just an example note that you can use here:
opendrive_file: "/home/agalbachicar/maliput_ws_focal/install/maliput_malidrive/share/maliput_malidrive/resources/odr/TShapeRoad.xodr" | |
opendrive_file: "/opt/ros/foxy/share/maliput_malidrive/resources/odr/TShapeRoad.xodr" |
(sudo apt install ros-foxy-maliput-malidrive
)
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.
Done.
emit_event_to_request_that_query_server_does_configure_transition = launch.actions.EmitEvent( | ||
event=launch_ros.events.lifecycle.ChangeState( | ||
lifecycle_node_matcher=launch.events.matches_action(maliput_query_server_node), | ||
transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, | ||
) | ||
) |
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 doing on state instead of just emitting?
emit_event_to_request_that_query_server_does_configure_transition = launch.actions.EmitEvent( | |
event=launch_ros.events.lifecycle.ChangeState( | |
lifecycle_node_matcher=launch.events.matches_action(maliput_query_server_node), | |
transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, | |
) | |
) | |
register_event_handler_for_query_server_reaches_unconfigured_state = launch.actions.RegisterEventHandler( | |
launch_ros.event_handlers.OnStateTransition( | |
target_lifecycle_node=maliput_query_server_node, goal_state='unconfigured', | |
entities=[ | |
launch.actions.LogInfo( | |
msg="node 'query_server' reached the 'unconfigured' state, 'configuring'."), | |
launch.actions.EmitEvent(event=launch_ros.events.lifecycle.ChangeState( | |
lifecycle_node_matcher=launch.events.matches_action(maliput_query_server_node), | |
transition_id=lifecycle_msgs.msg.Transition.TRANSITION_CONFIGURE, | |
)), | |
], | |
) |
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.
This does not work. It does not trigger the initialization.
register_event_handler_for_query_server_reaches_inactive_state, | ||
register_event_handler_for_query_server_reaches_active_state, |
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.
Maybe the stuff that is related to the lifecycle node we could move it to a launch file that is included here. That launchfile could live at maliput_ros/launch/include/lifecycle_config.launch.py
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.
Pushed to a future iteration. #11
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
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!
🎉 New feature
Part of #1
Summary
Creates a node and provides a launchfile to execute it. The node only responds to the
/road_geometry
service call at the moment and lacks of testing, it will be implemented in a subsequent PR.Also, there is no explicit
exec_depend
on maliput_malidrive as there is actually no dependency with this example resource file (note it is not installed on purpose). We still need to define what to do with it.Test it
Unit tests, and you can try launching it from the terminal:
From another terminal, you can try:
Checklist
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.