Skip to content

Platform Agnostic Launch System

Brian Goldfain edited this page Mar 12, 2018 · 11 revisions

Introduction

Because this project supports and maintains multiple AutoRally platforms and some configuration files are hardware-specific, it is useful to automate the process of determining which compute box and chassis the system is running on. For this purpose, we have created a "platform-agnostic launch system" which detects uniquely-identifying properties of peripherals attached to the platform and sets environment variables which our system uses to load the correct configuration files for each individual platform.

Configuration Instructions

1. Udev Rules

autorally/autorally_util/99-autoRally.rules is a template for the udev rules used by the AutoRally project. You will need to follow the instructions in this file to fill in the necessary values for each device. If you are maintaining multiple platforms or spare components, you will need to duplicate some of the entries so that each device has its own entry.

Udev rules key off of properties associated with USB devices. To lookup the values of these properties for your devices, use the udevadm command.

For example, if I plug an Arduino Due into my computer, the computer might automatically assign that device to the path /dev/ttyACM0. If I then run this command:

udevadm info --query=property /dev/ttyACM0

I see the following output:

DEVLINKS=/dev/serial/by-id/usb-Arduino__www.arduino.org__Arduino_Due_Prog._Port_75439313737351F052A0-if00 /dev/serial/by-path/pci-0000:00:14.0-usb-0:4:1.0
DEVNAME=/dev/ttyACM0
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0/tty/ttyACM0
ID_BUS=usb
ID_MM_CANDIDATE=1
ID_MODEL=Arduino_Due_Prog._Port
ID_MODEL_ENC=Arduino\x20Due\x20Prog.\x20Port
ID_MODEL_ID=003d
ID_PATH=pci-0000:00:14.0-usb-0:4:1.0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_4_1_0
ID_REVISION=0001
ID_SERIAL=Arduino__www.arduino.org__Arduino_Due_Prog._Port_75439313737351F052A0
ID_SERIAL_SHORT=75439313737351F052A0
ID_TYPE=generic
ID_USB_CLASS_FROM_DATABASE=Communications
ID_USB_DRIVER=cdc_acm
ID_USB_INTERFACES=:020201:0a0000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Arduino__www.arduino.org_
ID_VENDOR_ENC=Arduino\x20\x28www.arduino.org\x29
ID_VENDOR_ID=2a03
MAJOR=166
MINOR=0
SUBSYSTEM=tty
USEC_INITIALIZED=4904433

Here I can see device information such as vendor, product, and serial number. Most devices in the udev rules template only need you to fill in the serial number, listed in these results as ID_SERIAL_SHORT.

You will have to add a udev rule for each of the following devices, using the saved serial numbers from the compute box build, or by re-querying them:

  • arGPSroverPortA
  • arGPSroverPortB
  • arGPSroverPortD
  • arGPSbasePortA
  • arGPSbasePortB
  • arXbeeNode
  • arXbeeCoordinator

If you are using Teensy-LC for the compute box and runstop:

  • arComputeBoxArduino in the Teensy Section of the AutoRally rules file
  • arRunStop in the Teensy Section of the AutoRally rules file

2. Environment Variables

When launching the platform, you will source a setup script which will setup the necessary environment variables used by AutoRally. These setup scripts all rely on the setupEnvVariables.sh script found in autorally/autorally_util.

The primary purpose of this script is to identify which chassis the compute box is mounted to (if you have built more than one), and which cameras are connected (if you keep more than one left/right pair). There are a few things you will need to edit in this file.

  • Chassis Identifiers Each chassis has an Arduino Due mounted inside of the electronics box. Each Arduino Due has a unique serial number, so we can use this number to identify which chassis the compute box is mounted to.

    In line 38, replace ARDUINO_DUE_SERIAL_NUMBER with the serial number of your Arduino Due. (Refer to 1. Udev Rules for instructions on how to find this serial number.)

    In line 40, replace CHASSIS_NAME with a unique string identifier. (For example, we use "alpha" and "beta" to distinguish our chassis.)

    If you have a second chassis, uncomment lines 41 through 43 and insert the serial number and identifier for the second chassis.

    If you have more than two chassis, simply duplicate lines 41 through 43 for each additional chassis.

  • Camera Identifiers The ROS PointGrey Camera Driver identifies cameras by their serial number, so our launch system needs to know which cameras are connected and whether or not each camera is mounted on the left or right side of the car. We have simplified this process to two arrays in the script.

    Populate the array of right camera serial numbers (rightSerials, likely line 53), with the serial numbers for all cameras which are mounted on the right side of a platform(s). For example, a populated array might look like the following:

    rightSerials=("14092823" "15290005" "14092828")
    

    Populate the array of left camera serial numbers (leftSerials, likely line 54), with the serial numbers for all cameras which are mounted on the left side of a platform(s).

    leftSerials=("14092523" "16290205" "14092877")
    

3. Setup Scripts

ROS distributed launches establish one machine as the "master" machine, where rosmaster will run and coordinate ROS communication. Environment variables are used to tell ROS which host on the network should be used as master. We have condensed the necessary environment variable settings into a single setup script for each compute box, as well as one for running all nodes on your local host.

The template for these setup scripts is autorally/autorally_util/setupEnvRemote.sh. You should duplicate this file and replace "Remote" with the a unique string identifier for each compute box.

In each of these files, replace COMPUTE_BOX_HOSTNAME with the hostname (or static IP address) of the compute box. This value will need to be replaced on lines 4 and 5. Also replace COMPUTE_BOX_USERNAME with the name of the compute box user account, on line 6.

Setup Aliases

You may find it useful to make system-wide aliases for source-ing these setup scripts. To do so, add lines like the following to your ~/.bashrc file.

alias Local="source <path to catkin workspace>/src/autorally/autorally_util/setupEnvLocal.sh"
alias COMPUTE_BOX_NAME="source <path to catkin workspace>/src/autorally/autorally_util/setupEnvCOMPUTE_BOX_NAME.sh"

4. Chassis Actuator Configuration

Every chassis has slight variations in mechanical alignment so we provide a configuration file used by the AutoRally Chassis interface, autorally_chassis, to calibrate away these differences in software. When this file is properly configured, commanding a steering value of 0 will make any AutoRally chassis drive in a straight line and allow consistent behavior across platforms for throttle and front brake response.

A configuration template file filled out with default values is located at autorally_util/config/arChassisConfig_CHASSIS_NAME.yaml

  • Copy the file into the same folder and replace CHASSIS_NAME with the name of your chassis previously chosen (for example, if your chassis name is alpha, the new file name should be arChassisConfig_alpha.yaml)
  • Throttle min, center, max - enter the throttle calibration values you saved from the ESC calibration. When copying the calibration, remove the decimal. For example 1.496ms should be entered into the chassis config file as 1496. If you didn't save these values you can read the values using Castle Link software:
    • Connect ESC to computer using Castle Link USB Adapter as described in Tuning with Castle Link section of the Castle Creations Driver's Ed Guide
    • Open Castle Link software and connect to ESC
    • Navigate to the Advanced tab and locate the Transmitter Calibration at the bottom of the tab
    • In the config file, set throttle->center to Neutral value
    • In the config file, set throttle->min to Full Reverse value
    • In the config file, set throttle->max to Full Forward value
  • Steering min, center, max - power the chassis according to the Operating Procedures, connect the chassis USB cable to a computer with a USB extension cable, open the Arduino IDE, select the appropriate board (Due) and port, and run the Serial Monitor to view the data coming from the chassis.
    • Using the transmitter in manual mode, slowly drive the vehicle back and forth and nudge the DT.1 button until the platform drives in a straight line. Look at the steering pulse width in the data coming from the chassis. This value is steering->center. Reset the transmitter to 0 throttle bias using the DT.1 button.
    • Move the steering as far left as the mechanical linkage will allow and record the steering pulse value in the Serial Monitor. This value is steering->min.
    • Move the steering as far right as the mechanical linkage will allow and record the steering pulse value in the Serial Monitor. This value is steering->max.
  • Front Brake min, center, max (if installed) - set center and min to the same value, which should apply no brake. Set max so that the brake is fully actuated, but be careful to not set to the maximum past the mechanical limits of the system to avoid damaging the brake components.