Before we can run RACECAR/J, we need to program the electronic speed controller, called a VESC, for the motor and steering. Looky here:
Note: Newer versions of RACECAR J use a VESC 6. Please see the article RACECAR/J – Programming the Electronic Speed Controller.
For RACECAR/J, we replace the stock TRAXXAS ESC with Vedder Electronic Speed Controller (VESC) version 4.12 compatible hardware. The major reason for the change is to gain full control of the robot at low speeds. The stock ESC puts the minimum vehicle speed at around 6 mph. Another reason is that the VESC is open source, which allows the curious to explore the motor controller implementation.
Note: VESC is now a registered trademark. There are several manufacturers who build VESC compatible hardware, but expect different names since the registration. There is a new version of VESC hardware (6.4), but for the purposes of the this article, we will use the term VESC to indicate version 4.12 compatible hardware.
Architecturally, the VESC has a STM32 ARM Cortex processor. The STM32 runs ChibiOS, a real-time operating system. The default firmware flashed on the VESC-X is ‘Servo-in’, which allows a remote controller to set the motor speed. For the RACECAR/J application, the VESC servo port needs to be programmed as ‘Servo-out’, which allows commands to be sent to the robot steering servo.
Fortunately there is a compiled binary of the version of the VESC firmware that includes the Servo-out setting. We can flash the STM32 directly using a program called ‘bldc-tool’. BLDC is an acronym for BrushLess DC motor.
Once the bldc-tool loads the servo-out firmware on to the VESC, we then load a configuration file which matches the VESC configuration to control a TRAXXAS Velineon 3500 motor.
- There are pre-compiled versions of the BLDC Tool available for Macintosh and Windows machines (see vedder.se for more information).
- The VESC firmware and configuration files for hardware configuration are available in the RACECAR/J vesc-firmware repository.
- If you are interested in building the VESC firmware from source, you can compile it from the bldc firmware source tree on Github.
- The full RACECAR/J Kit contains an Enertion Boards FOCBOX, VESC 4.12 compatible hardware. The FOCBOX is programmed before shipping from RACECAR/J. This article is useful if at some point you need to reprogram the FOCBOX.
- L4T 28.1 does not have a driver for ACM USB devices, such as the VESC. This article covers how to install a cdc-acm module for the Jetson if you have not already installed one.
- This article covers installing and running the BLDC Tool on a Jetson TX Dev Kit running L4T 28.1. To build on a Linux x86 machine (like the one used to flash the Jetson), use the installBLDCToolHost.sh script
The RACECAR/J account on Github contains a repository named installBLDCTool. To build the BLDC Tool:
$ git clone https://github.com/racecarj/installBLDCTool
$ cd installBLDC
This will install prerequisites for the building, build the bldc-tool from source code, and download the VESC firmware and RACECAR/J motor configuration files. The VESC firmware and RACECAR motor configuration files are downloaded from the Github RACECAR/J vesc-firmware repository.
The BLDC Tool application is in the ~/bldc-tool directory.
A USB cable communicates motor speed and steering angle information between the Jetson and the VESC. The TRAXXAS steering servo is wired to the VESC servo cable. The USB cable is also used to flash the firmware on the VESC.
The FOCBOX connects via USB 2.0 to the Jetson. The connector on the FOCBOX is micro-USB. The programming USB cable supplied with the Jetson may be used:
Other VESC 4.12 hardware connect via USB 2.0 using a mini-USB connector. For example:
Before starting the bldc-tool, connect the VESC to the vehicle battery:
Programming the VESC
$ cd ~/bldc-tool
This will bring up the GUI to interact with the VESC. Before flashing the firmware, hit the ‘Connect’ button to communicate with the VESC. The current firmware revision will display in the lower right hand corner upon connection.
Use the ‘Firmware’ tab to go to the flash the firmware binary area. Select the firmware file, and upload to the VESC. After the firmware is finished uploading the VESC will disconnect and reboot. Important Note: You must select the correct version of firmware to match the VESC that you are using, otherwise damage and other bad things can happen. In the video, we flashed the firmware ‘VESC_servout.bin’ for version 4.12 of the hardware.
The firmware for hardware version 4.12 in the file located in ~/vesc-firmware/firmware/VESC_servout.bin
After the firmware is done uploading, go to the ‘Motor Controller’ tab. ‘Connect’ to the VESC. The configuration is loaded from the ‘Load XML’ button. Once the configuration is loaded, write the configuration to the VESC.
The configuration file is located in ~/vesc-firmware/VESC-Configuration. The configuration file shown in the video is ‘FOCBOX_hw_30k_erpm.xml’ which is for the FOCBOX. If you are using a regular VESC, you will probably want to use the configuration file ‘VESC_30k_erpm.xml’.
Note: You should use the updated bldc configurations, the configurations lower the min and max erpm values to avoid damaging the VESC when connected to the TRAXXAS motor.
Once the VESC has been flashed and configured, you are ready to tele-operate the robot: RACECAR/J – ROS Teleoperation
In the video, a Jetson TX2 running L4T 28.1 is shown.
The next generation VESC website VESC Project supports both older hardware and the new 6.4 version of the VESC.
VESC is a registered trademark of Benjamin Vedder.
At this point, we have a working robot platform. In the next few articles we will be covering attaching the Jetson to a battery, and adding different sensors. Stay tuned!