Run the whole robot from one launch file and one boot-time unit
hermes_bringup starts the face, camera, face detector and audio levels from one launch file with their parameters in robot.yaml, each node its own respawned process, the face first and the others after start_delay. robot.service runs it at boot, so everything is ROS and the face is up whenever the robot is powered. Reboot-tested: all services and nodes return by themselves, the face draws at about 28 s on the boot clock, the mic gain survives, nothing throttles. Cut the CPU: the camera runs at 15 fps (20% of a core, vs 40% at 30), and the detector went from 131% to 40% by pinning OpenCV to one thread (its DNN burns 3-4x its elapsed time across cores), decoding the JPEG at half size, and re-identifying a tracked face at most once a second. The audio scope is published only while someone is speaking or listening. A standalone face unit that skipped `ros2 launch` saved only 3.7 s and was dropped: the owner prefers everything in ROS and is fine with up to a minute. trim-boot.sh disables the unused snapd and ModemManager. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFN8nRRCiDiMN7ChBpHJhs
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Make the face start whenever the robot is powered. Run as root from this directory. Re-runnable.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
install -m 644 robot-cpu-performance.service /etc/systemd/system/
|
||||
install -m 644 robot-face.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now robot-cpu-performance.service
|
||||
systemctl enable robot-face.service
|
||||
systemctl restart robot-face.service
|
||||
sleep 8
|
||||
systemctl --no-pager --lines=4 status robot-face.service
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
# One unit runs the whole robot (face, camera, vision, audio) via the hermes_bringup launch file, so
|
||||
# the face is up whenever the robot is powered, and everything is ROS. Each node is its own process
|
||||
# and is respawned by the launch file, so one crash cannot take the others down.
|
||||
# Replaces the earlier standalone robot-face.service. Run as root from this directory. Re-runnable.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
install -m 644 robot-cpu-performance.service robot.service /etc/systemd/system/
|
||||
systemctl disable --now robot-face.service 2>/dev/null || true
|
||||
rm -f /etc/systemd/system/robot-face.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now robot-cpu-performance.service
|
||||
systemctl enable robot.service
|
||||
systemctl restart robot.service
|
||||
echo "robot.service enabled and started"
|
||||
@@ -1,16 +0,0 @@
|
||||
[Unit]
|
||||
Description=Robot face (hermes_face): the display is always on while the robot is powered
|
||||
After=local-fs.target robot-cpu-performance.service
|
||||
|
||||
[Service]
|
||||
User=hermes
|
||||
# lgpio (the GPIO backend for the display) drops a notification pipe, .lgd-nfy*, in its working
|
||||
# directory, which must be writable: systemd's default, /, is not.
|
||||
RuntimeDirectory=robot-face
|
||||
WorkingDirectory=/run/robot-face
|
||||
ExecStart=/bin/bash -c 'source /home/hermes/robot-env.sh && exec ros2 run hermes_face face_node'
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,20 @@
|
||||
[Unit]
|
||||
Description=Robot (hermes_bringup): face, camera, face detection, audio levels
|
||||
# Nothing here needs the user session: audio_state retries until the user's PipeWire is up.
|
||||
After=local-fs.target robot-cpu-performance.service robot-firewall.service
|
||||
|
||||
[Service]
|
||||
User=hermes
|
||||
# lgpio (the display's GPIO backend) drops a notification pipe in its working directory, which must
|
||||
# be writable: systemd's default, /, is not.
|
||||
RuntimeDirectory=robot
|
||||
WorkingDirectory=/run/robot
|
||||
# audio_state reaches the user's PipeWire through this
|
||||
Environment=XDG_RUNTIME_DIR=/run/user/1000
|
||||
ExecStart=/bin/bash -c 'source /home/hermes/robot-env.sh && exec ros2 launch hermes_bringup robot.launch.py'
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
TimeoutStopSec=20
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Switch off boot-time services a headless robot does not use. They cost ~9 s of CPU and a few
|
||||
# seconds of wall time at every boot, competing with the face for the CPU and the SD card.
|
||||
# snapd: no snaps are installed. ModemManager: no modems. Run as root. Re-runnable; undo with
|
||||
# `systemctl unmask ... && systemctl enable ...`.
|
||||
set -euo pipefail
|
||||
systemctl disable --now snapd.service snapd.socket snapd.seeded.service snapd.apparmor.service 2>/dev/null || true
|
||||
systemctl mask snapd.service snapd.socket 2>/dev/null || true
|
||||
systemctl disable --now ModemManager.service 2>/dev/null || true
|
||||
echo "trimmed: snapd, ModemManager"
|
||||
Reference in New Issue
Block a user