# Running the Simulator

Drive the Bolt in CARLA with the same ROS 2 topics as the real car. CARLA runs on the sim server; you work from your
Coder workspace.

!!!info Before you start
- You need an **AVC Bolt** workspace on [Coder](http://35.8.177.167:7080) (on campus or the VPN).
- Your workspace clones `bolt-ros2` on its first start. If `~/bolt-ros2` is missing, add your Coder SSH key
  (Coder → Account → SSH Keys) to [GitLab](https://www.gitlab.msu.edu/-/user_settings/ssh_keys), then run `bolt-clone`.
!!!

## 1. Open your workspace

In Coder, open **VS Code** and **Desktop**. rviz shows up in the Desktop tab.

## 2. Start the car

In a VS Code terminal:

```bash
uv run ~/bolt-ros2/sim/spawn_bolt.py --autopilot
```

This puts the Bolt and all its sensors in CARLA. Leave it running; **Ctrl+C** removes the car.
Drop `--autopilot` if you want to drive it yourself.

## 3. Start ROS and rviz

In a second terminal:

```bash
cd ~/bolt-ros2 && docker compose run --rm dev
```

This opens a shell in the bolt-ros2 container and builds the code (the first time takes a few minutes). Then:

```bash
ros2 launch bolt2_launch bolt.launch.py mode:=sim rviz:=true
```

The sensors appear in rviz on the Desktop tab. To stop, press **Ctrl+C** in both terminals.

## What you get

The sim publishes the same topics and TF as the car, so your code works on both:

| Sensor | Topic |
|---|---|
| Lidars | `/sensors/lidar/<name>/velodyne_points`, `/sensors/lidar/ouster/points` |
| Cameras | `/sensors/cameras/<name>/image_raw` |
| Radars | `/sensors/radar/<name>/points` |
| GNSS / IMU | `/sensors/gnss/navsatfix`, `/sensors/gnss/imu` |
| Sim time | `/clock` |

Sensor positions come from `vehicle/src/bolt2_launch/cfg/sensors.yaml`. On the car, the same launch file runs the real
drivers: `mode:=real`.

## Troubleshooting

| Message | Fix |
|---|---|
| `The sim is already in synchronous mode` | Someone else is running the car. The sim is shared, so only one at a time. |
| `A vehicle with ros_name 'bolt' is already in the sim` | A run didn't clean up. Add `--replace` to take over. |
| Nothing in rviz | Check step 2 is still running, and that you only have one Desktop tab open. |
