首先安装摄像头驱动,参照这个网址进行配置:https://github.com/orbbec/ros_astra_camera
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
cd ~/catkin_ws
touch install.sh
将以下代码复制到install.sh文件中
#!/bin/bash
# Varibles
rosversion="kinetic"
# Install the ros
if [ `id -u` == 0 ]; then
echo "Don't running this use root(sudo)."
exit 0
fi
echo "Start to install the ros, http://wiki.ros.org/$rosversion/Installation/Ubuntu"
echo "Update the software list"
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
echo "Install the ros from apt"
sudo apt-get install ros-$rosversion-desktop-full -y
sudo rosdep init
rosdep update
echo "Setup the ROS environment variables"
echo -e "if [ -f /opt/ros/kinetic/setup.bash ]; then\n\tsource /opt/ros/kinetic/setup.bash\nfi" >> ~/.bashrc
echo "source ~/racecar/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
echo "Install the rosinstall"
sudo apt-get install python-rosinstall -y
echo "Install the ssh"
sudo apt-get install ssh -y
echo "Install the ntpdate"
sudo apt-get install ntpdate -y
echo "Install the chrony"
sudo apt-get install chrony -y
# Install the dependecies for the project
echo "Start to config for the project"
#echo "Install the python dependecies"
#sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose -y
#echo "Install the eigen3"
#sudo apt install libeigen3-dev -y
#echo "Install the nlopt"
#sudo apt install libnlopt* -y
echo "Install the ROS package for art_racecar"
sudo apt-get install ros-$rosversion-joy -y
sudo apt-get install ros-$rosversion-move-base -y
sudo apt-get install ros-$rosversion-mrpt* -y
sudo apt-get install ros-$rosversion-geographic-msgs -y
sudo apt-get install ros-$rosversion-map-server -y
sudo apt-get install ros-$rosversion-gmapping -y
sudo apt-get install ros-$rosversion-amcl -y
sudo apt-get install ros-$rosversion-rviz-imu-plugin -y
sudo apt-get install ros-$rosversion-dwa-local-planner -y
echo "--Finish"
然后给予install.sh文件权限,并运行,该过程需要下载一些文件,可能会比较耗时,视网速而定!!!
sudo chmod +x ./install.sh
./install.sh
运行结束输入以下命令进行验证
roscore
若出现一下情况则说明安装成功
此时查看bashrc文件发现ros与当前的ros工作空间已加入文档中
sudo apt install ros-$ROS_DISTRO-rgbd-launch ros-$ROS_DISTRO-libuvc ros-$ROS_DISTRO-libuvc-camera ros-$ROS_DISTRO-libuvc-ros
cd ~/catkin_ws/src
git clone https://github.com/orbbec/ros_astra_camera
roscd astra_camera
./scripts/create_udev_rules
cd ~/catkin_ws
catkin_make --pkg astra_camera
roslaunch astra_camera astra.launch
rostopic list
rviz
查看深度图
查看rgb图
发现没有rgb图像!!!
有以下两种解决方案:
打开launch文件夹下的astra.launch文件,加入以下代码
<node pkg="uvc_camera" type="uvc_camera_node" name="uvc_camera" output="screen" />
<param name="width" type="int" value="320" />
<param name="height" type="int" value="240" />
<param name="fps" type="int" value="30" />
<param name="frame" type="string" value="wide_stereo" />
<param name="auto_focus" type="bool" value="False" />
<param name="focus_absolute" type="int" value="1" />
<!-- other supported params: auto_exposure, exposure_absolute, brightness, power_line_frequency -->
<param name="device" type="string" value="/dev/video2" />
<param name="camera_info_url" type="string" value="file://$(find uvc_camera)/example.yaml" />
保存并重新编译,运行查看
在astrapro.launch中有如下代码
<!-- Push down all topics/nodelets into "camera" namespace -->
<group ns="$(arg camera)">
<node pkg="astra_camera" type="camera_node" name="$(arg camera)_rgb">
<!-- Parameters used to find the camera -->
<param name="vendor" value="0x2bc5"/>
<param name="product" value="0x0501"/>
<param name="serial" value="0"/>
<!-- If the above parameters aren't unique, choose the first match: -->
<param name="index" value="$(arg index)"/>
可以看到这里是通过vendor向量和product ID号来确定打开的设备
查看我们设备的信息
lsusb
其中2bc5:0403是深度摄像头的,2bc5:0502是rgb摄像头的
将次句的0x0501改为我们设备的0x0502
<param name="product" value="0x0501"/> //更改前
<param name="product" value="0x0502"/> //更改后
保存编译,运行测试
roslaunch astra_camera astrapro.launch
cd catkin_ws/src
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
./build.sh
rgbd_dataset_freiburg1_xyz(提取码: 6gmw)
运行RGB-D测试程序,查看REANME.md,给出以下参考命令
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUMX.yaml PATH_TO_SEQUENCE_FOLDER ASSOCIATIONS_FILE
因为我使用的是rgbd_dataset_freiburg1_xyz序列,所以将TUMX.yaml改为 TUM1.yaml。
我的序列存储路径为:
PATH_TO_SEQUENCE_FOLDER = Data/rgbd_dataset_freiburg1_xyz
ASSOCIATIONS_FILE = Data/rgbd_dataset_freiburg1_xyz/associate.txt
由于代码默认订阅的话题跟我们摄像头发布的话题可能不同,所以需要更改ORB_SLAM2订阅的ros话题
cd ~/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src
gedit ros_rgbd.cc
将/camera/rgb/image_raw更改为我们摄像头的发布的rgb话题
将camera/depth_registered/image_raw更改为我们摄像头的发布的depth话题
更改完保存编译
cd ORB_SLAM2
./build_ros.sh
打开摄像头
roslaunch astra_camera astrapro.launch
运行RGB-D,查看REANME.md,给出以下参考命令
rosrun ORB_SLAM2 RGBD PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
我的序列存储路径为:
PATH_TO_VOCABULARY = /home/al007/Orbbec_Astra_Pro_Linux/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt
PATH_TO_SETTINGS_FILE = /home/al007/Orbbec_Astra_Pro_Linux/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml
运行结果如下:
1)摄像头标定时所处的平面位置一旦改变,一般会影响相机内参,需重新标定
2)将标定后的参数替换相机原有的内参,重新跑一遍即可
参考博客:
https://blog.csdn.net/qq_36219010/article/details/100084777
https://blog.csdn.net/u010312937/article/details/78759107?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
https://blog.csdn.net/qq_36219010/article/details/96559248?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task