Instrumenting Linux to HATON at boot time
Change directory to /lib/systemd/system and create haton.service file by typing the following commands:
cd /lib/systemd/system
sudo nano haton.service
Inside this file insert the following input:
[Unit]
Description=Turns ROS2RPI on
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=false
ExecStart=/usr/bin/python /home/ubuntu/bin/haton.py
[Install]
WantedBy=multi-user.target
Enable haton service by:
sudo systemctl enable haton
If successful, you should see output similar to:
Created symlink /etc/systemd/system/multi-user.target.wants/haton.service → /usr/lib/systemd/system/haton.service.
The system will execute haton.py at boottime.
Instrumenting Linux to HATOFF at shutdown
Change directory to /lib/systemd/system and create hatoff.service file by typing the following commands:
cd /lib/systemd/system
sudo nano hatoff.service
Inside this file insert the following input:
[Unit]
Description=Turns ROS2RPI off
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/usr/bin/python /home/ubuntu/bin/hatoff.py
[Install]
WantedBy=multi-user.target
Enable hatoff service by:
sudo systemctl enable hatoff
If successful, you should see output similar to:
Created symlink /etc/systemd/system/multi-user.target.wants/hatoff.service → /usr/lib/systemd/system/hatoff.service.
The system will execute hatoff.py at shutdown.
Important Note
While we can leverage Python scripts to manage peripheral control at boot and shutdown, the ROSRiders driver offers a software-based approach to dynamically activate and deactivate peripherals in response to ROS node lifecycle events.
Next Chapter: Compatibility
Copyright © 2026, ACADA Robotics • https://acada.dev