-
Notifications
You must be signed in to change notification settings - Fork 229
Platform Agnostic Launch System
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.
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
.
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 two 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.
In line 53, populate the array of serial numbers with the serial numbers for all cameras which are mounted on the right side of a platform. For example, a populated array might look like the following:
rightSerials=("14092823" "15290005" "14092828")
In line 54, populate the array of serial numbers with the serial numbers for all cameras which are mounted on the left side of a platform.
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.
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"