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
:
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 create a new module set that
overwrites the module set that contains the module you want to disable. To do so,
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:
robot_modules:
- module_1
- module_2
- custom_module_3
The Module Manager will sort all registered modules sets based on their filename in lexicographical order.
This means to overwrite the existing module set in 00_robot_modules.yaml
we have to register the new module set
in a file with a name that comes after 00_robot_modules.yaml
, for example 10_robot_modules.yaml
.
Note
The registered module sets are sorted based on the filename in lexicographical order.
Take this into account when naming the file of the module set. A module set file named
00_robot_modules.yaml
will be overwritten by a module set file named
10_robot_modules.yaml
. To overwrite the module set in robot_modules.yaml
the new module set file should be named robot_modules_01.yaml
.
See also#
application-management