# Robot Operations

Startup, shutdown, reboot, emergency shutdown and routine maintenance for the robot.

## Step 1: Robot Startup Procedure

Launch the robot’s core systems and verify that topics and nodes are running correctly.

After configuring your Raspberry Pi and flashing the firmware, you can start the robot’s onboard ROS 2 stack.  This module describes the launch command and how to verify that all expected topics and nodes are active.

```bash
ros2 launch common_platform launch_robot.launch.py
```

```bash
ros2 topic list
```

```bash
ros2 node list
```

Examine the output to confirm that sensor topics like `/scan` and `/camera/image_raw` are present and that nodes such as `rplidar_node`, `camera_node` and `micro_ros_agent` are running.  If any expected topics or nodes are missing, troubleshoot by reviewing earlier setup steps.

## Step 2: Shutdown Procedure

Properly shut down the robot by stopping all running ROS processes and powering off the Raspberry Pi.

To safely power off the robot, you should first stop any running ROS nodes and processes, then issue a shutdown command.  Abruptly disconnecting power can corrupt the filesystem or leave hardware in an unsafe state.

```bash
sudo shutdown now
```

## Step 3: Reboot Procedure

Restart the Raspberry Pi to apply configuration changes or reset the system.

Rebooting the robot is useful after editing configuration files or applying firmware updates.  A reboot cleanly shuts down processes and restarts the operating system.

```bash
sudo reboot
```

## Step 4: Emergency Shutdown

Safely stop the robot in emergency situations by halting software and cutting power if necessary.

In an emergency—such as a runaway robot or hardware failure—you must quickly stop all software and power down the system to prevent damage or injury.  Follow these steps:

```bash
sudo shutdown -h now
```

If software commands fail or the system is unresponsive, cut power by switching off the power supply or unplugging the battery.  After addressing the issue, inspect hardware and restart with the normal procedure.

## Step 5: Routine Maintenance

Perform regular checks on sensors, motors and software to ensure reliable operation of the robot.

Consistent maintenance prolongs the life of your robot and catches issues before they become critical.  This module outlines daily and weekly checks you can perform using ROS 2 commands.

```bash
ros2 launch common_platform launch_robot.launch.py
```

```bash
ros2 topic echo /${ROS_NAME}/scan
```

```bash
ros2 topic echo /${ROS_NAME}/camera/image_raw
```

```bash
ros2 topic echo /${ROS_NAME}/imu/data
```

```bash
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.1, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}"
```

Observe the outputs for each sensor to ensure data is being published.  The `/cmd_vel` publication should cause the robot’s wheels to turn briefly—ensure the workspace is clear before running this test.  Schedule deeper maintenance (tightening hardware, inspecting cables, updating packages) weekly or monthly as recommended by the program.

