BotWheel Explorer

Hardware Build

TODO

ODrive Configuration

  1. Lay your robot upside down on the ground so the wheels can spin freely in the air.

  2. Connect the left wheel ODrive with your computer using a USB cable.

  3. Go to https://gui.odriverobotics.com/configuration and configure the ODrive according to the screenshots. All values that you need to change are highlighted below. You can leave all other values at their default (some fields are left empty).

    ../_images/botwheel-config1.png
    ../_images/botwheel-config2.png
    ../_images/botwheel-config3.png

    Make sure to enable the GUI’s watchdog feeder (expand the bottom bar to reveal this switch). Later, when we run the robot, the Raspberry Pi will take over this task.

    ../_images/gui-watchdog-switch.png

    On the last wizard page, click all action buttons in order.

    ../_images/botwheel-config4.png
  4. Next, we will set the CAN configuration in the Inspector tab. Click on Inspector, search for “can” and drag the four highlighted elements into the Controls column.

    Set them as shown below and then press “Call” on save_configuration (by default this can be found at the end of the list).

    Note

    If you come to this step the second time (for the right ODrive), the controls will show red because they are bound to the left ODrive. Press “Bind Controls” in the tree view to rebind them to the right ODrive.

    axis0.config.can.node_id = 0 (left ODrive) or 1 (right ODrive)
    axis0.config.can.temperature_msg_rate_ms = 10
    axis0.config.can.bus_voltage_msg_rate_ms = 10
    axis0.config.can.torques_msg_rate_ms = 10
    
    ../_images/gui-can-config-annotated.png
  5. To verify that your ODrive is configured correctly, connect the battery to the ODrive. Go to the Dashboard and click on the Power button (you may need to click “Clear Errors” first). When you drag the velocity slider, the wheel should start spinning with the commanded velocity.

    ../_images/gui-dashboard-annotated.png
  6. Repeat steps 2 through 5 with the right wheel ODrive. Everything will be identical, except for the node_id in step 4.

  7. Configure gpio10 and an Estop using the min_endstop. Like before, you can use the Inspector tab for this.

    <odrv>.axis0.min_endstop.config.gpio_num = 10
    <odrv>.axis0.min_endstop.config.enabled = True
    <odrv>.axis0.min_endstop.config.is_active_high = False
    <odrv>.save_configuration()

Raspberry Pi Setup

  1. Install an operating system on your Raspberry Pi’s SD card. You can use the Raspberry Pi Imager for this. We recommend the following settings:

    • Operating System: Raspberry Pi OS Lite (64-bit)

    • Advanced settings (⚙ icon):

      • Set the hostname and note it down for later

      • Enable SSH and use password authentication

      • Set username and password, and note them down for later

      • Configure wireless LAN

    ../_images/rpi-advanced-settings.png

    If you’re an advanced user, feel free to use the settings that are best for you.

  2. After writing the image to the SD card, insert it into the Raspberry Pi and power it up. It should automatically join your Wi-Fi network.

  3. On your main computer, log into your Raspberry Pi remotely via SSH.

    ssh username@odrive-cart.local
    

    All subsequent instructions are meant to be run via SSH on the Raspberry Pi.

  4. Enable the CAN hat:

    Open the /boot/config.txt with

    sudo nano /boot/config.txt
    

    At the bottom of the file, add the following:

    link to product

    dtparam=spi=on
    dtoverlay=mcp251xfd,spi0-0,oscillator=40000000,interrupt=25 # configure can0 interface
    dtoverlay=mcp251xfd,spi1-0,oscillator=40000000,interrupt=24 # configure can1 interface
    dtoverlay=spi1-3cs
    

    Reboot the device for these changes to take effect.

    sudo reboot
    
  5. Install dependancies:

    sudo apt -y install git can-utils python3-can python3-websockets python3-qrcode
    
  6. Clone the repository that contains the control script:

    git clone https://github.com/odriverobotics/ODriveResources.git
    

Running the example

This section assumes you’re still logged into the Raspberry Pi via SSH.

  1. When the Raspberry Pi starts up, the CAN interface is down by default. Bring it up with this command:

    sudo ip link set can0 up type can bitrate 250000
    
  2. Launch the control script:

    python3 ODriveResources/examples/odrive-cart/bot_ctrl.py
    
  3. The control script will show a QR code in the terminal. You can scan this with your phone or copy & paste the address into the browser address bar on your computer. The address points to a webpage that serves as a remote control for the robot. Note that your remote control (phone or computer) must be in the same network.

    ../_images/botwheel-demo-launch.png
  4. On the remote control page, press “Drive”

  5. You can now use your mouse/touch, keyboard, joystick or IMU (on a smartphone) to drive the robot around. Press “Settings” for more info.

    The blue circle indicates the commanded velocity and turn rate. The green ball indicates the actual velocity and turn rate, based on the actual velocity feedback from BotWheels.

    ../_images/botwheel-demo-phone.jpg

    Note

    To enable IMU support, some browsers require the page to be served over an encrypted (SSL) connection. See step 2 for details.

Running the example on startup

After initial testing (section above), you probably want the control script bot_ctrl.py to start automatically when you power up the robot.

To achieve this, run the following commands on the Raspberry Pi:

sudo cp ODriveResources/examples/odrive-cart/bot_ctrl.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable bot_ctrl.service
sudo systemctl start bot_ctrl.service

Note

Open bot_ctrl.service in a file editor to see if the arguments are right for you.

This will create a systemd service for the control script, enable it to start on system start, and also start it right away. If the script exits for any reason, systemd will restart it.

To view the connection URL and QR code:

sudo journalctl -xe

To view the status and the most recent log output, run

sudo systemctl status bot_ctrl.service

Example Code

TODO: add explanation about the interesting parts of the example code.

../_images/botwheel-demo-data-diagram.png