RADU: Control the Robot using a Joystick

Connect and Read Gamepad Data

[412373.206747] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[412373.206749] usb 1-2: Product: PLAYSTATION(R)3 Controller
[412373.206751] usb 1-2: Manufacturer: Sony
[412373.562080] input: Sony PLAYSTATION(R)3 Controller Motion Sensors as /devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/0003:054C:0268.001C/input/input102
[412373.624511] input: Sony PLAYSTATION(R)3 Controller as /devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/0003:054C:0268.001C/input/input101
[412373.625435] sony 0003:054C:0268.001C: input,hiddev1,hidraw3: USB HID v81.11 Joystick [Sony PLAYSTATION(R)3 Controller] on usb-0000:00:15.0-2/input0
I: Bus=0003 Vendor=054c Product=0268 Version=8111
N: Name="Sony PLAYSTATION(R)3 Controller"
P: Phys=usb-0000:00:15.0-3.1/input0
S: Sysfs=/devices/pci0000:00/0000:00:15.0/usb1/1-3/1-3.1/1-3.1:1.0/0003:054C:0268.0059/input/input224
U: Uniq=00:21:4f:08:f6:c8
H: Handlers=event17 js0
B: PROP=0
B: EV=20001b
B: KEY=f00000000 0 0 0 7fdb000000000000 0 0 0 0
B: ABS=3f
B: MSC=10
B: FF=107030000 0

Reading Gamepad Data with ROS

sudo apt-get install ros-noetic-joy-teleop ros-noetic-teleop-twist-joy ros-noetic-joy
rosrun joy joy_node dev:=/dev/input/js0
[ INFO] [1627219939.885877257]: Opened joystick: /dev/input/js0 (Sony PLAYSTATION(R)3 Controller). deadzone_: 0.050000.
$> rostopic echo /joyheader: 
seq: 177
stamp:
secs: 1627219968
nsecs: 437779598
frame_id: "/dev/input/js0"
axes: [0.04505977779626846, -0.0, 0.0, -0.0, -0.0, 0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
---
header:
seq: 178
stamp:
secs: 1627219968
nsecs: 447620065
frame_id: "/dev/input/js0"
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, 0, 0, 0, 0]
---

Converting Gamepad Data to Twist Messages

rosrun teleop_twist_joy teleop_node
[ INFO] [1627221588.156287628]: Teleop enable button 0.
[ INFO] [1627221588.161486651]: Linear axis x on 1 at scale 0.500000.
[ INFO] [1627221588.161570308]: Angular axis yaw on 0 at scale 0.500000.
---
linear:
x: 0.036096855998039246
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: -0.5
---
linear:
x: -0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: -0.45583534240722656

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sebastian

Sebastian

IT Project Manager & Developer