CCM-SLAM跑自己的USB摄像头
ccm_slam/readme.md
# 5. Using your own Data
For using you own datasets or camera, you need to create according calibration and launch files:
* Create a new camera calibration file, e.g. by copying and adjusting ```conf/vi_euroc.yaml```.
* If you don't know the parameters of your camera, you can find them using a camera calibration toolbox, such as [kalibr](https://github.com/ethz-asl/kalibr).
* Create a new launch file, e.g. by copying and adjusting ```launch/EuRoC/Client0_euroc.yaml```.
* Change the parameter ```cam```to the path of your new camera file.
* Change the parameter ```TopicNameCamSub```to the name of your camera topic.
* Hint: If you have an existing rosbag-file with camera data, you can directly modify the topic when playing the bagfile: ```rosbag play mybag.bag existing_topic:=new_name```
* There is no need to change ```Server.launch```, however, you can adjust the number of Agents in the system by changing ```NumOfClients```. The maximum is set to **4** in the current implementation.
* If you are using a downward-looking camera instead of a forward-looking (as in the EuRoC sequences), it is recommended to change the rotational part of the [static transform publishers](http://wiki.ros.org/tf#static_transform_publisher) in the launch files to ```0 0 -3.142```, e.g. ```<node pkg="tf" type="static_transform_publisher" name="linkS0_broadcaster" args="0 0 5 0 0 -3.142 world odomS0 100" />```.
* There should be no need to change the name of the frame-IDs, such as ```odomC0```.
# 6. Parameters
System parameters are loaded from ```conf/config.yaml```. We explain the functionality of the most important parameters in the following lines:
**Mapping**
* ```Mapping.LocalMapSize```: The Local Map of the Agent is limited to n KFs.
* ```Mapping.LocalMapBuffer```: If LocalMapSize can not be reached, e.g. due to communication loss, there is a buffer of n KFs that is filled before KFs are irreversibly removed from the map.
* ```Mapping.RecentKFWindow```: The most recent n KFs of every map are excluded from KF culling.
* ```Mapping.RedThres```: Threshold for KF redundancy. 1.0 means no KF removal. (We recommend to use a value in the range of [1.0,0.95]. Please refer to the publications for details.)
**Communication**
* ```Comm.Client.PubFreq```: The Agent publishes new data from the local map at this frequency.
* ```Comm.Server.PubFreq```: The Server publishes data for the Agents to augment/update their local map at this frequency.
* ```Comm.Server.KfsToClient```: In every message to one Agent, the Server sends the data of the ```n```closest KFs to the Agent's current position.
* ```Comm.Client.PubMaxKFs```: Maximimum number of KFs per message.
* ```Comm.Client.PubMaxMPs```: Maximimum number of MPs per message.
**Place Recognition**
* ```Placerec.NewLoopThres```: Between two Loop Closures, ```n```KFs need to pass.
* ```Placerec.StartMapMatchingAfterKf```: Map Matching does not consider the first ```n```KFs to ensure enough overlap between two map when matching and merging.
**Visualization**
* ```Viewer.Active```: Activate/Deactivate the visualization functionalities.
* ```Viewer.ScaleFactor```: Scales the visualization. Useful since monocular estimates exhibit arbitrary scale.
**Other**
* ```Stats.WriteKFsToFile```: Write KFs to cslam/output. **Attention**: Before being written to the csv-file, KFs are transformed to the body frame of the robot using the transformation given in the camera calibration file by ```T_imu_cam0```.
如何使用自己的数据
为了使用自己的数据集或相机,您需要创建校准和启动文件:
- 创建一个新的相机校准文件,例如通过复制和调整
cslam/conf/vi_euroc.yaml
。
----* 如果您不知道相机的参数,则可以使用相机校准工具箱找到它们,比如kalibr。 - 创建一个新的启动文件,例如通过复制和调整
cslam/launch/EuRoC/Client0_euroc.launch
。
----* 将参数cam
更改为新相机文件的路径。
----* 将参数TopicNameCamSub
更改为相机主题的名称。
----* 提示:如果您现有一个带有照相机数据的rosbag文件,则可以在播放bagfile时直接修改该主题:rosbag play mybag.bag exist_topic:= new_name
- 无需更改
Server.launch
,但是,您可以通过更改NumOfClients
来调整系统中的代理数量。在当前实现中,最大值设置为4。 - 如果您使用的是向下看的摄像头而不是向前看的摄像头(如EuRoC序列中所示),建议更改[static transform publishers]的旋转部分,在启动文件中将其设置为"0 0 -3.142",例如
<node pkg =“ tf” type =“ static_transform_publisher” name =“ linkS0_broadcaster” args =“ 0 0 5 0 0 -3.142 world odomS0 100” />
。 - 无需更改帧ID的名称,例如
odomC0
。
参数功能
系统参数是从cslam/conf / config.yaml
加载的。我们在以下几行中解释最重要参数的功能:
Mapping建图
-
Mapping.LocalMapSize
: 代理的本地地图限制为n个KF。 -
Mapping.LocalMapBuffer
: 如果无法达到LocalMapSize,例如:由于通信丢失,在将KF不可逆地从地图中删除之前,将填充n个KF的缓冲区。 -
Mapping.RecentKFWindow
: 每张地图的最近n个KF都排除在KF剔除之外。 -
Mapping.RedThres
:KF冗余的阈值,1.0表示不删除KF。 (我们建议使用[1.0,0.95]范围内的值,有关详细信息,请参阅出版物) -
Communication 通信
-
Comm.Client.PubFreq
: 代理以该频率从本地地图发布新数据。 -
Comm.Server.PubFreq
: 服务器以该频率发布数据以供代理增加/更新其本地地图。 -
Comm.Server.KfsToClient
: 在发送给一个代理的每条消息中,服务器都会发送最接近代理当前位置的“ n”个KF的数据。 -
Comm.Client.PubMaxKFs
: 每条信息(message)的KF数上限。 -
Comm.Client.PubMaxMPs
: 每条信息(message)的MP数上限。 -
Place Recognition位置识别
-
Placerec.NewLoopThres
: 在两个闭环之间,需要通过`n’个KF。 -
Placerec.StartMapMatchingAfterKf
: 地图匹配不考虑前面n个KF,以确保在匹配和合并时两个地图之间有足够的重叠。
Visualization可视化
Viewer.Active
: 激活/停用可视化功能。Viewer.ScaleFactor
: 缩放可视化效果。单目有效。
Other其他
Stats.WriteKFsToFile
: 将KF写入cslam /输出。 注意: 在将KF写入csv文件之前,使用T_imu_cam0
摄像机校准文件中给出的转换将KF转换为机器人的body坐标系。
尝试
假设已经在工作空间~/ccmslam_ws
配置好CCM-SLAM 了
调用usb摄像头
进入ccmslam的工作空间,在src下下载usb_cam源文件到此目录下:
cd ~/ccmslam_ws/src
git clone https://github.com/bosch-ros-pkg/usb_cam.git
cd ..
catkin_make
如果失败的话用:
catkin_make_isolated
修改摄像头启动文件usb_cam-test.launch
启动文件在目录~/ccmslam_ws/src/usb_cam/launch/usb_cam-test.launch
下
修改为:
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video2" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="mjpeg" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>
</launch>
其中主要修改的是
<param name="video_device" value="/dev/video2" />
<param name="pixel_format" value="mjpeg" />
<remap from="image" to="/usb_cam/image_raw"/>
第一行是把连接的usb摄像头加上,不同的摄像头这个地址不同。
第二行是为了不让输出图像花屏。
第三行是将图像输出话题调整。
测试摄像头
source ~/ccmslam_ws/devel/setup.bash
roslaunch usb_cam usb_cam-test.launch
修改Client0_euroc.launch
原文件:
<?xml version="1.0"?>
<launch>
<arg name="dist" default="0"/>
<arg name="cam" default="$(find ccmslam)/conf/vi_euroc.yaml"/>
<group ns="ccmslam">
<node pkg="tf" type="static_transform_publisher" name="linkC0_broadcaster" args="-100 300 5 -1.571 0 -2 world odomC0 100" />
<node pkg="ccmslam" type="ccmslamClientNode" name="ccmslamClientNode0" args="$(find ccmslam)/conf/ORBvoc.txt $(arg cam)" output="screen">
<!-- ++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Agent Specific Params - !!!MUST BE ADJUSTED!!! -->
<param name="~FrameId" type="string" value="odomC0" />
<param name="~ClientId" type="int" value="0" />
<param name="~TopicNameCamSub" type="string" value="/cam0/image_raw" />
<param name="~MapInTopicName" type="string" value="MapOutServer0" unless="$(arg dist)" />
<param name="~MapInTopicName" type="string" value="MapOutServer0Disturbed" if="$(arg dist)" />
</node>
</group>
</launch>
相机文件.yaml暂时不修改,仍使用/conf/vi_euroc.yaml
。
将参数cam
更改为新相机文件的路径:
即,将
<param name="~TopicNameCamSub" type="string" value="/cam0/image_raw" />
改为:
<param name="~TopicNameCamSub" type="string" value="/usb_cam/image_raw" />
编写启动文件
编写ccm-usb.sh
:
gnome-terminal -t "cam" -x bash -c "source ~/ccmslam_ws/devel/setup.bash;roslaunch usb_cam usb_cam-test.launch;exec bash;"
sleep 3
gnome-terminal -t "server" -x bash -c "roslaunch ccmslam Server.launch;exec bash;"
sleep 3
gnome-terminal -t "agent0" -x bash -c "roslaunch ccmslam Client0_euroc.launch;exec bash;"
sleep 3
gnome-terminal -t "rviz" -x bash -c "roscd ccmslam ;rviz -d conf/rviz/ccmslam.rviz ;exec bash;"
启动
命令行输入:
chmod +x ccm-usb.sh
sh ccm-usb.sh
自动开启摄像头、服务端、代理0、rviz。
在rviz中,点击File ->Open Config
,选择~/ccmslam_ws/src/ccm_slam/cslam/conf/rviz/ccmslam.rviz
下方点击add
添加可视项目bytopic。
缓慢移动摄像头开始运行CCMSLAM:
建图结果:
成功了,(^-^)V
后续可以将rviz配置文件保存到桌面,方便直接打开。可以将ccm-usb.sh
中的
gnome-terminal -t "rviz" -x bash -c "roscd ccmslam ;rviz -d conf/rviz/ccmslam.rviz ;exec bash;"
修改为:
gnome-terminal -t "rviz" -x bash -c "roscd ccmslam ;rviz -d [你的rviz配置文件地址] ;exec bash;"
方便打开rviz时直接启动相应配置文件。
添加多个Client同理。
转载请备注:https://blog.csdn.net/klsjadkls/article/details/115856515