0
$\begingroup$

Rosanswers logo

Hi,

For my mecanum robot, i'm trying to build everything using ROS2. Currently i'm at the point where i implemented a hardware interface class for controlling the motors and reading the sensors.

Following the documentation on ros2_control github, i'm at the point where i need to run "ros2 contol load_start_controller", where i'm testing with the diff_drive_controller before implementing a custom controller for mecanum drive.

I can't find any information on how to automatically spawn the controller in ROS2 so i don't have to run the ros2 control load_start_controller every time i launch my robot nodes.

Can the controller be defined in the URDF as we do with hardware interface or can the controller be spawned trough python launch files?


Originally posted by RandyD on ROS Answers with karma: 161 on 2021-03-27

Post score: 0


Original comments

Comment by shonigmann on 2021-03-30:
You certainly can start the controller in your launch file. At the very least, anything that can be run from the commandline can be run from a python launch file by adding an ExecuteProcess action to your launch description. Something to the effect of:

return LaunchDescritpion([... ,ExecuteProcess(
        cmd=['ros2', 'control', 'load_start_controller', 'differential_drive_controller'],
        output='screen'
    ])
$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

To start a controller immediately you should add a spawner node to your launch file. You can even control if controller should be started or only configured on the beginning using the flag "--stoppped" to only load and configure a controller.

joint_state_broadcaster_spawner = Node(
    package="controller_manager",
    executable="spawner",
    arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
)

Originally posted by destogl with karma: 877 on 2022-01-17

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.