Configure an Application to Launch at Start-up#

Pre-requisites#

  • You must already know how to install (deploy) your app on the robot. See Deploying ROS 2 packages on your robot.

  • We recommend you to also read about the robot’s start-up configuration.

Adding Your Own Application to the Module Manager#

In addition to the system applications, you can easily add your own custom modules to the Module Manager. To do so, register the new module in the CMakeLists.txt of a ROS package. For example, if you have a package called hello_world with a node called hello_world_node, add the following lines to 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 and would look something like this:

hello_world:
  run: "hello_world hello_world_node"

Then, deploy the package to the robot as described in Deploying ROS 2 packages on your robot. After a reboot of the robot the module is available and can be started using:

pal module start hello_world

Adding Your Own Application to the Startup Sequence#

To start the module at startup, a module set has to be created. Register a new module set in the CMakeLists.txt of the hello_world ROS package:

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 something like this:

custom_modules:
  - hello_world

Then, deploy the package to the robot as described in Deploying ROS 2 packages on your robot. After a reboot of the robot the module hello_world starts automatically.

Customizing an Existing Application in the Startup Sequence#

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

pal module info foo_module

In this example the filename is 00_foo_module.yaml.

Then, register a new module in the CMakeLists.txt of a ROS package. The new module file should be placed in the module/ directory of the package and would look something like this:

foo_module:
  run: "foo_package different_node"

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

Note

The registered modules are sorted based on their filename in lexicographical order. Take this into account when naming the module file. A module file named 00_foo_module.yaml will be overwritten by a module file named 10_foo_module.yaml. To overwrite bar_module.yaml, the new module file should be named bar_module_01.yaml.

Finally, deploy the package to the robot. After a reboot, the updated version of foo_module is used. To verify, run:

pal module info foo_module

Disabling an Existing Application in the Startup Sequence#

To disable a module in the startup sequence, use the Module Manager command line interface:

pal module disable foo_module   # disable a module
pal module enable foo_module    # re-enable a module

Then, to apply the changes, restart the startup sequence:

pal module_manager restart

See Also#