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
, 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
would look something like this:
hello_world:
run: "hello_world hello_world_node"
Then, you can 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 the command pal module start hello_world
.
Adding your own application to the startup sequence of the robot#
To start the module at startup a module set has to be created. To do so, register a new module
set in the CMakeLists.txt
of hello_world
ROS package:
if(pal_module_cmake_FOUND)
pal_register_module_sets(
module/custom_module_set.yaml
)
endif()
The module file custom_module_set.yaml
should be placed in the module/
directory of the package
would look something like this:
custom_modules:
- hello_world
Then, you can 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
start automatically.
Customizing an existing application in the startup sequence of the robot#
To customize an existing application in the startup sequence of the robot,
you can create a new module that overwrites the existing module. To do so,
first retrieve the filename of the existing module by running the
command 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 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 when
naming the file of the module. A module file named 00_foo_module.yaml
will be overwritten by a module file named
10_foo_module.yaml
. To overwrite the module bar_module.yaml
the new module file should be named bar_module_01.yaml
.
Finally, deploy the package to the robot as described in Deploying ROS 2 packages on your robot.
After a reboot of the robot the updated version of the foo_module
is used. To check this run the command pal module info foo_module
.
Disable an existing application in the startup sequence of the robot#
To disable a module in the startup sequence of the robot, you can use the command line interface of the Module Manager.
To disable a module, run the command
pal module disable foo_module
.To enable a module, run the command
pal module enable foo_module
.
Then, in order to apply the changes you have to restart the startup sequence of the robot by running the command
pal module_manager restart
.