> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# JetBot Deployment

> Learn how to deploy the GRID API servers on a JetBot

# Running the API Servers on JetBot

The JetBot natively does not support port forwarding or an API server. The intended use is to use a jupyter notebook online and run the code locally on the JetBot. To better utilize grid functionality, we want to run all of the code locally and communicate with the JetBot remotely. To do this we have created scripts to run two servers that run locally on the JetBot.

### Setting up the JetBot

1. Connect the JetBot to the internet. This can be done in a variety of ways.

   1. We used [this tutorial](https://www.waveshare.com/wiki/JetBot_AI_Kit) for setup of the JetBot. To connect to the interface, run

   ```bash theme={null}
   sudo nmcli device wifi connect <WIFI_NAME> password <WIFI_PASSWORD>
   ```

   1. Once you are set up, the IP address of the JetBot should appear on the LCD screen on the base.
   2. the default password is jetbot

2. SSH into the JetBot

   ```python theme={null}
   ssh jetbot@<JETBOT_IP>
   ```

3. Install curl on the JetBot

   ```bash theme={null}
   sudo apt-get install curl
   ```

4. Download and install the necessary setup and server files

   ```bash theme={null}
   curl -L -O https://github.com/GenRobo/GRID-playground/releases/download/v0.1.0/jetbot_server.tar.gz
   tar -xzf jetbot_server.tar.gz
   ```

5. Run setup

```bash theme={null}
cd jetbot_server
./setup.sh
```

### Run the API Servers

In two separate terminal windows within `jetbot_server` please run:

```bash theme={null}
./run_locomotion.sh
```

and

```bash theme={null}
./run_camera.sh
```

to start the locomotion and camera servers on the JetBot.

Alternatively, to only use one window and keep the servers in the background run

```python theme={null}
./run_locomotion.sh & ./run_camera.sh &
```

The JetBot is now ready to interface with the GRID API!

### Setting motor speeds without the API

```python theme={null}
requests.get(f"{<url>}:{<locomotion_port>}/set_motors", params={"left_speed": left_speed, "right_speed": right_speed})
```

The default locomotion port is 8040.

### Getting camera images without the API

```python theme={null}
response = requests.get(f"{<url>}:{<camera_port>}/get_image")
```

The default camera port is 8050.

## FAQs

```bash theme={null}
AttributeError: module 'asyncio' has no attribute 'run'
```

* Python \< 3.7 does not have access to `run`
  * Upgrade your python version to 3.11 if possible
