Jetson RACECAR 11 – Arduino ROS Node for Car Control

In the eleventh part of our Jetson RACECAR build we construct a breadboard to interface the car with the Jetson using an Arduino ROS Node. Then we install the software, and test using a ROS teleoperation node to control the car with a game controller to boot. Looky here:

Background

In our earlier Motor Control and Battery Discussion we had planned on using a Teensy micro controller to interface the Jetson to the steering servo and ESC on the car. After working with the Teensy for a while, I realized that in order to upload a sketch to the Teensy (a sketch is a program that is uploaded and then runs on an Arduino type of processor) an updated version of the Arduino software is needed.

The updated Arduino version is not readily available for the Jetson. An alternative is to run the Arduino software from a PC, such as the host used to flash the Jetson. At the end of the day, it is easier just to replace the Teensy with a regular Arduino and use the Arduino software natively on the Jetson. That means that during development one doesn’t have to bounce back and forth between different development machines.

In the video, an Arduino Nano is used. The Nano was selected because the parts were already on hand, if buying new, an Arduino Micro or clone probably would be the choice.

Note: These are relatively inexpensive, and may use substitute parts. For example, the Arduino Nano uses a CH-340 serial to USB chip instead of a FTDI chip. See the note at the end of the article.

Arduino ROS Node

There are ROS bindings available for the Arduino. Money quote from the ROS wiki:

The Arduino and Arduino IDE are great tools for quickly and easily programming hardware. Using the rosserial_arduino package, you can use ROS directly with the Arduino IDE. rosserial provides a ROS communication protocol that works over your Arduino’s UART. It allows your Arduino to be a full fledged ROS node which can directly publish and subscribe to ROS messages, publish TF transforms, and get the ROS system time.

In our case, we will use the Arduino ROS node to send PWM pulses to the cars steering servo and ESC using the Arduino Servo library.

Construction

Here’s a wiring diagram:

Arduino Board Wiring Diagram
Arduino Board Wiring Diagram

This is a straightforward build. The parts from the video:

along with a soldering station: Hakko FX888D-23BY Digital Soldering Station

One note, notice that the steering servo receives 6V power from the ESC header, which gets power from the car battery. The Arduino receives 5V power over USB, and sends signals to both the steering servo and ESC. To avoid nasties, an isolation circuit can be added.

Make sure that the car battery is disconnected from the ESC before wiring the Arduino breadboard to the car. This Nano uses a mini USB connector.

Here’s what it looks like after assembly and connected to the car, with the USB from the Nano connected to the Jetson:

Arduino ROS Node breadboard
Arduino ROS Node breadboard – Interface Jetson with TRAXXAS car

Software Installation

The prerequisites for software installation are ROS and the appropriate serial to USB driver for the Arduino. FTDI is usual choice for standard Arduinos, here’s an article for building a kernel and installing ROS on the Jetson TK1.

Once the prerequisites are met, you can go to the installJetsonCar repository on the JetsonHacks Github account. Install the repository on the Jetson, and then run the installation script:

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

Next, go to the Arduino sketchbook and open the jetsoncar sketch. This should be in ~/sketchbook/jetsoncar. The name of the sketch file is jetsoncar.ino Open jetsoncar.ino, setup the Arduino software for flashing by selecting the correct Arduino model and port number, and then upload the sketch to the Arduino.

Operation

In the video, a Nyko game pad controller was used. This controller is from the JetsonBot project. The game pad needs to be paired over Bluetooth with the Jetson. The Jetson in the video has a an Intel 7260 Wireless/BT Network Interface Card (NIC) card. Here’s an article on installing the NIC. You’ll also need antennas.

Then open a separate Terminal window for each command:

$ roscore
$ rosrun rosserial_python serial_node.py /dev/ttyUSB0
$ roslaunch jetsoncar_teleop nyko_teleop.launch

You should be able to examine rostopics being fired by the controller. In order to send cmd_vel topics, the ‘Y’ button on the game controller must be pressed while controlling the left joystick, right trigger, or the right button about the right trigger. The ‘Y’ button is commonly called a deadman switch in this use case.

Note: Usual safety warnings apply, make sure that the car is in stable position and the tires are free from contact with surroundings.

Once you are satisfied everything is working correctly, connect the car battery, and hit the power button on the ESC. The controller should then control the car actions.

Conclusion

As with most of these articles, this is not a step by step operation on how to build a project. It requires a bit of ingenuity on the readers part to gather the parts needed on their own, and as such these articles are more for providing a framework on how to build a project like this. Some of the software will need to take that into account, but there should be enough there to give a good starting point for your own build.

Note on Arduino Nano

As noted earlier an Arduino Nano is used in this project. This will probably be revisited with a new model. In order to get this particular Nano to work, a kernel module is built to support the CH-340 serial to USB chip on the Nano. Most Arduinos use FTDI chips, but these are somewhat more expensive than the CH-340, so some Chinese clones substitute the part. The option in the Linux kernel is:

USB Winchiphead CH341 Single Port Serial Driver

One issue that presented itself is that if the rosserial node was used more than once, the Nano would hang. This appears to be related on this particular chip to the pyserial library. On the Jetson, pyserial is 2.6 which exhibits the issue. Rolling back to version 2.5 seems to fix the problem for this particular board.

To install pyserial 2.5:

sudo apt-get install python-pip -y
pip install –user ‘pyserial==2.5’

For more information see:
https://github.com/ros-drivers/rosserial/issues/219

4 Comments on Jetson RACECAR 11 – Arduino ROS Node for Car Control

  1. Hi,

    I have been following this project for a long time. Thank you for your efforts to put these videos for learners like us. I am planning to follow the Jetson Racecar tutorial series to build my own RC car. I would be thankful if you can answer some questions. 1. In my country the traxxass model that you are using is not available, will other traxxass model work the same way? 2. This particular video no.11, you used an arduino for serial communication with ROS. Whats not clear is that last video you hinted at using Teensy microcontroller. Do you have plans to use that as well? How about the VESC for fine motor control in subsequent videos? Also, from the speed it seems that for indoor use still speed is way too much to carefully navigate the car. What are your plans next to rectify this? Thanks

  2. Hi Alex,
    In answer to your first question, most RC cars work in the same manner as the TRAXXAS Rally in the video. In most cases, the steering is controlled by a servo, and the ESC is controlled in a servo like manner. See:
    http://www.jetsonhacks.com/2016/01/20/jetson-racecar-part-2-racecar-steering-control/
    http://www.jetsonhacks.com/2016/01/26/jetson-racecar-part-3-esc-motor-control/

    Typically both of these are controlled by PWM, which either a dedicated device like a PCA9685 or a micro controller like an Arduino can generate. The Jetson can also generate PWM signals, but it’s more involved (and annoying) to do so.

    In answer to your second question, at the 0:42 mark I explained that the Arduino was selected over the Teensy because the Teensy could not be programmed from the Jetson itself. However it is still possible to use the Teensy, just be aware that you’ll probably have to use another machine to do so. The Teensy is mostly compatible with the Arduino, but UPenn is using it in a different manner for more fine grain control of the timing pulses. See: http://f1tenth.org and their repository: https://github.com/mlab-upenn/f1_10_code_public
    The cars are pretty fast (after all they are race cars) and a car using the onboard TRAXXAS ESC goes at about a jogging pace at a minimum: https://www.youtube.com/watch?v=inr7BPh7cv8 As such, they’re not really indoor things unless you’re in a sports/concert arena or commercial building. If you use a VESC, the cars are much more controllable and can travel more slowly. The VESC requires some work to integrate into the car, and some specialized software which puts it into the intermediate roboticist level. Hopefully we’ll get to it, but the next steps are to get the car put together and get the sensors running. With that said, remember that the cars are 22″ (56cm) long and can go 40mph (65 kmh) which is beyond the scale of most indoor environments. And they WILL crash 😉

    If you’re more interested in working indoors, a Rover is probably a better way to go. We’re starting a series on a new Rover project very soon, similar to: https://github.com/avirtuos/ros_hercules/blob/master/README.md A Rover can be used both outdoors and indoors, and travels at much more indoor friendly speeds.
    Thanks for reading!

  3. hi @kangalow,

    Thanks for the detailed answer. I understand your point. Nevertheless, its a good learning project for me. The rover project looks very interesting. I will wait for your rover project. Many thanks.

Leave a Reply

Your email address will not be published.


*


%d bloggers like this:
Skip to toolbar