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:
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.
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).
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.
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.
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.
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.
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.