Customize the robot start-up#

This tutorial uses the module manager CLI.

Add your application to the Module Manager#

You can add your own custom modules to the Module Manager. You have to register the new module in the CMakeLists.txt of a ROS2 package. For example, if you have a package called hello_world, with a node called hello_world_node, you can add the following lines to the CMakeLists.txt:

find_package(pal_module_cmake QUIET)

if(pal_module_cmake_FOUND)
  pal_register_modules(module/hello_world.yaml)
endif()

The module file hello_world.yaml should be placed in the module/ directory of the package. It would look like this:

hello_world:
  run: "hello_world hello_world_node"

When the package containing this is deployed on the robot, the module will be available after rebooting the robot. To start it, do

pal module start hello_world

Add to the start-up#

To start the module at startup a module set has to be created. To do so, you have to register a new module set in the CMakeLists.txt of hello_world ROS2 package by adding:

find_package(pal_module_cmake QUIET)

if(pal_module_cmake_FOUND)
  pal_register_module_sets(module/custom_module_set.yaml)
endif()

The module set file custom_module_set.yaml should be placed in the module/ directory of the package, and would look like this:

custom_modules:
   - hello_world

When such a package would be deployed in the robot, it would run automatically at startup after a reboot of the robot.

Customize a startup module#

To customize an existing application in the startup sequence of the robot, you can create a new module that overwrites an existing module. First, retrieve the filename of the existing module:

pal module info foo_module

Say the filename is 00_foo_module.yaml. Register a new module in the CMakeLists.txt of your ROS 2 package. The new module file should be placed in the module/ directory, looking as follows

foo_module:
  run: "foo_package different_node"

The Module Manager will sort all registered modules based on their filename in lexicographical order. This means to overwrite the existing module in 00_foo_module.yaml we have to register the new module in a file with a name that comes after 00_foo_module.yaml, for example 10_foo_module.yaml.

!!! note The registered modules are sorted based on the filename in lexicographical order. Take this into account:

- `00_foo_module.yaml` will be overwritten by `10_foo_module.yaml`.
- To overwrite `bar_module.yaml`, the new module should be named `bar_module_01.yaml`.

If such a package is deployed, after a reboot the updated version of the foo_module would be the one started. Check this by doing:

pal module info foo_module

Disable a startup module#

To disable or enable modules, use the Module Manager CLI:

  • Disable modules:

pal module disable foo_module bar_module
  • Enable modules:

pal module enable foo_module bar_module

After that, restart the startup sequence to apply changes:

pal module_manager restart