1. 系统环境
- Ubuntu16.04
- ROS-Kinetic
- Python 2.7
2. 安装
2.1 创建squeezeseg虚拟环境
conda create -n squeezeseg python=2.7
# 激活虚拟环境
source activate squeezeseg
注意:下面的操作都在虚拟环境中执行
2.2 安装依赖
pip install easydict==1.6
pip install joblib==0.10.3
pip install numpy==1.16.1
pip install Pillow==4.0.0
pip install tensorflow-gpu==1.0.0
pip install tensorflow==1.0.0
#因为我在后面运行的时候会报tensorflow出错,所以又安装了cpu版本的tensorflow
2.3 下载SqueezeSeg_Ros
SqueezeSeg_Ros源程序地址:https://github.com/AbangLZU/SqueezeSeg_Ros。
放在工作空间中编译。
2.4 运行:
由于直接执行:roslaunch squeezeseg_ros squeeze_seg_ros.launch
出现了下面两个错误:
第一个错误是:
import tensorflow as tf
ImportError: No module named tensorflow
明明已经安装了tensorflow,却总是提醒不能导入tensorflow模块,导致节点不能正常启动。
第二个错误是:
[ERROR] [1556797434.210039200]: PluginlibFactory: The plugin for class ‘rviz_plugin_selected_points_publisher/SelectedPointsPublisher’ failed to load. Error: According to the loaded plugin descriptions the class rviz_plugin_selected_points_publisher/SelectedPointsPublisher with base class type rviz::Tool does not exist. Declared types are jsk_rviz_plugin/CloseAll jsk_rviz_plugin/OpenAll jsk_rviz_plugin/OverlayPicker jsk_rviz_plugin/ScreenshotListener rviz/FocusCamera rviz/Interact rviz/Measure rviz/MoveCamera rviz/PublishPoint rviz/Select rviz/SetGoal rviz/SetInitialPose rviz_plugin_tutorials/PlantFlag
大概意思是Rviz的某个插件出现了问题,不能正常启动。
所以参考此博客先进行一些修改:
- 打开launch文件,将squeezeseg_ros节点以及Rviz的启动部分注释掉,然后执行:
roslaunch squeezeseg_ros squeeze_seg_ros.launch
此时数据的路径等配置会被写入。
- 进入srcipt文件夹,直接使用python2启动squeezeseg_ros_node.py文件:
cd ~/catkin_ws/src/SqueezeSeg_Ros/script
python squeezeseg_ros_node.py
得到如下图的情况,说明节点已经启动:
[INFO] [1614072451.492779]: Point cloud processed. Took 241.734000 ms.
[INFO] [1614072451.665434]: Point cloud processed. Took 172.866000 ms.
[INFO] [1614072451.840346]: Point cloud processed. Took 175.159000 ms.
[INFO] [1614072452.017152]: Point cloud processed. Took 177.005000 ms.
[INFO] [1614072452.194837]: Point cloud processed. Took 177.914000 ms.
[INFO] [1614072452.365629]: Point cloud processed. Took 171.038000 ms.
[INFO] [1614072452.559498]: Point cloud processed. Took 194.111000 ms.
[INFO] [1614072452.733044]: Point cloud processed. Took 173.809000 ms.
[INFO] [1614072452.904046]: Point cloud processed. Took 171.244000 ms.
[INFO] [1614072453.078510]: Point cloud processed. Took 174.690000 ms.
[INFO] [1614072453.254257]: Point cloud processed. Took 175.957000 ms.
[INFO] [1614072453.433785]: Point cloud processed. Took 179.744000 ms.
[INFO] [1614072453.621945]: Point cloud processed. Took 188.380000 ms.
[INFO] [1614072453.813024]: Point cloud processed. Took 191.308000 ms.
[INFO] [1614072453.986304]: Point cloud processed. Took 173.454000 ms.
[INFO] [1614072454.173566]: Point cloud processed. Took 187.464000 ms.
[INFO] [1614072454.356452]: Point cloud processed. Took 183.120000 ms.
[INFO] [1614072454.539483]: Point cloud processed. Took 183.268000 ms.
[INFO] [1614072454.728233]: Point cloud processed. Took 188.993000 ms.
[INFO] [1614072454.919899]: Point cloud processed. Took 191.853000 ms.
[INFO] [1614072455.140920]: Point cloud processed. Took 221.126000 ms.
2.5 打开Rviz
进行查看:
使用add添加上述主题,类型为PointCloud2
,固定坐标(Fixed Frame
)设置为velodyne_link
,讲Channel Name
设置为label
,即可得到识别分割图像:
参考: