5. The services
Each host runs its part of the stack as a systemd service under a watchdog: it starts at boot, restarts when something it depends on goes away, and is never given up on.
5.1 Install
The same on each host:
cd ~/x30_ws/src/x30_ros/tools
sudo bash x30_host.sh installThe role comes from the host’s address: navigation on .106, perception on .105. A role named for the other host is refused, and a service an older x30_host.sh put on the wrong host is removed with its settings. This writes /etc/systemd/system/x30-<role>.service and its settings file /etc/x30/<role>.env (mode 600: root and ysc only), and enables the service. Run it with the robot up: the navigation host’s service is ordered after Deep Robotics’ services and the one running the ROS master, as it finds them. At the end it prints the next commands: the settings to edit, then the service’s start and its log.
An existing settings file is kept
install never overwrites /etc/x30/<role>.env. On a robot installed before version 0.19, add the line X30_NETRA_TOKEN= to /etc/x30/navigation.env yourself.
5.2 Settings
/etc/x30/navigation.env (shell words: a quoted value stays one argument; NETRA’s arguments join X30_LAUNCH_ARGS in Chapter 7):
X30_LAUNCH_ARGS="site:=gardu controller:=neupan"
# only for controller:=neupan
X30_PYTHON=/home/ysc/x30_ws/neupan/bin/python
X30_TELEOP_TOKEN=<the handheld's token>
X30_NETRA_TOKEN=<CC_TOKEN from NETRA>
# each node's JSON lines log
# X30_LOG_DIR=/home/ysc/x30/logs
# ROS's own logs, pruned at every start (MB)
# X30_ROS_LOG_MB=2048/etc/x30/perception.env:
# e.g. hikmicro_host:=192.168.1.64 hertzino_host:=192.168.2.204
X30_LAUNCH_ARGS=""
HIKMICRO_PASSWORD=<thermal camera admin password>
HERTZINO_PASSWORD=<acoustic camera password>A comment goes on a line of its own
systemd reads no comment after a value: whatever follows a value on its line becomes part of it, the comment’s words in a token, a password or the launch arguments.
5.2.1 Launch arguments of the navigation host
| Argument | Default | What it does |
|---|---|---|
site | last run’s | the site at start (routes, tags, inspection points), created when missing |
sites_dir | ~/x30/map | where the sites are |
controller | holonomic | the path controller; neupan needs its venv and X30_PYTHON |
health, inspection | true | the health monitor; the inspection at the stop points |
bridge | true | the H12 gateway on UDP 9870 |
netra_url, netra_robot_id | empty | NETRA’s address and this robot’s ID; the uplink runs when netra_url is set |
reports_dir | ~/x30/reports | the inspection reports |
lidar_frame, lidar_pose | livox_frame, 0s | the frame of /livox/lidar and its mount (Section 8.2) |
odometry_method | fast_lio | external when another estimator publishes /Odometry |
blackbox, blackbox_dir | true, ~/x30/blackbox | the rolling rosbag of the last 3 h |
5.3 Start, stop, watch
The navigation host first: the perception host uses its master. On .106:
sudo systemctl restart x30-navigationThen on .105:
sudo systemctl restart x30-perceptionThe watchdog’s status line, the log and the check, here on .106 (x30-perception on .105):
systemctl status x30-navigation
journalctl -u x30-navigation -f
bash ~/x30_ws/src/x30_ros/tools/x30_host.sh checkx30_host.sh check tells this host’s role and address, whether the other host answers, the ROS master and every registered node from here, the two clocks, and on the navigation host that Deep Robotics’ autonomy is off, on the perception host the cameras’ ports.
5.4 What the watchdog does
The service’s main process starts the host’s launch file, tells systemd it is ready once the master and the critical nodes answer (on the navigation host: the driver, the control mux, the LiDAR scans and the path follower), then checks them every 5 s. The service restarts when:
the master restarted (its nodes are lost with it; the perception host follows this way);
the master or a critical node stays away longer than 45 s;
the start takes longer than 4 min, or roslaunch exits;
the watchdog itself hangs (systemd’s
WatchdogSec=60).
Meanwhile the robot stands: the control mux stops a command that is not renewed, and the motion host stops taking commands without the driver’s heartbeat. On the navigation host the watchdog also turns off, every 30 s, whatever of Deep Robotics’ autonomy one of its services started again late, and names it in the journal.
5.5 Run by hand
For a test without the services (stop them first), on each host this shell’s ROS network:
eval "$(bash ~/x30_ws/src/x30_ros/tools/x30_host.sh env)"Then on .106:
roslaunch x30_bringup navigation_host.launch site:=garduAnd on .105:
roslaunch --wait x30_bringup perception_host.launch