In the tenth part of our Jetson RACECAR build we discuss how to control the drive motor and steering servo. Then we discuss battery selection to power the electronic components we are adding to the car. Looky here:
Background
As discussed in Part 3 – ESC Motor Controller, the TRAXXAS Rally steering servo and the drive motor Electronic Speed Controller (ESC) are controlled by PWM signals sent from an on board radio receiver. PWM stands for Pulse-Width Modulation. In the article, we explore sending PWM signals through a dedicated hardware PWM driver. We are then able to determine appropriate values to send to control the car from a Jetson.
Discussion
As you recall, the Jetson RACECAR is a derivative of the MIT RACECAR. There is another MIT derivative race car from the University of Pennsylvania. Both the MIT and UPenn cars are open source autonomous robot platforms.
The MIT and UPenn designs use two different approaches for controlling the cars. The UPenn approach is to use a micro controller to generate PWM pulses which control the stock TRAXXAS ESC and the steering servo. On the other hand, the MIT approach is to replace the stock TRAXXAS ESC with a Vedder Electronic Speed Controller (VESC).
UPenn Approach
The UPenn car incorporates a Teensy 3.2 Microcontroller which is a USB-based micro controller development system. While not an official Arduino product, the Teensy can be programmed using Arduino software. In the UPenn design, the Teensy generates PWM signals for the ESC and steering servo.
A nice feature of using the Arduino software on the Teensy is that you can use the Arduino ROS library. In that way, the Teensy can act as an independent ROS node that is accessed through the Arduino rosserial_client.
The Teensy costs around $20 from places such as Adafruit or Sparkfun. You can also get it from Amazon with headers attached.
So it’s inexpensive and easy to integrate, what are the drawbacks? The drawbacks depend on your perspective. As discussed in Part 3, because the stock TRAXXAS ESC is being used the minimum speed that the car travels from a constant minimum pulse is around 6 or 7 mph. One view of this is that it is a race car after all, we can’t really fault it for wanting to go fast. We can always jog after it.
An opposing view is that since it is robotic, it should be able to control itself at all speeds. I also believe that it is against one of the major ethical rules of robotics, which is one should never have to run after a robot. Running should be reserved for running from robots in terror.
Another “drawback” is that the stock setup does not provide odometry. The MIT approach which we will discuss shortly does provide odometry from the custom ESC. This may or may not be of concern depending on how the car is being used. Note here however that TRAXXAS offers a telemetry package for the Rally car which adds a hall effect sensor for sensing drivetrain revolutions. The sensor sends out PWM signals, it may be possible to read the signal and derive odometry from it using the Teensy.
MIT Approach
In the first version of the MIT RACECAR, the stock ESC and steering servo were driven with PWM signals generated from a Jetson TK1. As we have discussed in previous articles, this is not ideal because the Jetson is not using either a real-time operating system or dedicated hardware to generate the PWM pulses.
In the second version of the RACECAR, a VESC replaces the stock ESC. This provides a couple of advantages for a teaching vehicle. First, it’s easy to experiment with the algorithms in the firmware due to the open source nature of the hardware and software. For example, when teaching a class on feedback control the students can implement different algorithms in the ESC firmware. In the case of the RACECAR, this also means that low speed motor control of the car is under programmer control.
The VESC has a servo control port which controls the car steering servo.
The second advantage is that the VESC provides monitoring the speed of the motor under control. If you know how fast the motor is turning, you can calculate how much the wheels turn. If you know that, you can tell the distance the car has travelled, thus you have odometry. Now it’s not super accurate as it does not take into account factors such as drivetrain slippage, but it can be pretty close.
The drawbacks? The VESC itself is a relatively low volume part which means availability can vary. Depending on where you buy it, delivery times can be short or on the order of 4-6 weeks. Most of the manufacturers appear to take orders in batches, they wait until they have enough orders to run a batch. Because the VESC is open source, you can build your own if you like.
You will probably have to modify the VESC for the RACECAR application, at least changing the wiring to match the gauges being used on the RACECAR. The main VESC application is to control motorized skateboards which draw a lot more current than the TRAXXAS car. Overall, the VESC is harder to integrate into the RACECAR design than the Teensy approach.
The other drawback of the VESC is that it is relatively expensive compared to the Teensy. The price on the VESC seem to vary widely depending on where you buy it. In general they seem to range from around $125 USD to $225 USD.
Battery
Both the MIT and UPenn cars use the Energizer XP18000AB Universal Power Adapter with External Battery. In earlier episodes we talked about using a regular LiPo battery. However the Energizer solves a couple of issues. First, it provides three different voltages, 5V, 12V and 19V. That makes it easy to drive the Jetson and a good selection of sensors, transmitters, and other peripherals. Second, the battery has built-in temperature and short-circuit protection when charging. This makes it somewhat safer to charge the battery than a traditional LiPo.
The Energizer is more expensive than the traditional LiPo solution we have discussed, but is much more flexible.
There are a lot of ways to view this subject. In this particular design, a battery is placed in the car chassis to drive the motor and steering servo. In the stock configuration, the battery also powers the receiver. A secondary battery, in this case the Energizer, is used to power the additional electrical components which turn the car into a robot.
In general you need to have power isolation between motors and electrical components, having two batteries is an easy way to accomplish this. However, recognize it is a tradeoff.
The Energizer is a big 18 Amp hour battery, so placement in the car and adjusting the center of gravity may be of concern to the real racers out there.
The takeaway is that for a development mule, this seems like a great solution. You can add and subtract components without having to worry too much about power drain or voltage requirements.
Next Steps
The original Jetson RACECAR hardware PWM driver approach is viable. In order to make it work, some code needs to be written to integrate it into the ROS environment. While not a big project, it does not make sense to undertake it when the UPenn Teensy solution is conceptually equivalent, more flexible and already finished.
So off comes the PCA9685, and on goes the Teensy 3.2. We’ll program up the micro controller and test out the motors and steering from ROS.
20 Responses
When it comes to affordable and functional solution, it is logical to use the most ubiquitous and accordingly the least expensive solution for the generation of PWM – ARDUINO UNO R3 it costs US $ 3.45. I have installed on my machine this bundle, and it works perfectly with the ROS.
That’s certainly one good solution.
Howdy Jim,
I have decided I want to go with the VESC for my E-MAXX-based project since I need to be able to traverse natural outdoors terrain at relatively low speeds as well as moderately fast speeds.
Would you mind sharing where you obtain your VESC?
Cheers
Galto
Hi Galto,
I bought mine from:
http://www.ollinboardcompany.com/product/vedder-s-speed-controller
There are several places that sell them, but most companies appear to run them in small batches. Just to manage expectations, at the time of the order the item was said to be in stock but actually took about three weeks before it was ready to ship. Thanks for reading!
Oh, that’s okay, I’ll play with the Teensy in the mean time!
Thanks!
Galto
Hello kangalow I’ve been following this particular thread for a while now and i thought id say hello. I think it would be awesome if you could share with us some basic tutorials on how to program the vesc. (Its already in your arsenary of electronics, so you might as well, right? XD) I am also currently using upenn and mit as well as your tutorials as a guide in building my hokuyo lidar/structure sensor/zed sensor based racecar. I come from a mechanical/motorsport engineering background so most of this is very new to me but its really rewarding.
Hi Jesse,
I haven’t had a chance to work with the VESC yet. I’ve been working on coordinating with the MIT release of the VESC firmware that they use, it’s still a while coming. The actual MIT ROS interface for the VESC is at:
https://github.com/mit-racecar/vesc
So the VESC that I have ordered from Ollin (due to arrive in a couple of days) will not work with the code published on github by MIT unless it has been programmed with specific firmware?
Two parts to it. There’s the actual firmware itself (which is available for any VESC) and then some settings that MIT uses to tune the firmware. When I first saw their software, they had a special image that they were burning to the VESC. I do not believe that is the case anymore, but I do not know this to be absolute. My guess is that it will work with the MIT Github software directly now with the stock VESC firmware.
One of the things that MIT uses the VESC for is to teach control systems with the cars, so maybe I got confused by that in my visit there. It could very well be that the custom firmware is in used in a control theory class, not the general RACECAR class. But I personally haven’t tried any of it yet, so I don’t know the answer.
I want to re-program/hack my VESC firmware. In order to do this I need to connect to it via a Micro JST 2.0 PH 6-Pin Connector (Female).
It turns out that the only vendors for this particular connector that I could find are located in China, and it will take 6 to 8 weeks before I receive my 5-pack order (via Amazon, and it didn’t have a rush option).
This is probably a shot in the dark, but does anyone happen to know where I would be able to obtain this connector state-side?
Thanks in advance
Galto
Hi Galto, were you able to hack the VESC firmware? I’ve been trying to look online for UART communication between a VESC and an arduino but I am not really sure where to begin.
@JetsonHacks: Since there is a lot of existing code on uart communication between vesc and the arduino in VESC forums, may I suggest you kindly revisit this portion of interfacing with the Jetson Racecar series? As you mentioned, the conventional RC ESC lacks telemetry and the minute control for low speed runs.
Hi Jesse,
There’s been a lot of behind the scenes stuff with this project, unfortunately it has delayed the articles. The VESC ROS code that is going to be used can be found in the MIT RACECAR repository: https://github.com/mit-racecar/vesc
The MIT RACECAR software is the software stack the Jetson RACECAR is being built on.
I have troubles powering TX1 with the battery. I am using 3S LiPo battery, hooked up to DCDC step up converter to get 19v. Everything is wired properly , but when I press power button nothing happens. And when I press power button 2 times, fan moves a bit, but still board doesn’t turn on. When I use provided power brick (also 19v) board works fine.
Do you have any suggestions?
The first thing that I would look at is the connector that you’re using to plug into the TX1 board.
It is nort exactelly the same as Nvidia’s, it fits a bit looser. But I measured the voltage on the dc jack and I see 19V coming in. DC-DC converter I am using is rated to 8A max current, which should be enough (power brick is 4.9A). I’ll try to lower the voltage on the converter, and try to power it with 16 and 12V.
Most people having issues with the battery have fixed it by using a correctly sized connector. I would guess that is where your issue lies.
Ok, thanks. I’ll try to find the matching connector. I tried also 16v and 12v, and that didn’t help. One more thing I noticed, there is a voltage spike on J21 pins when I press the power button.
Can you tell me how many part did you use in this car.
I wanna make one.
I am actually using ezrun max5 as ESC right now. I am trying to slow it down with jetson nano
I have a small doubt I am using dji zenmuse z15-a7 gimbal on my rc car do you have any references that how can I control both the car and gimbal from same remote controller and I am also looking how can I control the gimbal with jetson nano or any jetson so if you have any references that’s much appreciated
I don’t know anything about the devices on your project. But that’s part of the fun! Good luck!