-
Notifications
You must be signed in to change notification settings - Fork 3
[Deployment] Creating ROS 2 Linux services
It's a typical requirement that for an embedded system, that it starts the required services and no further action is needed for operation and maintenance. In ROS 1, this task tended to be tedious, many wrapper packages has been developed for automatic start and maintenance.
Fortunately, ROS 2 is specifically designed for production-level embedded systems and blends well with other system-level services and applications.
It is possible to create a conventional Linux service for an ROS 2-based application. Just keep in mind: the environment variables and paths must be set explicitly. Also, ROS 2 tasks (run, launch, etc.) can be accessed on a direct path. For example, on my BeagleBone, I start SICK S300 as a systemd service, with the following configuration file (ros2 run is used in this example):
[Unit]
Description=ROS 2 SICK S300 service
[Service]
User=debian
Environment="ROS_DOMAIN_ID=0"
Environment="LD_LIBRARY_PATH=/opt/ros/robotom/lib:/opt/ros/foxy/lib"
Environment="PYTHONPATH=/opt/ros/robotom/lib/python3.7/site-packages:/opt/ros/foxy/lib/python3.7/site-packages/"
Environment="AMENT_PREFIX_PATH=/opt/ros/robotom:/opt/ros/foxy"
ExecStart=/opt/ros/foxy/bin/ros2 run sick_s300_ros2 sick_s300_driver_node --ros-args -r /scan:=/robotkocsi0/scan --params-file /opt/ros/robotom/share/sick_s300_driver/configuration/sick_s300.yaml
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=laserscanner.service
NOTE: always check your system Python version (Python 3.7 or 3.8).
Keep in mind, that these services should be placed in /lib/systemd/system/ folder. From further on, the systemd commands could be used.
As a reminder, to enable a systemd service:
sudo systemctl enable sicks300.service
To start a systemctl service:
sudo systemctl start sicks300.service
To stop a systemctl service:
sudo systemctl stop sicks300.service
To view the status of the SICK s300 service:
sudo systemctl status sicks300.service
To view the journal (the log) of each associated service:
sudo journalctl -u sicks300.service
Wiki home page: Home Quick Reference: Quick Reference
ROS2
Installation description
- 🇭🇺 ROS2 telepítése
- Linux
- Distributions
- General tricks of ROS2 installation
- General Linux tricks
- Windows
Development
- Eclipse tricks and tips
- Build system
- Launch files
- General programming techniques