ROS2 spawn controllers (launch.py)
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?
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' ])