系统:Ubuntu 18.04 64位,ROS:melodic
安装basler单目相机驱动之前需要安装ROS,安装过程见我之前发的博客,一定要确保rosdep update
成功,否则可能会导致安装失败。
1.创建工作空间,以catkin_ws
为例,进入到src
文件夹目录下并下载
cd ~/catkin_ws/src
git clone https://github.com/basler/pylon-ros-camera
git clone https://github.com/dragandbot/dragandbot_common.git
相机相关参数设置的软件安装包去这个地址下载,现在我们一般用的是6.1.1版本
的。
此处相机相关的安装包,也可在百度网盘下载,链接如下:
链接:https://pan.baidu.com/s/1GY-CIZ10C80nkDuLlKQZUQ
提取码:ankf
2.安装单目相机参数设置的软件,以6.1.1版本
为例
sudo dpkg -i /home/xxx/xxx/pylon_5.0.12.11829-deb0_amd64
echo "export PYLON=/opt/pylon" >> ~/.bashrc
source ~/.bashrc
echo $PYLON_ROOT
注意:进入下边这个文件,检查第三行set(PYLON_ROOT "/opt/pylon5")
中的5是否存在,若存在则删除保存退出。
gedit ~/catkin_ws/src/pylon-ros-camera/pylon_camera/cmake/FindPylon.cmake
3.编译
cd ~/catkin_ws
catkin_make clean
catkin_make
如果报错:AttributeError: module 'em' has no attribute 'Interpreter'
,解决方案:
pip uninstall em
pip install empy
4.设置环境变量
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
5.运行
连接好相机后,首先通过系统设置——网络——有线——选项,更改IPv4设置,将方法改为“仅本地连接”。
cd ~/catkin_ws
source devel/setup.bash
roslaunch pylon_camera pylon_camera_node.launch
之前的终端不要关,另开终端:Ctrl+Shift+T
,输入命令:rostopic list
可查看pylon_camera_node
发布的话题,其中/pylon_camera_node/image_raw即发布的图像数据,消息形式为sensor::msgs/Image。
然后输入命令:
rosrun image_view image_view image:=/pylon_camera_node/image_raw
即可在弹出的可视化窗口中看到图像。觉得之前输入的命令太麻烦不容易记,提供第二种方法【前提是安装了rqt,不过基本都是ros自带】,终端输入rqt,在弹出的窗口中,左上角Plugins——Visualization——Image VIew
,点击后在左上方的一个下拉框中选择/pylon_camera_node/image_raw
,即可看到图像了,到此basler相机的ROS驱动程序pylon_ros_camera安装完成。
参考:
1.https://github.com/basler/pylon-ros-camera 此地址提供下载源码,安装编译的步骤,以及一些feature的介绍。
2.https://www.baslerweb.com/cn/sales-support/downloads/document-downloads/interfacing-basler-cameras-with-ros/
此文档为basler官方文档,也提供了十分详细的安装步骤,建议下载下来仔细看看。