BehaviorTree / BehaviorTree.ROS2

BehaviorTree.CPP utilities to work with ROS2
Apache License 2.0
144 stars 59 forks source link

Behavior Tree Goal on launch on TreeExecutionServer #70

Closed marj3220 closed 4 months ago

marj3220 commented 4 months ago

It would be useful to launch a tree with the TreeExecutionServer from it's launch. This would bypass the secondary node that needs to be created to send a goal to the TreeExecutionServer.

marj3220 commented 4 months ago

This was actually already possible. As referenced by @MarqRazz: https://github.com/BehaviorTree/BehaviorTree.ROS2/pull/71#issuecomment-2111379917

Why not just call the Server from your launch file?

Here is an example on calling a service from a python launch file.

from launch.substitutions import FindExecutable
from launch.actions import ExecuteProcess

...

ld.add_action(
    ExecuteProcess(
        cmd=[[
            FindExecutable(name='ros2'),
            " service call ",
            "/namespace/service_to_call ",
            "example_msgs/srv/ExampleMsg ",
            '"{param_1: True, param_2: 0.0}"',
        ]],
        shell=True
    )
)