Set up a robot
Run as a service
How to start ARC when the robot computer boots, read its logs, keep it online on Wi-Fi, and upgrade it.
arc run is the whole robot side. Run it under systemd so that it starts when the robot computer boots and comes back after a failure. It reconnects to the relay by itself after a network drop.
Run it once by hand first, as in the Quickstart, and set it up as a service only when that works.
Before you start
arc doctor robot.tomlhas noFAILline.- You know the user that ran
arc enroll. The service must run as that user, because the robot's identity is in that user's home directory. - You know three paths. The examples use user
robot, the Python environment/home/robot/arc_env, and the robot's files in/home/robot/robot.
The unit
Create /etc/systemd/system/arc.service with your user and paths:
[Unit]
Description=ARC robot client
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=robot
WorkingDirectory=/home/robot/robot
Environment=PYTHONUNBUFFERED=1
ExecStart=/home/robot/arc_env/bin/arc run /home/robot/robot/robot.toml
Restart=on-failure
RestartSec=10
# Stop signal goes to the main process only. It stops each arm in order.
KillMode=mixed
SyslogIdentifier=arc
[Install]
WantedBy=multi-user.targetWhat matters in it:
Useris the user that enrolled. Do not run the service as root.ExecStartuses the full path ofarcinside the Python environment, so the environment does not need to be activated. Giverobot.tomlas a full path too.KillMode=mixedlets the client stop the arms in order when the service stops. With the default mode the arm processes are signalled at the same time as the client.Restart=on-failurestarts the client again if it exits with an error. It does not restart it aftersystemctl stop.
The user must be able to write to the directory that holds robot.toml. The session logs go there, and a settings change from the console is written into robot.toml there.
CAN links at boot
For YAM and MakerMods Metal arms, both CAN links must be up, at 1 Mbit/s, before the arms can open. Bring them up at boot the way you do for the rest of your system. If the client starts before a link is up, it warns, prints the command that brings the link up, and keeps trying that arm until it opens.
Start at boot
sudo systemctl daemon-reload
sudo systemctl enable --now arcenable makes the service start at every boot. --now also starts it now. Then check it:
systemctl status arcThe robot shows as Online on the Robots page in the console once the client has connected.
| To | Run |
|---|---|
| Stop the client | sudo systemctl stop arc |
| Start it | sudo systemctl start arc |
| Restart it | sudo systemctl restart arc |
| Stop it from starting at boot | sudo systemctl disable arc |
With YAM and MakerMods Metal arms, stopping or restarting the service releases the arms: they are damped, then the motors switch off and the arms go limp. Fold or support the arms first. See release_on_exit in Configure your robot. Stopping the service is not an emergency stop.
Only one client can run per robot computer. Stop the service before you run arc run by hand or arc doctor --identify.
Logs
The client's output goes to the journal:
journalctl -u arc -f-f follows the output. journalctl -u arc -b shows everything since the last boot.
A good start has these lines, in this order, with other lines between them:
[arc] Session log:and the path of the log file.[yam-relay] config:and the table of every setting with where its value came from.[yam-relay] config sync:and what the settings sync did, on an enrolled robot.[yam-relay] checked in asand the robot id.[yam-relay] Connected to relayand the relay address.[yam-relay] Streaming. Ctrl+C to stop.
Every start also writes a session log file to logs/ next to robot.toml, named arc-<date>-<time>-<pid>.log. It holds the same output, is readable only by the service's user, and is complete after a crash. This is the file to send when you ask for help.
Old session logs are not deleted. Remove old files from logs/ from time to time, or add --no-log to ExecStart and rely on the journal alone.
Settings changes and restarts
The client reads robot.toml once, when it starts.
- After you edit
robot.toml, restart the service. - A change pushed from the console is applied at the next start. Restart the service to apply it now. The
config sync:line in the journal says what was applied.
See how settings sync.
Network watchdog
A robot computer on Wi-Fi can drop off the network and stay off: after a few failed attempts NetworkManager stops trying until someone steps in. On a computer with Wi-Fi managed by NetworkManager, the installer adds a watchdog that brings the connection back. It is a systemd timer, arc-net-watchdog.timer, separate from the arc service.
What it does:
- Every 30 seconds it pings the default gateway and a public address. The network is up when either answers.
- After 3 failed checks in a row, and again after every 3 more, it brings the Wi-Fi connection up with
nmcli connection up. - After 10 minutes of failure it reloads the Wi-Fi driver, at most once every 10 minutes.
- It never reboots the computer and never touches the CAN links.
The connection it brings up is the Wi-Fi connection that was active during the install, or the one named with --wifi-connection NAME. Install lists the installer options for it.
| To | Run |
|---|---|
| See what it sees and does | journalctl -t arc-net-watchdog -f |
| Change its settings | sudo nano /etc/arc/net-watchdog.conf |
| Turn it off | sudo systemctl disable --now arc-net-watchdog.timer |
The settings file is read on every check, so an edit applies without a restart:
| Setting | Default | Meaning |
|---|---|---|
ENABLED | 1 | 0 turns the watchdog off without removing it. |
DRY_RUN | 0 | 1 logs what it would do and changes nothing. |
WIFI_CONNECTION | empty | The NetworkManager connection to bring up. Empty: the Wi-Fi connection last seen active. |
FAIL_THRESHOLD | 3 | Failed checks in a row before the connection is brought up. |
DRIVER_RELOAD_AFTER_S | 600 | Seconds of failure before the Wi-Fi driver is reloaded. 0 never reloads it. |
DRIVER_MODULE | rtl8822ce | The kernel module of the Wi-Fi card. Change it if your card uses another one. |
Wi-Fi settings that keep a robot offline
arc doctor checks the active Wi-Fi connection and prints a WARN line, with the nmcli command that fixes it, for each of these:
| Check | Warns when | Why it matters |
|---|---|---|
wifi bssid | The connection is pinned to one access point. | NetworkManager will not use another access point of the same network when that one goes away. The watchdog cannot fix this. |
wifi retries | connection.autoconnect-retries is not 0. | With the default, NetworkManager gives up after 4 failed tries. |
wifi profiles | More than one Wi-Fi connection connects automatically. | NetworkManager can switch to another network and give up there. |
wifi powersave | Wi-Fi power saving is on. | The link pauses and drops. |
net watchdog | The watchdog is not installed, is turned off, or is in dry run. | Nothing brings Wi-Fi back after a drop. |
The fixes, with the name of your connection in place of NAME:
sudo nmcli connection modify NAME 802-11-wireless.bssid ''
sudo nmcli connection modify NAME connection.autoconnect-retries 0
sudo nmcli connection modify NAME 802-11-wireless.powersave 2For a second Wi-Fi connection that should not be used: sudo nmcli connection modify OTHER connection.autoconnect no.
Network notes
- The robot opens every connection itself: TCP port 443 and UDP ports 4433 to 4440, outbound. Nothing has to be opened inbound. How it works has the details for your network team.
- A wired connection is better than Wi-Fi. When the link is slow or drops, the arms hold their position, and the operator resumes when it is back.
- After a drop the client reconnects by itself. It checks in again before every connection, so nothing needs a restart.
Upgrade
- Run the install command again, with the same options as the first time. It downloads the new release into its own directory and upgrades the packages in the existing Python environment. See Install.
- Check the version:
/home/robot/arc_env/bin/arc --version. - Fold or support the arms, then restart the service:
sudo systemctl restart arc.
The running client keeps using the old version until the restart. robot.toml, the enrollment and the unit file are not touched by an upgrade. The Changelog lists what each release changed.
Next
If the service does not come up, or the robot stays Offline, see Troubleshooting.
NORTHSTAR