参考:blog.csdn.net/hcx25909/article/details/9042469
罗技F710无线控制手柄ROS下使用说明
安装手柄相关的包和驱动
sudo apt-get install ros-indigo-joy(ROS相关项,Jetson TK1只安装这一个)
sudo apt-get install ros-indigo-joystick-drivers
rosdep install joy
rosmake joy
备注:直接rosdep install joy时提示错误:
wang@wang-Rev-1-0:~$ rosdep install joy
ERROR: Rosdep cannot find all required resources to answer your query
Missing resource joy
ROS path [0]=/opt/ros/indigo/share/ros
ROS path [1]=/home/wang/bzrobot_ws/src
ROS path [2]=/opt/ros/indigo/share
ROS path [3]=/opt/ros/indigo/stacks
所以用apt-cache search ros-indigo查找安装包,最后选定以下包安装,之后rosdep install joy成功
ros-indigo-joy
ros-indigo-joystick-drivers
sudo apt-get install ros-indigo-joy
rosdep install joy
rosmake joy
查看手柄接口信息并更改其所在的群组 //重启后无效不知道怎么解决
默认情况下游戏手柄接口名称为js0
1). 输入:ls -l /dev/input/js0
输出:crw-rw-r--+ 1 root root 13, 0 10月 5 09:03 /dev/input/js0
可知js0默认的所有者和群组都是root,即需要root权限才能操作js0
2). 更改js0的root群组为dialout群组
sudo chgrp dialout /dev/input/js0 //改变所属用户方法:sudo chown 用户名 /dev/input/js0
查看更改后所属群组,输入:ls -l /dev/input/js0
输出:crw-rw-r--+ 1 root dialout 13, 0 10月 5 09:03 /dev/input/js0
3. 测试手柄信号
1). 插上无线手柄接收器
2). sudo jstest /dev/input/js0
(sudo apt-get install joystick) (在ubuntu本身上的测试,Jetson TK1安装了该项)
现在按下手柄按键就会在终端显示信息,如附件表一所示:
运行joy_node节点,查看或订阅消息
1). 运行joy_node节点:
rosrun joy joy_node 或者rosrun bzrobot_comm joy_node
2). 查看消息:
rostopic echo joy 或者rosrun bzrobot_comm joy_sub.py
现在按下手柄按键即可收到信息,终端显示如下:
header:
seq: 1990
stamp:
secs: 1412479062
nsecs: 544396707
frame_id: ''
axes: [-0.0, -0.0, 1.0, -0.0, -0.0, 0.0, -0.0, -0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
header:
seq: 1964
stamp:
secs: 1412478581
nsecs: 100324311
frame_id: ''
axes: [-0.0, -0.0, 0.21262244880199432, -0.0, -0.0, 0.0, -0.0, -0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
备注:与sudo jstest /dev/input/js0输出信号相比,其数字量用0.0,1.0,-1.0表示,模拟量在-1.0到1.0之间,方向键和摇杆的正负号反过来
查看ROS定义的手柄消息类型Joy
输入:rosmsg show Joy
附件表一: sudo jstest /dev/input/js0时终端显示
MODE有两种状态:绿灯不亮、绿灯亮 VIBRATION:按下手柄震动
为方便叙述,左侧摇杆称为摇杆A,右侧摇杆称为摇杆B,有上下左右标志的键称为方向键
绿灯不亮时按键值及其位置:
|
axes |
buttons |
||||||||||||||||||
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
A |
|
|
|
|
|
|
|
|
on |
|
|
|
|
|
|
|
|
|
|
|
B |
|
|
|
|
|
|
|
|
|
on |
|
|
|
|
|
|
|
|
|
|
X |
|
|
|
|
|
|
|
|
|
|
on |
|
|
|
|
|
|
|
|
|
Y |
|
|
|
|
|
|
|
|
|
|
|
on |
|
|
|
|
|
|
|
|
LB |
|
|
|
|
|
|
|
|
|
|
|
|
on |
|
|
|
|
|
|
|
RB |
|
|
|
|
|
|
|
|
|
|
|
|
|
on |
|
|
|
|
|
|
BACK |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
on |
|
|
|
|
|
START |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
on |
|
|
|
|
Logitech |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
on |
|
|
|
摇杆A下压 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
on |
|
|
摇杆B下压 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
on |
|
摇杆A左右 (模拟量) |
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
摇杆A上下 (模拟量) |
|
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LT (模拟量) |
|
|
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
摇杆B左右 (模拟量) |
|
|
|
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
摇杆B上下 (模拟量) |
|
|
|
|
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RT (模拟量) |
|
|
|
|
|
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
方向键左右 (数字量) |
|
|
|
|
|
|
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
方向键上下 (数字量) |
|
|
|
|
|
|
|
-32767 至 32767 |
|
|
|
|
|
|
|
|
|
|
|
|
绿灯亮时:1). 摇杆A成为数字量,其位置和值与绿灯不亮时方向键键相同
2). 方向键只是位置由axes的6,7位改变到0,1位
3). 其它按键不变
Jetson TK1安装F710驱动:
1.ls -l /dev/input/js0
2.sudo apt-get install joystick(安装)
3.sudo jstest /dev/input/js0
4. sudo apt-get install ros-indigo-joy(安装)
5.roscore
6.rosrun joy joy_node
7.rostopic echo joy