Ubuntu 16.04 + ros-kinetic + Kinect V1相机
由于ros的kinetic版本不再配有openni_tracker功能包,因此需要我们自己安装配置
sudo apt-get install git-core cmake freeglut3-dev pkg-config build-essential libxmu-dev libxi-dev libusb-1.0-0-dev doxygen graphviz mono-complete
mkdir ~/kinect
cd ~/kinect
git clone https://github.com/OpenNI/OpenNI.git
cd OpenNI
git checkout unstable
cd Platform/Linux/CreateRedist/
chmod +x RedistMaker
./RedistMaker
cd ../Redist/OpenNI-Bin-Dev-Linux-x64-v1.5.8.5
sudo ./install.sh
如果出现报错
/bin/sh: 1:javac: not found
make[1]: ***[../../../Bin/x64-Release/org.OpenNI.jar] Error 127
make: ***[Wrappers/OpenNI.java] Error 2
执行
sudo apt-get install openjdk-8-jdk openjdk-8-jre
cd ~/kinect/
git clone https://github.com/ph4m/SensorKinect.git
cd SensorKinect
git checkout unstable
cd Platform/Linux/CreateRedist/
chmod +x RedistMaker
./RedistMaker
cd ../Redist/Sensor-Bin-Linux-x64-v5.1.2.1/
chmod +x install.sh
sudo ./install.sh
OpenNI官网失效了,所以只能在网上下载安装包,链接在此
我下载的是 NITE-Bin-Linux-x64-v1.5.2.23.tar.bz2
cd ~/kinect
tar -xvjpf nite-bin-linux-x64-v1.5.2.23.tar.bz2
cd NITE-Bin-Dev-Linux-x64-v1.5.2.23/Data
在Data文件夹中有三个文件:Sample-Scene.xml Sample-Tracking.xml Sample-User.xml,分别修改三个文件:
将
改为
然后执行
cd ..
sudo ./install.sh
通过以上部分,Kinect V1相机的驱动就已经完全装好了,相机已经可以正常使用了,如果不放心的话,用以下方法检验是否能成功驱动相机
cd ~/kinect/NITE-Bin-Dev-Linux-x64-v1.5.2.23/Samples/Bin/x64-Release
./Sample-PointViewer
将kinect插上电脑,人站在kinect前应该会显示depth图
sudo apt-get remove libopenni-sensor-pointclouds0
sudo apt-get install ros-kinetic-openni-launch
sudo apt-get install ros-kinetic-openni-camera
下面安装openni_tracker,实现骨骼点检测功能的关键库
cd ~/catkin_ws/src
git clone https://github.com/ros-drivers/openni_tracker.git
cd ..
catkin_make
roslaunch openni_launch openni.launch camera:=openni
rosrun openni_tracker openni_tracker
rosrun rviz rviz
注意第一条指令最后的部分(camera:=openni)不要忘记添加
在rviz中,把GlobalOptions > Fixed Frame 改成 openni_depth_optical_frame;
点击Add(左下角),选择PointCloud2,确定;
把PointCloud2 >Topic改成 /openni/depth_registered/points;
再点击Add,选择TF;
在相机前摆出这个姿势
适当调整可视框中的角度和放大倍数,不一会就能看到骨骼点数据了
终端中会出现下面提示
New User 1
Pose Psi detected for user 1
Calibration started for user 1
Calibration complete, start tracking user 1
openni_tracker会提供以下的tf坐标系,可以在rviz中选择显示哪一个或者哪几个
/head
/neck
/torso
/left_shoulder
/left_elbow
/left_hand
/right_shoulder
/right_elbow
/right_hand
/left_hip
/left_knee
/left_foot
/right_hip
/right_knee
/right_foot
查看坐标之间的变换关系(如/torso到/openni_link的坐标变换)
rosrun tf tf_echo openni_link torso_1
也可以自己写一段tf_listener代码
但是要注意在代码中创建监听器后一定要加延时
ros::Duration(10.0).sleep() //延迟10s
不然会报错 passed to lookupTransform argument target_frame does not exist
因为一旦创建了监听器,它就开始通过线路接收tf转换