ubuntu18.04 ROS配置AstraPro深度摄像头
参考资料:《ROS by example 1》1.下载驱动和安装依赖sudo apt-get install build-essential freeglut3 freeglut3-devldconfig -p | grep libudev.so.1cd /lib/x86_64-linux-gnusudo ln -s libudev.so.x.x.x libudev.so.1 如果已经有了就忽略此
欢迎交流,QQ群:172410964或博客留言,坐标:重庆
参考资料:《ROS by example 1》
1.下载驱动和安装依赖
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 如果已经有了就忽略此步 现有的:libudev.so.1 -> libudev.so.1.6.9
2.编译驱动
解压下载的OpenNI-Linux-x64-2.3驱动OpenNI-Linux-x64-2.3.tar.bz2
$ cd OpenNI_2.3.0.55/Linux/OpenNI-Linux-x64-2.3.0.55
$ sudo chmod a+x install.sh
安装
$ sudo ./install.sh
插拔摄像头,source环境
$ source OpenNIDevEnvironment
编译
$ cd Samples/SimpleViewer
$ make
连接设备,执行示例
$ cd Bin/x64-Release
$ ./SimpleViewer
编译安装libuvc
先安装依赖和工具:
sudo apt install cmake
sudo apt-get install libusb-1.0
sudo apt-get install libjpeg9-dev
sudo apt-get install pkg-config
$ git clone https://github.com/ktossell/libuvc
$ cd libuvc
$ mkdir build
$ cd build
$ cmake ..
$ make && sudo make install
$ sudo cp /usr/include/libusb-1.0/libusb.h /usr/local/include/libuvc/
3.安装ROS和官方astra_launch astra_camera libuvc rgbd包
ubuntu安装ROS
先安装aptitude: sudo apt install aptitude
添加 sources.list
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.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'
添加 keys
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
或sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
如果出现由于没有公钥,无法验证下列签名: NO_PUBKEY F42ED6FBAB17C654
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
解决apt-get install E: 无法定位软件包问题,在软件和更新里的其他软件添加镜像源 deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse
然后 sudo apt-get update 接着安装就可以了
安装ubuntu18.04对应的ROS版本,依赖包会一起安装完成
sudo apt-get install ros-melodic-desktop-full
sudo apt-get install ros-melodic-rqt*
sudo rosdep init
如果不能下载就安装: sudo apt install python-rosdep 和 sudo apt-get install python3-rosdep
rosdep update
$ sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
以下这些包melodic没有,需要从源码安装
$ sudo apt-get install ros-melodic-astra-camera
$ sudo apt-get install ros-melodic-astra-launch
$ sudo apt-get install ros-melodic-libuvc-*
$ sudo apt-get install ros-melodic-rgbd-launch
获取源码
打开工作空间的~/catkin_ws/src目录,执行git clone https://github.com/orbbec/ros_astra_launch.git和git clone https://github.com/orbbec/ros_astra_camera.git
catkin_make编译即可
ros的命令运行提示找不到的情况下 安装如下
sudo aptitude install python-roslaunch
加载环境设置文件
source /opt/ros/melodic/setup.bash
创建并初始化工作目录
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/
catkin_make
设置环境变量:
sudo apt install net-tools
gedit ~/.bashrc
#######################################
# Set ROS melodic
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bash
# Set ROS Network
export ROS_MASTER_URI=http://localhost:11311
export ROS_HOSTNAME=localhost
# Set ROS alias command 快捷指令
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'
################################################
source ~/.bashrc
小海龟测试,打开三个终端:
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
4.插入相机查看设备向量ID
lsusb
Bus 003 Device 009: ID 2bc5:0502
Bus 003 Device 008: ID 2bc5:0403
其中2bc5:0403是深度模块
2bc5:0502是RGB模块
再看查看launch启动文件
启动文件是
~/catkin_ws/src/ros_astra_camera/launch/astrapro.launch
打开翻到第68行内容如下
这里的值是0x0501;而我的设备是0x0502,修改为0x0502
启动launch文件
source catkin_ws/devel/setup.bash
roslaunch ~/catkin_ws/src/ros_astra_camera/launch/astrapro.launch
打开新的终端用rviz或者rqt_image_view 预览RGB图和深度图
5.ubuntu for ROS安装PCL(似乎在安装ROS的时候已经安装了PCL,不需要重复安装,需要验证)
依赖项安装,新建一个脚本文件:touch install.sh,内容如下:
sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev \
sudo apt-get install cmake cmake-gui \
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev \
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common \
sudo apt-get install libflann1.8 libflann-dev \
sudo apt-get install libeigen3-dev \
sudo apt-get install libboost-all-dev \
sudo apt-get install libvtk5.10-qt4 libvtk5.10 libvtk5-dev \
sudo apt-get install libqhull* libgtest-dev \
sudo apt-get install freeglut3-dev pkg-config \
sudo apt-get install libxmu-dev libxi-dev \
sudo apt-get install mono-complete \
sudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre
catkin_ws/src目录下克隆 git clone https://github.com/PointCloudLibrary/pcl.git
CMakeList.txt添加如下支持c++11
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
在pcl文件中建立并进入build目录
$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON ..
$ make -j4
$ sudo make install
卸载pcl
sudo rm -r /usr/include/pcl-1.7 /usr/share/pcl /usr/bin/pcl* /usr/lib/libpcl*
sudo rm -r /usr/lib/x86_64-linux-gnu/cmake/pcl
sudo rm -r /usr/share/doc/libpcl*
sudo rm -r /usr/lib/x86_64-linux-gnu/pkgconfig/pcl*
sudo rm -r /usr/local/include/pcl-1.9 /usr/local/share/pcl* /usr/local/bin/pcl* /usr/local/lib/libpcl*
sudo rm -r /usr/local/lib/pkgconfig/pcl*
应用程序CmakeList.txt中添加:
find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
应用程序编译:
创建ROS程序包
cd catkin_ws/src
catkin_create_pkg imgpcl std_msgs rospy roscpp sensor_msgs image_transport pcl_conversions pcl_ros pcl_msgs
cd imgPcl
cd src//在此创建.cpp文件
source ./devel/setup.bash
catkin_make
运行
roscore
启动摄像头
source ./devel/setup.bash
roslaunch ~/catkin_ws/src/ros_astra_camera/launch/astrapro.launch
运行程序
source ./devel/setup.bash
rosrun imgpcl display_points input:=/camera/depth/points
预览图像
rosrun rviz rviz
数据格式转换:
pcl::PointCloud::Ptr cloud_Ptr(new pcl::PointCloud);
pcl::PointCloud cloud;
cloud=*cloud_Ptr;
cloud_Ptr=cloud.makeShared;
环境软件工具版本:
GCC v9
libc v2.30
~/catkin_ws/src/ros_astra_camera/launch/astrapro.launch
GDB debug
launch-prefix="xterm -e gdb -ex run --args"
astra pro相机标定
$ roslaunch astra_launch astrapro.launch
$ rosrun camera_calibration cameracalibrator.py image:=/camera/depth/image camera:=/camera/ir --size 8x6 --square 0.024
rosrun camera_calibration cameracalibrator.py image:=/camera/ir/image camera:=/camera/ir --size 8x6 --square 0.024
错误处理:
1. Could NOT find move_base_msgs (missing: move_base_msgs_DIR)
sudo apt install ros-melodic-move-base-msgs -y
2. *** 没有规则可制作目标“/usr/lib/x86_64-linux-gnu/libGL.so”
找到 libGL.so.1.0.0 文件的目录,在此目录下建立软链接 sudo ln -s libGL.so.1.0.0 libGL.so
更多推荐
所有评论(0)