turtlebot入门-xbox360无线游戏杆控制turtlebot
xbox360无线游戏杆控制turtlebot
说明
- 手上有xbox360无线游戏杆,想看看能不能用来控制turtlebot.查资料,真可行.只要增加一个PC接收器
需的硬件
xbox360无线游戏杆
xbox360无线游戏杆PC接收器,或叫USB适配器
windows下的安装XBOX360手柄驱动
- 利用驱动精灵安装驱动
下载驱动安装:(适合win7 32位,64位,XP系统)
https://pan.baidu.com/s/1milnt0W
Linux下的安装XBOX360手柄驱动
安装驱动:
sudo apt-add-repository ppa:rael-gc/ubuntu-xboxdrv
sudo apt-get update && sudo apt-get install ubuntu-xboxdrv
参考:
- http://www.omgubuntu.co.uk/2014/06/ubuntu-xbox-controller-support-xboxdrv-driver
- http://www.omgubuntu.co.uk/2013/07/dealing-with-xbox-controllers-in-ubuntu
- http://pingus.seul.org/~grumbel/xboxdrv/
手柄和接收器配对过程
- 1、PC接收器连好电脑,并且确保安装好驱动程序
- 2、手柄打开,按中间大圆按钮,俗称西瓜键,如果没有匹配上,灯会闪烁
- 3、按图2手柄前面靠左的小圆按钮,手柄西瓜键灯闪烁旋转,进入匹配状态
- 4、按图2接收器的小圆按钮,手柄灯闪烁也进入匹配状态
- 5、几秒之后自动匹配好,手柄西瓜键灯会亮1/4,接收器也停止闪烁。说明匹配成功。
注意:一个PC接收器最多可以对应4个XBOX360手柄。
Linux下游戏杆的使用一般步骤
- 游戏杆插入到ubuntu PC,检查是否发现设备。检查方式查看教程
$ ls /dev/input/js*
查看是否有显示或jsX,X为数字:
/dev/input/js0
- 测试设备是否可用
$ sudo jstest /dev/input/js0
显示,移动游戏杆数据会变化:
Driver version is 2.1.0.
Joystick (Logitech Logitech Cordless RumblePad 2) has 6 axes (X, Y, Z, Rz, Hat0X, Hat0Y)
and 12 buttons (BtnX, BtnY, BtnZ, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR).
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
- 查看权限, ROS的joy node需要访问设备的权限
$ ls -l /dev/input/jsX
显示:
crw-rw-XX- 1 root dialout 188, 0 2009-08-14 12:04 /dev/input/jsX
如果XX是rw: js设备配置正确的
如果xx是--: js设备配置不正确需要更改权限:
$ sudo chmod a+rw /dev/input/jsX
- 配置需要使用的设备,默认是js0:
$ rosparam set joy_node/dev "/dev/input/jsX"
- 启动joy节点
$ rosrun joy joy_node
显示如:
[ INFO] 1253226189.805503000: Started node [/joy], pid [4672], bound on [aqy], xmlrpc port [33367], tcpros port [58776], logging to [/u/mwise/ros/ros/log/joy_4672.log], using [real] time
[ INFO] 1253226189.812270000: Joystick device: /dev/input/js0
[ INFO] 1253226189.812370000: Joystick deadzone: 2000
- 在新终端下查看joy主题
$ rostopic echo joy
显示如:
header:
seq: 9414
stamp:
secs: 1325530130
nsecs: 146351623
frame_id: ''
axes: [-0.0038758506998419762, -0.0038453321903944016, -0.0, -0.999969482421875, 0.0, 0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
header:
seq: 9415
stamp:
secs: 1325530130
nsecs: 146351623
frame_id: ''
axes: [-0.0038758506998419762, -0.0038453321903944016, -0.0, -0.999969482421875, 0.0, 0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
header:
seq: 9416
stamp:
secs: 1325530130
nsecs: 146351623
frame_id: ''
axes: [-0.0038758506998419762, -0.0038453321903944016, -0.0, -0.999969482421875, 0.0, 0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Linux下xbox无线游戏杆的使用步骤
- 步骤有类似也有区别,插入Xbox pc接受器后,查看设备信息
ls /dev/input/js*
显示为:
/dev/input/js0 /dev/input/js1 /dev/input/js2 /dev/input/js3 /dev/input/js4
会出现有四个JS设备,可能是xbox标准就是支持4个控制器。pc接受器也提供四个对应的JS设备。
- 按下PC接收器的中间键,开始闪亮
- 按下xbox无线游戏杆的中间键,顶部开始旋转闪亮
- 完成xbox无线游戏杆和pc接收器的配对
- 测试是否设备可用,js1为xbox游戏杆设备
sudo jstest /dev/input/js1
显示如:
Driver version is 2.1.0.
Joystick (Xbox 360 Wireless Receiver (XBOX)) has 6 axes (X, Y, Z, Rx, Ry, Rz)
and 15 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnThumbL, BtnThumbR, ?, ?, ?, (null), (null), (null), (null)).
Testing ... (interrupt to exit)
Axes: 0: -5086 1: 0 2:-32767 3: -1291 4: 1066 5:-32767 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 13:off 14:off
- 检查权限,并设置权限
$ls -la /dev/input/js1
crw-rw-r--+ 1 root root 13, 1 Nov 5 15:48 /dev/input/js1
$ sudo chmod a+rw /dev/input/js1
$ ls -la /dev/input/js1
crw-rw-rw-+ 1 root root 13, 1 Nov 5 15:48 /dev/input/js1
在新终端启动roscore
设置设备并启动joy节点
rosparam set joy_node/dev "/dev/input/js1"
rosrun joy joy_node
- 新终端显示joy主题
rostopic echo joy
显示如:
header:
seq: 429
stamp:
secs: 1415227355
nsecs: 833352850
frame_id: ''
axes: [0.19235174357891083, -0.0, 1.0, -0.04268254339694977, -0.048208002001047134, 1.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- linux下的MicrosoftXbox360无线游戏杆的按钮及轴和索引号对应关系, 参考教程
- Table of index number of /joy.buttons:
Index |
Button name on the actual controller |
0 |
A |
1 |
B |
2 |
X |
3 |
Y |
4 |
LB |
5 |
RB |
6 |
back |
7 |
start |
8 |
power |
9 |
Button stick left |
10 |
Button stick right |
- Table of index number of /joy.axis:
Index |
Axis name on the actual controller |
0 |
Left/Right Axis stick left |
1 |
Up/Down Axis stick left |
2 |
Left/Right Axis stick right |
3 |
Up/Down Axis stick right |
4 |
RT |
4 |
LT |
6 |
cross key left/right |
7 |
cross key up/down |
游戏杆控制turtlebot
- 关闭之前所有打开的终端,重新打开启动roscore
$ roscore
- 新终端启动turtlebot
$roslaunch turtlebot_bringup minimal.launch
- 新终端设置设备并启动游戏杆遥控支持
$ rosparam set /joystick/dev "/dev/input/js1"
$ roslaunch turtlebot_teleop xbox360_teleop.launch
测试使用,按住左边的LB按钮激活游戏杆并移动左遥控杆,Turtlebot应该就有反应。
配置完成,可以开始继续探索。
参考:
- http://wiki.ros.org/joy/Tutorials/ConfiguringALinuxJoystick#Configuring_the_Joystick
- http://wiki.ros.org/joy
- https://ekpyroticfrood.net/?p=115
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号