Stoked! SNES Wireless Gamepad That Works!

I am so stoked!

Several years ago I tried two different PS4 wireless game controllers with Carl to no avail.

Today (Friday the 13th) was different. This $16 SNES Gamepad comes pre-paired to a USB WiFi adapter

Screen Shot 2021-08-13 at 10.26.04 PM
and with a simple:

sudo apt-get install joystick

I have a controller that should work with ROS teleop-twist-joystick node to drive Dave around for /scan topic bagging and future map development.

I could even walk him around the block for donkey car training (after a few years more learning…).

Setup 2.4GHz Wireless USB Gamepad

lsusb shows:
  Bus 001 Device 005: ID 0079:0126 DragonRise Inc.

Plugged in USB WiFi Gamepad adapter

sudo apt install joystick

jstest --normal /dev/input/js0

Driver version is 2.1.0.
Joystick (Controller) has 6 axes (X, Y, Z, Rz, Hat0X, Hat0Y)
and 13 buttons (BtnA, BtnB, BtnC, BtnX, BtnY, BtnZ, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode).
Testing ... (interrupt to exit)
Axes:  0:     0  1:     0  2:     0  3:     0  4:     0  5:     0 Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 10:off 11:off 12:off 


Pad Up:    Axis 1: -32767
Pad Dn:    Axis 1:  32767

Pad Left:  Axis 0: -32767
Pad Right: Axis 0:  32767

Select: Button 8
Start:  Button 9

X: Button 0
B: Button 2
Y: Button 3
A: Button 1

Forefinger pads:
Left:  Button 4
Right: Button 5

sudo jscal -q /dev/input/js0
jscal -u 6,0,1,2,5,16,17,13,304,305,306,307,308,309,310,311,312,313,314,315,316 /dev/input/js0


Charging: blinking red 
Fully Charged: LED off

Low Battery: blinking red
Battery OK: solid red


Instructions say do not charge more than 2 hours

Power Consumption:  12 mA at 11.13v (probably 25mA at 5v through USB)

(I have a powerful wired joystick connected to the desktop computer,
but since the the PiCamera doesn’t easily work with the 64bit Ubuntu Server OS,
this wireless-to-Dave controller will allow me to “escort” Dave around the house.)

2 Likes

Cool! I find joystick control so much easier than keyboard control. So you’re plugging the receiver directly into one of Dave’s USB port? I’ve got a wired controller, so it’s plugged into the laptop, but then I just run the ‘Joy’ node on the laptop and it works fine.
/K

2 Likes

Right - with remote camera view.

I also have a wired joystick on my desktop, but without the remote camera view it is too awkward to use.

Yes - (perpetuating my “most ROS robots are just remote controlled, brain-less platforms” opinion)

Additionally, after “Cassie Runs 5k”, Dave was whispering “I want to do that” in my ear.

 

Full Disclosure

Dave’s max speed is 0.25m/s so to “run for 5k” he will have to run for 5.6 hours.
That is probably a bit more than his battery will last,
and a lot more than my patience to walk along with him in his “First GoPiGo3 Goes 5k” effort.

I just checked Carl’s wheel stats:

Total Travel:  1540.1 m 5052.8 ft
Total Rotate:  1082044.4 deg 3005.6 revolutions
Total Motion:  37020.5 sec 10.283 hrs
Total Life:  20605.0 hrs   percentInMotion: .04

Carl is coming up on his third year birthday with a 1.5km headstart on Dave.

I “run/walk” 5k every Monday and Friday. I just barely beat Cassie at 40-42 minutes for my 5k.

2 Likes

I have a working drive_gopigo3.py going direct to the GoPiGo3, but ROS refuses to recognize a device named “Controller” as a “device name ends in -joystick”.

Seems like I am going to have to modify the ROS2 joy_node for SNES game controller.

Added wheel logging to Dave since I’m driving him around a bit -

Total Travel:  5.9 m 19.3 ft
Total Rotate:  129.8 deg .3 revolutions
Total Motion:  84.9 sec .023 hrs
Total Life:  187.9 hrs   percentInMotion: .01

A good start - 6 meters “exercise” in one day. Don’t want to over-do it!

2 Likes

Or maybe I just needed to reboot and try fresh:

IT WORKS!

Perhaps running jstest or jscal yesterday before trying the node messed it up. Perhaps accessing it with Python-evdev didn’t release it, I did have to CTRL-C twice to exit my programs. Perhaps it just needed a reboot. (Yesterday “$ ros2 run joy joy_node” was stuck with no printout, today it works.)

$ ros2 run joy joy_enumerate_devices
Joystick Device ID : Joystick Device Name
-----------------------------------------
                 0 : Controller
pi@ROSbot:~/rosbot-on-gopigo3/handsonros2$ ros2 run joy joy_node
[INFO] [1629144617.662619904] [joy_node]: No haptic (rumble) available, skipping initialization
[INFO] [1629144617.663449763] [joy_node]: Opened joystick: Controller.  deadzone: 0.050000  

$ ros2 topic echo /joy
header:
  stamp:
    sec: 1629144685
    nanosec: 390600086
  frame_id: joy
axes:
- -0.0
- -0.0
- -0.0
- -0.0
- 0.0
- 0.0
buttons:
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
---

And with y-axis-up rocker depressed:

---
header:
  stamp:
    sec: 1629144707
    nanosec: 519377462
  frame_id: joy
axes:
- -0.0         
- 1.0        <------ Y "Joy Pad" Up depressed
- -0.0
- -0.0
- 0.0
- 0.0
buttons:
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
---

Now I can figure out what config file I need to create for the SNES Controller to drive teleop_joy. I’m stoked!

2 Likes

Congrats. That’s great.
I found it easier just to write a short program to listen to the joy messages and send cmd_vel messages than to sort through all of the teleop_joy configuration.
/K

1 Like

May yet be the best solution for me as well since this “joystick” is not continuously variable. It puts out only zero or full travel. Either solution, I have to come up with a scheme for speed control.

Some other reasons to build a custom teleop_gopigo node that listens to the joy topic:

  • I can write it in python instead of having to relearn C++. I taught C++ when it was first released, and programmed in it for ten years, but feel more comfortable in Python now.
  • I can publish “more right/left” /servo/position/S1 topics on the “top right” and “top left” buttons of the controller, and “center servo” (/servo/position/S1 msg.data=0) on the “stop!” button
     

It seems the teleop_joy implements a “turbo” button which would give me a slow speed and a fast speed. I haven’t figured out what all it can implement.

The keyboard teleop used a zero or “full travel” concept with two other keys to increase or decrease the “full travel” speed value.

What functions did you assign to your buttons?

1 Like

My program (gpg3_joy.py) is pretty spare on functionality. My joystick does have a potentiometer, so the output is variable. Right now I don’t have anything mapped to the buttons. I like the idea though of having faster/slower buttons you could use in combination with the directional keys. That could provide you with some degree of speed control.
/K

PS - I never learned C++ well, and most recently have really only used a subset for programming Arduino’s and the like. Far prefer Python.

2 Likes

The four-button “joystick” is not a joystick per se but more like a four-position switch.

Some of these joysticks actually have a knob that is an analog joystick.

Maybe you can find one?

1 Like

Yes, they exist but

  • They tend to cost 2x to 3x the $16 price of this one
  • I had serious connection difficulties and poor reliability even when successful
  • I can live with either two speeds, slow and fast or a press more times for faster, or on/off paired w speed up/dn buttons.

This one is very reliable and inexpensive and in hand.

2 Likes

Yup.

Excellent reason for using it. Once you get the bugs out, you can migrate to a fancier one.
:+1:

2 Likes