diff --git a/anchor.service b/anchor.service new file mode 100644 index 0000000..7b95062 --- /dev/null +++ b/anchor.service @@ -0,0 +1,14 @@ +[Unit] +Description=Autostart the anchor node for controlling the rover and its modules +After=systemd-user-sessions.service +Requires=systemd-user-sessions.service + +[Service] +ExecStart=/home/clucky/auto_start/auto_start_anchor.sh +Restart=always +RestartSec=5 +User=clucky +Environment=PYTHONUNBUFFERED=1 + +[Install] +WantedBy=multi-user.target diff --git a/auto_start/auto_start_anchor.sh b/auto_start/auto_start_anchor.sh new file mode 100755 index 0000000..724062c --- /dev/null +++ b/auto_start/auto_start_anchor.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Wait for a network interface to be up (not necessarily online) +while ! ip link show | grep -q "state UP"; do + echo "[INFO] Waiting for active network interface..." + sleep 1 +done + +echo "[INFO] Network interface is up!" + +# Your actual ROS node start command goes here +echo "[INFO] Starting ROS node..." + +# Source ROS 2 Humble setup script +source /opt/ros/humble/setup.bash + +# Source your workspace setup script +source /home/clucky/rover-ros2/install/setup.bash + +# CD to directory +cd /home/clucky/rover-ros2/ + +# Launch the ROS 2 node with the desired mode +ros2 launch rover_launch.py mode:=anchor diff --git a/auto_start/auto_start_core_headless.sh b/auto_start/auto_start_core_headless.sh new file mode 100755 index 0000000..b59126b --- /dev/null +++ b/auto_start/auto_start_core_headless.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Wait for a network interface to be up (not necessarily online) +while ! ip link show | grep -q "state UP"; do + echo "[INFO] Waiting for active network interface..." + sleep 1 +done + +echo "[INFO] Network interface is up!" + +# Your actual ROS node start command goes here +echo "[INFO] Starting ROS node..." + +# Source ROS 2 Humble setup script +source /opt/ros/humble/setup.bash + +# Source your workspace setup script +source /home/clucky/rover-ros2/install/setup.bash + +# CD to directory +cd /home/clucky/rover-ros2/ + +# Launch the ROS 2 node +ros2 run core_pkg headless diff --git a/core_headless.service b/core_headless.service new file mode 100644 index 0000000..035ba56 --- /dev/null +++ b/core_headless.service @@ -0,0 +1,14 @@ +[Unit] +Description=Autostart headless core node for controlling the rover without a base station +After=systemd-user-sessions.service +Requires=systemd-user-sessions.service + +[Service] +ExecStart=/home/clucky/auto_start/auto_start_core_headless.sh +Restart=always +RestartSec=10 +User=clucky +Environment=PYTHONUNBUFFERED=1 + +[Install] +WantedBy=multi-user.target