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

Create nav2 dynamic composition #2147

Closed
SteveMacenski opened this issue Jan 8, 2021 · 17 comments
Closed

Create nav2 dynamic composition #2147

SteveMacenski opened this issue Jan 8, 2021 · 17 comments
Assignees

Comments

@SteveMacenski
Copy link
Member

SteveMacenski commented Jan 8, 2021

Something to contain manually composed nav2 system nodes so that even though the launch system doesn't deal with component-lifecycle nodes well, we can still get the benefits of both (even if not as flexible). This will be good enough for most users as they're not going to be swapping out the task servers.

Per idea / request from Emerson in the WG meeting

@SteveMacenski
Copy link
Member Author

@SteveMacenski SteveMacenski self-assigned this Jan 11, 2021
@NithishkumarS
Copy link
Contributor

So ideally where should this composition file be located?

@SteveMacenski
Copy link
Member Author

SteveMacenski commented Jan 22, 2021

In a new package, nav2_composed_bringup (or something like that, I'm not really great with naming, feel free to propose a different one)

@gezp
Copy link
Contributor

gezp commented Aug 19, 2021

i will do this work in the next few weeks. i make a plan list at first , and any suggestions are welcome.

@gezp
Copy link
Contributor

gezp commented Sep 8, 2021

It provides a composition-based bringup method, which could replace launching Nav2 nodes separately in package nav2_bringup, so it's not necessary to create a new package nav2_composition, just put it in package nav2_bringup.

@gezp
Copy link
Contributor

gezp commented Sep 9, 2021

i try to implement dynamically composed bringup for Nav2, but i failed because of some problems, i will share my experience:

there are some problems about loading ROS parameters :

i have no idea about how to solve the second problem, any discussion is welcome.

@gezp
Copy link
Contributor

gezp commented Sep 14, 2021

in order to solve the second problem in #2147 (comment), i try to use argument --params-file for containter Node so that the internal Node could use this argument to load parameter from file.

it still has no effect, because NodeOption of component Node uses use_global_arguments(false) to disable global arguments (https://github.com/ros2/rclcpp/blob/master/rclcpp_components/src/component_manager.cpp#L151), in addition, some other
arguments also has no effect for component Node, you can find some details here : ros2/rclcpp#978

@gezp
Copy link
Contributor

gezp commented Sep 14, 2021

According to https://discourse.ros.org/t/nav2-composition/22175, a large multi-threaded executor consumes higher cpu(increase 30%-50%) than a bunch of single-threaded executors in manually composed bringup of nav2.
but rclcpp_components doesn't support a bunch of single-threaded executors for run-time composition, which is important for dynamically composed bringup of nav2 . a related issue here: ros2/rclcpp#1772 .

@gezp
Copy link
Contributor

gezp commented Sep 18, 2021

in order to solve the second problem in #2147 (comment), i try to use argument --params-file for container Node so that the internal Node could use this argument to load parameter from file.

sorry, it works well , i forgot to load parameters for each component Node when i use params-file for container.

in this way, we need load component Node's parameter from ComposableNode (code block in launch file) and load internal Node's parameter from Container Node (which seems like a bit strange).

the internal Node (e.g. local_costmap) create their own rclcpp::NodeOptions, which couldn't be affected by component Node, so default use_global_arguments(true) is used by them, which could load parameters from container's argument --params-file .

@SteveMacenski
Copy link
Member Author

in this way, we need load component Node's parameter from ComposableNode (code block in launch file) and load internal Node's parameter from Container Node (which seems like a bit strange).

Indeed, sounds like we still want to enable that option, but if there's a work around we can use for now, that works for me. Lets just continue to document the issue that does exist for solutions.

@SteveMacenski SteveMacenski changed the title Create nav2 composition package Create nav2 dynamic composition Sep 30, 2021
@SteveMacenski
Copy link
Member Author

Manual composition merged!

@SteveMacenski
Copy link
Member Author

Essentially done, just waiting on docs updates

@imstevenpmwyca
Copy link

imstevenpmwyca commented Jun 6, 2022

in order to solve the second problem in #2147 (comment), i try to use argument --params-file for container Node so that the internal Node could use this argument to load parameter from file.

sorry, it works well , i forgot to load parameters for each component Node when i use params-file for container.

in this way, we need load component Node's parameter from ComposableNode (code block in launch file) and load internal Node's parameter from Container Node (which seems like a bit strange).

the internal Node (e.g. local_costmap) create their own rclcpp::NodeOptions, which couldn't be affected by component Node, so default use_global_arguments(true) is used by them, which could load parameters from container's argument --params-file .

Dear @gezp,
I am dealing with the exact same issue you had loading parameters from a .yaml file to a node within a Composable node.
From reading this ticket I got the idea that you found a workaround for it; I tried doing what you described in this comment (using the Container's node argument --params-file), but it doesn't seem to work for me.
My current launch file looks something like this:

_container = ComposableNodeContainer(
            name = 'name_container',
            namespace = '',
            package = 'rclcpp_components',
            executable = 'component_container',
            composable_node_descriptions=[
                  ComposableNode(
                      package = 'package_name',
                      plugin = 'plugin::plugin',
                      name = 'node_name',
                      parameters = [
                          {'use_sim_time': use_sim_time},
                          {'param1': 1},
                          ],
                      extra_arguments = [{'use_intra_process_comms': True}]
                  ),
            ],
            arguments = ['--params-file', path/to/parameters.yaml],
            output = 'both',
    )

The Composable Node is a LifecycleNode and it uses an instance of a 2D ROS costmap from nav2 like shown below. The parameters I'm trying to load from 'path/to/parameters.yaml' are actually the ones needed for the 2D ROS costmap.

costmap_ros_ = std::make_shared<nav2_costmap_2d::Costmap2DROS>("local_costmap","","ns_local");

Am I missing something? I also tried other suggestions I found like this, this and this, and while I noticed that the ComposableNode correctly gets the parameters from the .yaml file, the costmap node within doesn't. So I haven't managed to properly initialize the costmap2dros instance.

I hope you can help me with this one,
Thank you very much for your time and consideration,
Kind regards!

@gezp
Copy link
Contributor

gezp commented Jun 6, 2022

while I noticed that the ComposableNode correctly gets the parameters from the .yaml file, the costmap node within doesn't.

i guess your .yaml file for costmap is incorrect, could you show your .yaml file?

@imstevenpmwyca
Copy link

while I noticed that the ComposableNode correctly gets the parameters from the .yaml file, the costmap node within doesn't.

i guess your .yaml file for costmap is incorrect, could you show your .yaml file?

ns_local:
    local_costmap:
        ros__parameters:
            update_frequency: 10.0
            publish_frequency: 10.0
            global_frame: odom
            robot_base_frame: base_footprint
            rolling_window: True
            (...)

I'm using a .yaml file that was working before converting the node to a ComposableNode.

@gezp
Copy link
Contributor

gezp commented Jun 6, 2022

i didn't use ComposableNodeContainer to lanuch ComposableNode, so i'm not sure why it didn't work. In Nav2, i launch container as a normal node, and --params-file isn't used, maybe you could try this method:

# use this method
params = os.path.join(get_package_share_directory('xxx'),  'config', 'parameters.yaml' )
_container = ComposableNodeContainer(
            xxx
            parameters = [params]
    )
# instead of this method
#_container = ComposableNodeContainer(
#           xxx
#           arguments = ['--params-file', path/to/parameters.yaml],
#    )

@imstevenpmwyca
Copy link

i didn't use ComposableNodeContainer to lanuch ComposableNode, so i'm not sure why it didn't work. In Nav2, i launch container as a normal node, and --params-file isn't used, maybe you could try this method:

# use this method
params = os.path.join(get_package_share_directory('xxx'),  'config', 'parameters.yaml' )
_container = ComposableNodeContainer(
            xxx
            parameters = [params]
    )
# instead of this method
#_container = ComposableNodeContainer(
#           xxx
#           arguments = ['--params-file', path/to/parameters.yaml],
#    )

This did the trick, thanks a lot man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants