JetsonHacks

Developing on NVIDIA® Jetson™ for AI on the Edge

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.

Facebook
Twitter
LinkedIn
Reddit
Email
Print

14 Responses

  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?

    1. 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.

  3. Making a lot of progress here on my racecarj.
    Thank you guys for your hints and advice.
    (the change from localhost to 127.0.0.1 did work for me)
    Would like to increase the speed a little bit of the racecar.
    It seems to top out at a couple miles an hour.

    In the joy_teleop.yaml I increased the axis 1 scale from scale: 2.0 to scale: 8.0 but had no luck.

    Has anyone found a way to increase the speed?

  4. Hello,
    I’m trying to use Logitech GamePad F710 in Direct Input (D) mode along with Jetson Xavier.
    I have followed all of the instructions given by you to connect the game pad with Mode light off and it’s being detected by the system as “/dev/input/js0”, but when I run “sudo jstest /dev/input/js0” o/p is shown with pre-normalized values of all the parameters. In this issue is that Data in the o/p of jstest is not getting updates as I move joystick or press buttons.
    Initially I thought that it be issue with read/write permissions of “js0” device, so gave those permissions, as well as reloaded “joydev” and “usbhid” modules. But nothing worked out.
    Anyone has suggestions/ solution to this problem?

      1. Anyone know how to use Logitech Gamepad F710 on Xavier? jstest0 does not work. I search online, seems need to rebuild L4T kernel. I am wondering the later version of Jetpack enable it?

  5. I have a very strange problem I hope you can help me with. My Racecarj can go forward and backward but it can not turn. Neither the teleop or ros command can make it turn. When I tried to turn the front wheels by hand, it feels very stiff but turntable. I am wondering what’s going on and how can I debug. Is servo bad? Is there anyway to check with the BLDC tool?

  6. Hi everyone, I have successfully build my car. However, I could not find the FocBox VESC anymore. The manufacture no longer makes them. So if you have a spare or want to sell your used, please let me know…

Leave a Reply

Your email address will not be published. Required fields are marked *

Disclaimer

Some links here are affiliate links. If you purchase through these links I will receive a small commission at no additional cost to you. As an Amazon Associate, I earn from qualifying purchases.

Books, Ideas & Other Curiosities