Skip to content
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

Support container in frontend #235

Merged
merged 16 commits into from
Jun 8, 2021

Conversation

kenji-miyake
Copy link
Contributor

Hello, I've added container support in launch frontend because it seems nothing is going on after #77.

I read https://answers.ros.org/question/333404/launch-composed-nodes-using-the-launch-xml-frontend/ and followed @ivanpauno's suggestion.

@ivanpauno Could you review this, please?

Following is the launch file I used.

// sample.launch.xml
<launch>
  <node_container pkg="rclcpp_components" exec="component_container" name="my_container" namespace="" args="test_args">
    <composable_node pkg="composition" plugin="composition::Talker" name="talker" namespace="test_namespace">
      <remap from="chatter" to="/remap/chatter" />
      <param name="use_sim_time" value="true"/>
      <extra_arg name="use_intra_process_comms" value="true"/>
    </composable_node>
  </node_container>

  <load_composable_node target="my_container">
    <composable_node pkg="composition" plugin="composition::Listener" name="listener" namespace="test_namespace">
      <remap from="chatter" to="/remap/chatter" />
      <param name="use_sim_time" value="true"/>
      <extra_arg name="use_intra_process_comms" value="true"/>
    </composable_node>
  </load_composable_node>
</launch>

How to test

$ ros2 launch sample_container.launch.xml
[INFO] [launch]: All log files can be found below /home/kenji/.ros/log/2021-05-06-22-29-14-382250-desktop-3799342
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [3799366]
[component_container-1] [INFO 1620307754.832549812] [my_container]: Load Library: /opt/ros/rolling/lib/libtalker_component.so
[component_container-1] [INFO 1620307754.833179414] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO 1620307754.833199314] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO 1620307754.837469835] [my_container]: Load Library: /opt/ros/rolling/lib/liblistener_component.so
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/test_namespace/talker' in container '/my_container'
[component_container-1] [INFO 1620307754.838234197] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-1] [INFO 1620307754.838254847] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/test_namespace/listener' in container 'my_container'
[component_container-1] [INFO 1620307755.837301844] [test_namespace.talker]: Publishing: 'Hello World: 1'
[component_container-1] [INFO 1620307755.837412384] [test_namespace.listener]: I heard: [Hello World: 1]
[component_container-1] [INFO 1620307756.837283640] [test_namespace.talker]: Publishing: 'Hello World: 2'
[component_container-1] [INFO 1620307756.837384780] [test_namespace.listener]: I heard: [Hello World: 2]
[component_container-1] [INFO 1620307757.837282930] [test_namespace.talker]: Publishing: 'Hello World: 3'
[component_container-1] [INFO 1620307757.837388000] [test_namespace.listener]: I heard: [Hello World: 3]

In another terminal,

# Check namespace is remapped
$ ros2 node list
/launch_ros_3799880
/my_container
/subscriber
/test_namespace/listener
/test_namespace/talker

# Check topic is remapped
$ ros2 node info /test_namespace/talker
/test_namespace/talker
  Subscribers:
    /clock: rosgraph_msgs/msg/Clock
    /parameter_events: rcl_interfaces/msg/ParameterEvent
  Publishers:
    /parameter_events: rcl_interfaces/msg/ParameterEvent
    /remap/chatter: std_msgs/msg/String
    /rosout: rcl_interfaces/msg/Log
  Service Servers:
    /test_namespace/talker/describe_parameters: rcl_interfaces/srv/DescribeParameters
    /test_namespace/talker/get_parameter_types: rcl_interfaces/srv/GetParameterTypes
    /test_namespace/talker/get_parameters: rcl_interfaces/srv/GetParameters
    /test_namespace/talker/list_parameters: rcl_interfaces/srv/ListParameters
    /test_namespace/talker/set_parameters: rcl_interfaces/srv/SetParameters
    /test_namespace/talker/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically
  Service Clients:

  Action Servers:

  Action Clients:

# Check use_sim_time is set to true
$ ros2 param dump --print /test_namespace/talker
/test_namespace/talker:
  ros__parameters:
    qos_overrides:
      /clock:
        subscription:
          depth: 1
          durability: volatile
          history: keep_last
          reliability: best_effort
      /parameter_events:
        publisher:
          depth: 1000
          durability: volatile
          history: keep_last
          reliability: reliable
    use_sim_time: true

Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loos pretty good to me, I've left some minor comments

launch_ros/launch_ros/actions/composable_node_container.py Outdated Show resolved Hide resolved
launch_ros/launch_ros/actions/load_composable_nodes.py Outdated Show resolved Hide resolved
@ivanpauno ivanpauno requested a review from hidmic May 6, 2021 14:38
@ivanpauno ivanpauno added the enhancement New feature or request label May 6, 2021
@kenji-miyake
Copy link
Contributor Author

@ivanpauno Thank you for your quick review! I'll fix them.

Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Kenji Miyake added 4 commits May 7, 2021 14:50
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@kenji-miyake
Copy link
Contributor Author

Fixed except for #235 (comment) (because there was a problem with it).
@ivanpauno @hidmic Could you review again and close resolved comments?

Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@kenji-miyake kenji-miyake force-pushed the support-container-in-frontend branch from c93d435 to c119e94 Compare May 7, 2021 18:16
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM pending green CI

launch_ros/launch_ros/descriptions/composable_node.py Outdated Show resolved Hide resolved
launch_ros/launch_ros/actions/composable_node_container.py Outdated Show resolved Hide resolved
launch_ros/launch_ros/actions/load_composable_nodes.py Outdated Show resolved Hide resolved
Kenji Miyake added 2 commits May 11, 2021 11:54
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@kenji-miyake kenji-miyake force-pushed the support-container-in-frontend branch from dad664d to cb67451 Compare May 11, 2021 04:13
Kenji Miyake added 2 commits May 11, 2021 13:43
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @kenji-miyake !!

@ivanpauno ivanpauno requested a review from hidmic May 11, 2021 16:17
@ivanpauno
Copy link
Member

This PR could use a test case, that could be added here.

Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too, and I agree with @ivanpauno this could use a few test cases.

Thank you for your contributions @kenji-miyake!

launch_ros/launch_ros/actions/composable_node_container.py Outdated Show resolved Hide resolved
launch_ros/launch_ros/actions/load_composable_nodes.py Outdated Show resolved Hide resolved
Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for adding this! LGTM pending some tests.

Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@hidmic
Copy link
Contributor

hidmic commented May 20, 2021

@kenji-miyake friendly ping

@kenji-miyake
Copy link
Contributor Author

@hidmic Oh, I'm sorry. Did you ask me to add tests? I couldn't recognize that from your conversations because there isn't a concrete request, sorry. 😢
I'll try it this weekend!

@kenji-miyake
Copy link
Contributor Author

I'm sorry, I couldn't make time recently. I think I can start to work!

@hidmic
Copy link
Contributor

hidmic commented May 31, 2021

Did you ask me to add tests? I couldn't recognize that from your conversations because there isn't a concrete request, sorry.

Yes! Sorry if it wasn't clear.

Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@kenji-miyake kenji-miyake force-pushed the support-container-in-frontend branch from db96302 to 7c5ecb9 Compare June 6, 2021 18:55
@kenji-miyake
Copy link
Contributor Author

@hidmic @ivanpauno @jacobperron I'm sorry to be late. Added tests! Could you review again, please? 😄
Although I wasn't sure what level of tests you expected, does this match your expectation?

The following is my test result.

~/launch_test_ws/src/launch_ros/test_launch_ros support-container-in-frontend
❯ pytest -s test/test_launch_ros/frontend/test_component_container.py
=============================================================================================================================================================================================== test session starts ================================================================================================================================================================================================
platform linux -- Python 3.8.5, pytest-6.2.2, py-1.10.0, pluggy-0.13.0
rootdir: /home/kenji/launch_test_ws/src/launch_ros/test_launch_ros, configfile: pytest.ini
plugins: launch-testing-ros-0.14.2, launch-testing-0.17.0, ament-flake8-0.9.6, ament-lint-0.9.6, ament-pep257-0.9.6, ament-xmllint-0.9.6, ament-copyright-0.9.6, cov-2.11.1, asyncio-0.15.1, dash-1.20.0, repeat-0.9.1, rerunfailures-9.1.1, mock-1.10.4, colcon-core-0.6.1
collected 2 items                                                                                                                                                                                                                                                                                                                                                                                                  

test/test_launch_ros/frontend/test_component_container.py [INFO] [launch]: All log files can be found below /home/kenji/.ros/log/2021-06-07-03-55-16-088632-desktop-550780
[INFO] [launch]: Default logging verbosity is set to INFO
1623005716.141647 [0]     pytest: selected interface "lo" is not multicast-capable: disabling multicast
[INFO] [component_container-1]: process started with pid [550855]
[component_container-1] 1623005716.156574 [0] component_: selected interface "lo" is not multicast-capable: disabling multicast
[component_container-1] [INFO 1623005716.400550184] [my_container]: Load Library: /opt/ros/foxy/lib/libtalker_component.so
[component_container-1] [INFO 1623005716.401018869] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO 1623005716.401033379] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO 1623005716.403538496] [my_container]: Load Library: /opt/ros/foxy/lib/liblistener_component.so
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/test_namespace/talker' in container '/my_container'
[component_container-1] [INFO 1623005716.403958001] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-1] [INFO 1623005716.403970261] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/test_namespace/listener' in container 'my_container'
[component_container-1] [INFO 1623005717.403391317] [test_namespace.talker]: Publishing: 'Hello World: 1'
[component_container-1] [INFO 1623005717.403531039] [test_namespace.listener]: I heard: [Hello World: 1]
[component_container-1] [INFO 1623005718.403373227] [test_namespace.talker]: Publishing: 'Hello World: 2'
[component_container-1] [INFO 1623005718.403473408] [test_namespace.listener]: I heard: [Hello World: 2]
[component_container-1] [INFO 1623005719.403712682] [test_namespace.talker]: Publishing: 'Hello World: 3'
[component_container-1] [INFO 1623005719.403811873] [test_namespace.listener]: I heard: [Hello World: 3]
[component_container-1] [INFO 1623005720.403378523] [test_namespace.talker]: Publishing: 'Hello World: 4'
[component_container-1] [INFO 1623005720.403479034] [test_namespace.listener]: I heard: [Hello World: 4]
[INFO] [component_container-1]: sending signal 'SIGINT' to process[component_container-1]
[component_container-1] [INFO 1623005721.403385760] [test_namespace.talker]: Publishing: 'Hello World: 5'
[component_container-1] [INFO 1623005721.403482981] [test_namespace.listener]: I heard: [Hello World: 5]
[component_container-1] [INFO 1623005721.611731658] [rclcpp]: signal_handler(signal_value=2)
[INFO] [component_container-1]: process has finished cleanly [pid 550855]
.[INFO] [launch]: All log files can be found below /home/kenji/.ros/log/2021-06-07-03-55-16-088632-desktop-550780
[INFO] [launch]: Default logging verbosity is set to INFO
1623005721.951976 [0]     pytest: selected interface "lo" is not multicast-capable: disabling multicast
[INFO] [component_container-2]: process started with pid [550887]
[component_container-2] 1623005721.961697 [0] component_: selected interface "lo" is not multicast-capable: disabling multicast
[component_container-2] [INFO 1623005722.206660393] [my_container]: Load Library: /opt/ros/foxy/lib/libtalker_component.so
[component_container-2] [INFO 1623005722.207380071] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-2] [INFO 1623005722.207419631] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-2] [INFO 1623005722.211512605] [my_container]: Load Library: /opt/ros/foxy/lib/liblistener_component.so
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/test_namespace/talker' in container '/my_container'
[component_container-2] [INFO 1623005722.212243743] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-2] [INFO 1623005722.212270203] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/test_namespace/listener' in container 'my_container'
[component_container-2] [INFO 1623005723.211132346] [test_namespace.talker]: Publishing: 'Hello World: 1'
[component_container-2] [INFO 1623005723.211273338] [test_namespace.listener]: I heard: [Hello World: 1]
[component_container-2] [INFO 1623005724.211093024] [test_namespace.talker]: Publishing: 'Hello World: 2'
[component_container-2] [INFO 1623005724.211193115] [test_namespace.listener]: I heard: [Hello World: 2]
[component_container-2] [INFO 1623005725.211097102] [test_namespace.talker]: Publishing: 'Hello World: 3'
[component_container-2] [INFO 1623005725.211197673] [test_namespace.listener]: I heard: [Hello World: 3]
[component_container-2] [INFO 1623005726.211102820] [test_namespace.talker]: Publishing: 'Hello World: 4'
[component_container-2] [INFO 1623005726.211201451] [test_namespace.listener]: I heard: [Hello World: 4]
[INFO] [component_container-2]: sending signal 'SIGINT' to process[component_container-2]
[component_container-2] [INFO 1623005727.211125241] [test_namespace.talker]: Publishing: 'Hello World: 5'
[component_container-2] [INFO 1623005727.211216542] [test_namespace.listener]: I heard: [Hello World: 5]
[component_container-2] [INFO 1623005727.421546433] [rclcpp]: signal_handler(signal_value=2)
[INFO] [component_container-2]: process has finished cleanly [pid 550887]
.

================================================================================================================================================================================================ 2 passed in 11.69s ================================================================================================================================================================================================

Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added test seems reasonable to me!

@ivanpauno ivanpauno requested a review from hidmic June 7, 2021 13:06
Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with @ivanpauno comment addressed.

Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@ivanpauno
Copy link
Member

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@ivanpauno ivanpauno merged commit e2abd4b into ros2:master Jun 8, 2021
@ivanpauno
Copy link
Member

Thanks for the contribution @kenji-miyake !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants