1、下载ros包或者自己去github
如果不能科学上网,可以在这里下载所有源代码。
下载链接:https://download.csdn.net/download/ryanji/87990936
git clone https://github.com/orbbec/ros_astra_camera.git
git clone https://github.com/libuvc/libuvc.git
2、安装依赖
sudo apt install libgflags-dev ros-$ROS_DISTRO-image-geometry ros-$ROS_DISTRO-camera-info-manager ros-$ROS_DISTRO-image-transport ros-$ROS_DISTRO-image-publisher libgoogle-glog-dev libusb-1.0-0-dev libeigen3-dev ros-$ROS_DISTRO-astra-camera ros-$ROS_DISTRO-astra-launch ros-$ROS_DISTRO-libuvc-* ros-$ROS_DISTRO-rgbd-launch
(1)、在openNI驱动包中进行下列操作
cd OpenNI-Linux-x64-2.3
sudo chmod a+x install.sh
sudo ./install.sh
插拔摄像头之后
source OpenNIDevEnvironment
编译
cd Samples/SimpleViewer
make
连接设备,执行示例
cd Bin/x64-Release
./SimpleViewer
此时可以看到深度图像
假如没有图像,确认已重新插拔。再不行执行命令
sudo apt-get install build-essential freeglut3 freeglut3-dev
ldconfig -p | grep libudev.so.1
cd /lib/x86_64-linux-gnu
sudo ln -s libudev.so.x.x.x libudev.so.1
(2)、在libuvc驱动包中进行下列操作
cd libuvc
mkdir build && cd build
cmake .. && make -j
sudo make install
sudo cp /usr/include/libusb-1.0/libusb.h /usr/local/include/libuvc/
sudo ldconfig
3、创建ros工作区
mkdir -p ~/ros_ws/src
- 将开头下载的src包ros_astra_camera放入工作区
cd ~/ros_ws/src
- Build
cd ~/ros_ws
catkin_make
- 安装udev
cd ~/ros_ws
source ./devel/setup.bash
roscd astra_camera
./scripts/create_udev_rules
sudo udevadm control --reload && sudo udevadm trigger
- 编辑source ~/.bashrc
echo "source ~/ros_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
4、打开相机
- 深度图大小640*480
- 修改astra_pro.launch文件
lsusb
会得到usb列表
其中0502是彩色图的usb接口,0403是深度图接口。将launch文件里的对应product_id改成你自己电脑上的接口即可。
- 在launch文件夹下新建一个uvc_camera.launch
内容如下
<launch>
<node pkg="uvc_camera" type="uvc_camera_node" name="uvc_camera" output="screen">
<param name="device" type="string" value="/dev/video4" />
<param name="width" type="int" value="640" />
<param name="height" type="int" value="480" />
<param name="fps" type="int" value="30" />
<param name="frame_id" type="string" value="camera_rgb_optical_frame" />
</node>
</launch>
通过插拔摄像头确定 device 的id
ls dev 可以看到,基本上是/dev/video,后面的数字会改变。
sudo apt-get install uvc_camera
如果安装不了,无视即可,继续往下走。
- 打开terminal 1
source ./devel/setup.bash
roslaunch astra_camera uvc_camera.launch
roslaunch astra_camera astra_pro.launch - 打开terminal 2
source ./devel/setup.bash
rviz
添加image,topic是/image_raw
添加pointcloud2,topic是/camera/depth/points
可以看到图像和点云,记得把fixed_frame设置成camera
后续都是参数调整,可以不看
5、参数设置
rosrun rqt_reconfigure rqt_reconfigure
- 选择topics / services/ parameters
rostopic list
rosservice list
rosparam list - 相机的 extrinsic parameter
rostopic echo /camera/extrinsic/depth_to_color - 获得相机参数
rosservice call /camera/get_camera_params “{}”
设置曝光
- 打开ir流。默认ir_exposure是3000,uvc_exposure是157。
- 设置曝光值
rosservice call /camera/set_uvc_auto_exposure ‘{data: false}’
rosservice call /camera/set_ir_auto_exposure “{data: false}”
rosservice call /camera/set_ir_exposure “{data: 3000}”
rosservice call /camera/set_uvc_exposure “{data: 157}”
rosservice call /camera/get_ir_exposure “{}”
rosservice call /camera/get_uvc_exposure “{}”
设置增益 - 打开ir流。默认ir_gain是2000,uvc_gain是0。
- 设置增益值
Get Gain
rosservice call /camera/get_ir_gain ‘{}’ # OpenNI camera
rosservice call /camera/get_uvc_gain “{}” # UVC camera
rosservice call /camera/set_ir_gain “{data: 2000}”
roservice call /camera/set_uvc_gain “{data: 0}”