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 for setup of the JetBot. To connect to the interface, run
    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

    ssh jetbot@<JETBOT_IP>
    
  3. Install curl on the JetBot

    sudo apt-get install curl
    
  4. Download and install the necessary setup and server files

    curl -L -O https://github.com/ScaledFoundations/GRID-playground/releases/download/v0.1.0/jetbot_server.tar.gz
    tar -xzf jetbot_server.tar.gz
    
  5. Run setup

cd jetbot_server
./setup.sh

Run the API Servers

In two separate terminal windows within jetbot_server please run:

./run_locomotion.sh

and

./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

./run_locomotion.sh & ./run_camera.sh &

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

Setting motor speeds without the API

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

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

The default camera port is 8050.

FAQs

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

Was this page helpful?