RACECAR/J – ROS Teleoperation

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:

Background

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.

Teleoperation

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.

Logitech F710 (Back)
Logitech F710 (Back)

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.

Logitech F710
Logitech F710

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:

~/racecar-ws/src/racecar/racecar/config/racecar-v2/joy_teleop.yaml

In the section:

# Enable Human control by holding Left Bumper
human_control:
type: topic
message_type: ackermann_msgs/AckermannDriveStamped
topic_name: low_level/ackermann_cmd_mux/input/teleop
deadman_buttons: [4]
axis_mappings:

axis: 1
target: drive.speed
scale: 2.0 # joystick will command plus or minus 2 meters / second
offset: 0.0

axis: 3
target: drive.steering_angle
scale: 0.34 # joystick will command plus or minus ~20 degrees steering angle
offset: 0.0

Change the line

axis: 3

to:

axis: 2

This should change from the vertical to the horizontal axis on the game controller.

Conclusion

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.

5 Comments

  1. When I attempt to perform teleoperation w/o a connected ethernet cable I get the following error:
    Unable to connect to my own server at…

    Otherwise this performs as expected.

    Why does the jetson TX-2 need to have a connected ethernet cable to perform teleoperation?
    Is there a way around this?

    • Not sure what your issue is. When does the error message “Unable to connect to my own server at” appear?
      Your ROS_MASTER and ROS_IP need to be set to the IP address of the Jetson which does not depend on the ethernet network connection. When you have an Ethernet cable attached, there’s usually a router which assigns a network address. If you assign your ROS IPs to the address on the ethernet network, and then unplug the cable, it no work.

  2. @Joshua_Hughes, you probably used your Jetson’s IP address in the configuration somewhere. When the Ethernet port goes down, the IP address goes away. If you use 127.0.0.1 instead, that address will persist through all network changes.

Leave a Reply

Your email address will not be published.


*