After completion of the RACECAR/J robot assembly, ROS software installation and VESC programming, it is time to test teleoperation using a game controller. Looky here:
In the software installation article, we installed a custom ROS software stack for the MIT RACECAR. There is a special node, joy_teleop, which is lightly modified to support the RACECAR for use with a game controller. The standard controller in the package is a Logitech Gamepad F710. It is possible to use other game controllers by modifying the scripts.
Once the robot is assembled, software loaded and VESC programmed, the Jetson RACECAR is ready for teleoperation. The game controller used in the video is a Logitech Gamepad F710.
Note: If you purchashed a full RACECAR/J base kit (RACECAR/J Robot Base Kitt or RACECAR/J “FlatNose” Robot Base Kit) the FOCBOX VESC will arrive programmed. If you purchase a VESC separately, you will need to program it to operate the robot. See: Programming the Electronic Speed Controller.
Power on the robot. Plug the battery in the chassis into the VESC. Plug the Jetson and peripherals into a power source, either a battery for the electronics on the car or using the Jetson power brick if the robot is on a bench.
Note: Use caution if the RACECAR is on a bench. You should place the robot on a pit stand or perhaps the Jetson cardboard box to make sure that the wheels do not come in contact with the bench. Also, make sure that none of the cables can come in contact with any moving parts. Let’s just say bad things can happen if the wires wrap around the spinning parts, or the robot starts moving unexpectedly.
In order for the Jetson to recognize the F710, the small switch on the back of the game controller must be in the ‘D’ position. If the game controller is in the ‘X’ position, it may not be detected.
The Logitech F710 connects to the Jetson over a wireless USB dongle. The dongle should be plugged into the USB Hub which is connected to the Jetson. In order to connect to the Jetson, power the F710 on (using the center button labeled ‘Logitech’). You can press the ‘VIBRATION’ button to tell if the F710 is powered on. The ‘VIBRATION’ button should cause the game controller to rumble in your hand.
Once connected, the game controller should show up as /dev/input/js0
The F710 has two modes, selected 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. There is an LED next to the MODE button. If the LED is green, then it is in the wrong mode, the light should be off.
You can test a game controller to make sure it is working with the Jetson using the jstest program.
$ sudo jstest /dev/input/js0
Note: jstest is located in the joystick debian package. If it is missing you can install it:
$ sudo apt-get install joystick
Once the game pad is sending information, you can teleoperate the robot. Make sure that the wheels are clear of any obstructions.
$ cd racercar-ws
$ source devel/setup.bash
$ roslaunch racecar teleop.launch
The robot has a deadman switch, the upper button (labeled LB) 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.
Switch the joystick axis
In the repository on the MIT RACECAR account on Github the right joystick controls steering of the car by changing the vertical axis. Most computer games use the horizontal axis to steer. In order to switch the axis, edit the YAML file located at:
In the section:
# Enable Human control by holding Left Bumper
scale: 2.0 # joystick will command plus or minus 2 meters / second
scale: 0.34 # joystick will command plus or minus ~20 degrees steering angle
Change the line
This should change from the vertical to the horizontal axis on the game controller.
Setting up the robot for teleoperation is straightforward. Note that this is different from how a radio controlled car normally works. In an unmodified vehicle, a radio receiver receives information for a hand held controller. The receiver converts this into PWM pulses which the ESC interprets as throttle and response information.
In the case of RACECAR/J, the game controller is sending information to the Jetson computer. The Jetson then interprets the game controller commands and sends that information as commands to the ESC. This subtle, but important, difference means that additional autonomous algorithms can be integrated using the computer as a mediator.