Get Your Motor Running – VESC – Jetson RACECAR Build

After finishing the installation of the ROS packages on the Jetson RACECAR, we need to program the VESC, an electronic speed controller, for use in the Jetson RACECAR. Looky here:

Background

As discussed in Part 3 – ESC Motor Controller, the TRAXXAS steering servo and the drive motor Electronic Speed Controller (ESC) are controlled by PWM signals sent from an on board radio receiver.

For the Jetson RACECAR, we replace the stock TRAXXAS ESC with a Vedder Electronic Speed Controller (VESC). The major reason for the change is to gain full control 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.

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 Jetson RACECAR 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 from the Jetson using a program called ‘bldc-tool’. BLDC is an acronym for BrushLess DC motor.

Note: There are also compiled versions of the bldc-tool for x86 machines, if you prefer that route.

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.

Note: The actual VESC firmware is available in binary form in the bldc-tool firmwares directory. If you are interested in building the VESC firmware from source, you can compile it from the bldc firmware source tree on Github.

Installation

The VESC is wired to the Jetson using a micro USB to USB-A cable. The USB cable normally communicates motor speed and steering angles between the Jetson and the VESC. The TRAXXAS steering servo is wired to the VESC servo header. In this application, a 90 degree, 3 pin female header helps with the wiring.

VESC Wiring
USB input from Jetson on left, steering servo center. Front of robot is to the left.

The JetsonHacks account on Github contains a repository named installBLDC. To build the bldc-tool:

$ git clone https://github.com/jetsonhacks/installBLDC
$ cd installBLDC
$ ./installBLDC.sh

This will build the bldc-tool and download the RACECAR motor configuration files. The RACECAR motor configuration files are downloaded from the Github mit-racecar repository, and are stored in ~/hardware/vesc.

Before starting the bldc-tool, connect the VESC to the vehicle battery. Then:

$ cd ~/bldc-tool
$ ./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 VESC should be at ttyACM0 (more formally, /dev/ttyACM0). The current firmware revision will display in the lower right hand corner on connection.

Use the ‘Firmware’ tab to flash the firmware binary, the configuration can be loaded from the ‘Load XML’ button. 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 configuration file is located in ~/hardware/vesc. The configuration file shown in the video is ‘6.141_bldc_VESC_X_hw_30k_erpm.xml’ which is for the VESC-X. If you are using a regular VESC, you will probably want to use the configuration file ‘/6.141_bldc_old_hw_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.

Tele-operation

Once the firmware and configuration files are in place, the Jetson RACECAR is ready for teleoperation. You can test a game controller to make sure it is working with the Jetson:

$ sudo jstest /dev/input/js0

The Logitech Gamepad F710 has two modes, controlled by the button labeled ‘mode’. The correct mode for the Jetson RACECAR is the one which the left joystick controls axis 0 and 1, and the right joystick controls axis 2 and 3.

Once the game pad works, you can teleoperate the robot. Make sure that the wheels are clear of any obstructions.

$ cd racercar-ws
$ source devel/setup.bash
$ roslaunch racer teleop.launch

The robot has a deadman switch, the upper button on the left horn of the game pad. Holding the deadman button, you can control the throttle with the left joystick, and the steering with the right joystick.

Conclusion

At this point, we have a working robot platform. We’ll have a couple of more articles on the Jetson RACECAR. As we go forward, we will build the final prototype hardware platform, which we are calling RACECAR/J.

30 Comments

    • Currently we’re working with suppliers for the custom parts such as the deck platforms, wiring, and a version of the VESC that has the proper bullet connectors. We’ve been through a couple of revisions, getting closer. The idea is that you’ll be able to buy the custom, long tent pole items as a kit. This should cut down the amount of time needed to wrangle the long lead time items. There also won’t be a need to do soldering. There are options beyond that, such as a kit of everything needed to build the robot and a fully functioning robot. Once the parts have been specified, we’ll be able to create a BOM. Thanks for reading!

  1. Hello Jim,

    Thanks for all the time and effort you’re putting into these. I’m following along with every article and currently working on my own RACECAR build. I’ve found that the VESC-X can take a while to obtain, so i’m thinking of just buying the original VESC and using that (as you did in your earlier prototype). Will i have any trouble following along with this video installing the software and drivers on the older VESC model?

    Thanks,
    Ryan

    • Hi Ryan,
      The software is the same, the only difference in the install is that you should select a different VESC configuration file from the MIT RACECAR repository: 6.141_bldc_old_hw_30k_erpm.xml
      I hope you can share your build with us! Thanks for reading!

      • How did you know you were flashing the proper firmware version? I’ve been looking through the BLDC firmware github, but that’s mostly information about compiling my own firmware from source (as you pointed out). I’d just like to know what VESC models match up with which firmwares provided with the BLDC tool install. Are you sure the firmware you used will work on the original VESC model?

        • Not quite sure what the question is. If you look in the firmware directory of the BLDC tool:
          https://github.com/vedderb/bldc-tool/tree/master/firmwares
          There are versions that match with each version of the VESC hardware. The VESC-X, for example, is hw 4.12, so I looked in the hw_410_411_412 directory. There is a default version, which works with any of the 4.10 to 4.12 models. There is a version for what looks like a resistor substitution. There’s one for the servo-out. The normal setting for the VESC is Servo in, as the long boarders use wifi/bt controllers to control the motor speed. Servo out is for controlling a servo from the VESC. I don’t know what the 2811 version does, but I’m sure it’s in the forums somewhere. So am I sure? Nope. If I was making a moon shot, then I would research more deeply. But an educated guess after reading the VESC forum leads me to believe that works. When I flashed a VESC, it works. Is it absolutely 100% correct. Dunno.

          • Just my two cent here. I once built my own Ambilight device. I used RGB addressable LED strip, where you have full control for every pixel in that strip. They came with variety of IC chips. One of them is ws2811. Mine was ws2812b.
            I think Vedder add those .bin because he can connect the nunchuk and the ws2812 LEDs directly without any external microcontroller and with a minimal amount of external components.

  2. I’m currently doing the work for a company i’m interning for, i’ll run it by and if it’s okay with them i would love to share! We’re still early in the build now but as we get closer to a working car (provided i get the proper permissions) i’d be happy to share our progress with you What is the best way to get in touch with you? Via youtube/article comments or the “Contact Us” portion of your website?

  3. Great project. How are the game pad commands routed from TX1 to VESC? Does the bldc-tool have game pad support, or do you have a custom communication over USB for this?

    • Hi Erwin,
      The Logitech Gamepad F710 has a wireless dongle that plugs into the USB hub. It’s pretty painless. An alternative is to use a Bluetooth controller and pair it to the Bluetooth onboard the Jetson. The Jetson reads the Gamepad controller as input, and the outputs to the VESC over USB throttle and steering commands. Thanks for reading!

  4. Thanks! How is the USB communication done exactly? Using libusb sending the VESC commands directly? Is there a pointer to this part of the code?

  5. Also, is there a pointer to the C source code diff/changes to make VESC firmware servo output instead of input?

      • Thanks. In a nutshell, you need to recompile bldc firmware using SERVO_OUT_ENABLE 1 in conf_general.h .

        In addition, you need to replace the resistor in R5 to a lower value, say 100 Ohm.

        • In the cars that I have built, there haven’t been any issues using the servo with the stock resistor value. MIT has not recommended any changes, they’ve built several cars. However, that doesn’t mean changing out the resistor is a bad idea.

  6. Hello,

    I don’t see the ttyACM0 port through BLDC tool for some reason and cannot connect to VESC. It does work on ubuntu 16.04 and Windows on my laptop but not on my TX2 (I work through ssh with X forwarding if that is of any relevance, and I added my user to the dialout group). Maybe you have an idea, or at least could post the output of “lsmod” command run on your TX2 here?

    Alex

    • The stock NVIDIA Jetson TX2 on version L4T 27.1 does not have ACM support enabled by default. You will need to modify the stock kernel to add that module, or build it into the kernel itself. The next version of L4T is scheduled to be released soon, I do not know whether ACM support was added.
      As I recall, the configuration is:
      USB Modem (CDC ACM) support
      Abstract Control Model (CDC ACM)
      If it’s any consolation, it took me a while to figure out what the screw was going on. Good luck!

      • Thanks a lot! That explains. I saw your video on updating the kernel but somehow missed what was the reason for updating it. I’ll try to update the kernel.

        • Hi Alex,
          The kernel rebuild was just for instructions on how to do rebuild onboard the Jetson TX2. I was using the VESC for the first time on the TX2 last week, and discovered the issue. Simple enough to fix, but a little frustrating that something that standard was missing out of the kernel build.

          • Thanks for your answer. I have successfully built a new kernel with cdc-acm support enable with the script you provided and was able to connect the VESC. However, I encountered another problem — TX2 does not detect the game pad (the same as in your video). I suspect it’s a driver issue again, maybe you have a solution for this one as well? There is very little information about these things out there, and your website is pretty much the only source. Thanks for running it!

          • Hi Alex,
            You’re welcome. I’m glad you got the VESC to work!
            The Jetson TX2 needs to have the JOYSTICK modules built into the kernel image for the Logitech Gamepad to work.
            I think it’s JOYDEV and CONFIG_INPUT_JOYSTICK
            Make sure to build them as part of the image, you may encounter issues if they are added as modules. If you’re using make xconfig, you can do a Find on JOYSTICK and both should come up, though they will have a more descriptive name. Next, click on the option. The first option is to build it as a module, the second is to build it into the image. Make sure to save it after editing, build the new kernel, then install it. Good luck!

  7. Hi,

    I am trying to run a Traxxas Velineon 3500 Motor and VESC-X combo. Could you please confirm that by “updated bldc configurations” you meant the “6.141_bldc_VESC_X_hw_30k_erpm.xml” file? I loaded this config file and the BLDC-Tool failed to detect the motor.

    Below is a quote from above.

    “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.”

    Thanks!

Leave a Reply

Your email address will not be published.


*