使用ZED运行RTABMAP(debugging)

很多教程告诉我们只要运行下面两个代码就可以直接的用zed手持建图

1.roslaunch zed_wrapper zed.launch camera_model:=zed
2.roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" rgb_topic:=/zed/zed_node/rgb/image_rect_color depth_topic:=/zed/zed_node/depth/depth_registered camera_info_topic:=/zed/zed_node/rgb/camera_info frame_id:=base_link approx_sync:=false visual_odometry:=false odom_topic:=/zed/zed_node/odom

首先我要说明,上面这句话声明的topic名,的确与roslaunch zed_wrapper zed.launch camera_model:=zed的topic名字相同,所以有错的话,应该不是这些topic名字不对,和rtabmap不对应的关系。
可是当我运行上面代码的时候,发现如下报错

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

提示了内存溢出
下面是报红的错误,

[rtabmap/rtabmapviz-2] process has died [pid 8312, exit code -6, cmd /home/asber/catkin_ws/devel/lib/rtabmap_ros/rtabmapviz -d ~/.ros/rtabmap_gui.ini rgb/image:=/zed/zed_node/rgb/image_rect_color depth/image:=/zed/zed_node/depth/depth_registered rgb/camera_info:=/zed/zed_node/rgb/camera_info rgbd_image:=rgbd_image_relay left/image_rect:=/stereo_camera/left/image_rect_color right/image_rect:=/stereo_camera/right/image_rect left/camera_info:=/stereo_camera/left/camera_info right/camera_info:=/stereo_camera/right/camera_info scan:=/scan scan_cloud:=/scan_cloud odom:=/zed/zed_node/odom __name:=rtabmapviz __log:=/home/asber/.ros/log/8b2f382e-3928-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmapviz-2.log].
log file: /home/asber/.ros/log/8b2f382e-3928-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmapviz-2*.log

pid 8312, exit code -6, cmd /home/asber/catkin_ws/devel/lib/rtabmap_ros/rtabmapviz -d ~/.ros/rtabmap_gui.ini
这句话只是表明我们要执行这个线程的时候错误了,线程终止
rgb/image:=/zed/zed_node/rgb/image_rect_color
depth/image:=/zed/zed_node/depth/depth_registered
rgb/camera_info:=/zed/zed_node/rgb/camera_info
rgbd_image:=rgbd_image_relay #我们没有rgbd,是双目
left/image_rect:=/stereo_camera/left/image_rect_color #此处topic不对,应该是/zed/zed_node/left/image_rect_color
right/image_rect:=/stereo_camera/right/image_rect #此处topic不对,应该是/zed/zed_node/right/image_rect_color
left/camera_info:=/stereo_camera/left/camera_info #此处topic不对,应该是/zed/zed_node/left/camera_info
right/camera_info:=/stereo_camera/right/camera_info #此处topic不对,应该是/zed/zed_node/right/camera_info
scan:=/scan #貌似没有
scan_cloud:=/scan_cloud #貌似没有
odom:=/zed/zed_node/odom
__name:=rtabmapviz

这里的topic有四个没指定对
roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="–delete_db_on_start" rgb_topic:=/zed/zed_node/rgb/image_rect_color depth_topic:=/zed/zed_node/depth/depth_registered camera_info_topic:=/zed/zed_node/rgb/camera_info frame_id:=base_link approx_sync:=false visual_odometry:=false odom_topic:=/zed/zed_node/odom left/image_rect:=/zed/zed_node/left/image_rect_color right/image_rect:=/zed/zed_node/right/image_rect_color left/camera_info:=/zed/zed_node/left/camera_info right/camera_info:=/zed/zed_node/right/camera_info
可是实验就算是这样还是报错,而且报错的内容一模一样,没有把我添加的
left/image_rect:=/zed/zed_node/left/image_rect_color right/image_rect:=/zed/zed_node/right/image_rect_color left/camera_info:=/zed/zed_node/left/camera_info right/camera_info:=/zed/zed_node/right/camera_info
进行修改
下面是第二个报错

[rtabmap/rtabmap-1] process has died [pid 8311, exit code -11, cmd /home/asber/catkin_ws/devel/lib/rtabmap_ros/rtabmap --delete_db_on_start rgb/image:=/zed/zed_node/rgb/image_rect_color depth/image:=/zed/zed_node/depth/depth_registered rgb/camera_info:=/zed/zed_node/rgb/camera_info rgbd_image:=rgbd_image_relay left/image_rect:=/stereo_camera/left/image_rect_color right/image_rect:=/stereo_camera/right/image_rect left/camera_info:=/stereo_camera/left/camera_info right/camera_info:=/stereo_camera/right/camera_info scan:=/scan scan_cloud:=/scan_cloud user_data:=/user_data user_data_async:=/user_data_async gps/fix:=/gps/fix tag_detections:=/tag_detections odom:=/zed/zed_node/odom imu:=/imu/data __name:=rtabmap __log:=/home/asber/.ros/log/8b2f382e-3928-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmap-1.log].
log file: /home/asber/.ros/log/8b2f382e-3928-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmap-1*.log

这是网上看到的第二个教程

启动zed
// A) With rtabmap odometry:
$ export ROS_NAMESPACE=camera
$ roslaunch zed_wrapper zed_camera.launch publish_tf:=false
 
// B) With zed odometry:
$ export ROS_NAMESPACE=camera
$ roslaunch zed_wrapper zed_camera.launch

这里的namespce要和rtabmap.launch中的保持一致。

  
  
  
  
  

启动rtab_map

     // A) With rtabmap odometry
     $ roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" depth_topic:=/camera/depth/depth_registered frame_id:=zed_camera_center approx_sync:=false
     
     // B) With zed odometry
     $ roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" depth_topic:=/camera/depth/depth_registered frame_id:=zed_camera_center approx_sync:=false visual_odometry:=false odom_topic:=/camera/odom

首先这里的topic和上面不一样,就是错的了,所以会一直报错

[ WARN] [1579267742.962219658]: /rtabmap/rgbd_odometry: Did not receive data since 5 seconds! Make sure the input topics are published ("$ rostopic hz my_topic") and the timestamps in their header are set. Parameter "approx_sync" is false, which means that input topics should have all the exact timestamp for the callback to be called.
/rtabmap/rgbd_odometry subscribed to (exact sync):
   /camera/rgb/image_rect_color,
   /camera/depth/depth_registered,
   /camera/rgb/camera_info
[ WARN] [1579267744.298012924]: /rtabmap/rtabmapviz: Did not receive data since 5 seconds! Make sure the input topics are published ("$ rostopic hz my_topic") and the timestamps in their header are set. If topics are coming from different computers, make sure the clocks of the computers are synchronized ("ntpdate"). Parameter "approx_sync" is false, which means that input topics should have all the exact timestamp for the callback to be called.
/rtabmap/rtabmapviz subscribed to (exact sync):
   /rtabmap/odom,
   /camera/rgb/image_rect_color,
   /camera/depth/depth_registered,
   /camera/rgb/camera_info,
   /rtabmap/odom_info
[ WARN] [1579267745.598941368]: /rtabmap/rtabmap: Did not receive data since 5 seconds! Make sure the input topics are published ("$ rostopic hz my_topic") and the timestamps in their header are set. If topics are coming from different computers, make sure the clocks of the computers are synchronized ("ntpdate"). Parameter "approx_sync" is false, which means that input topics should have all the exact timestamp for the callback to be called.
/rtabmap/rtabmap subscribed to (exact sync):
   /rtabmap/odom,
   /camera/rgb/image_rect_color,
   /camera/depth/depth_registered,
   /camera/rgb/camera_info,
   /rtabmap/odom_info

我去看了一下rtabmap.launch

     

所以第一个程序会有frame_id:=base_link的参数
以及我还看到了


  
  
  
        
  
  

这也就是为什么我刚刚在参数里面声明却没有生效的原因,那么我对launch文件进行修改,修改成如下

  


      


visual_odometry:=false odom_topic:=/zed/zed_node/odom
为了省去这些参数,我们对launch中的

            
           
            

修改成如上模样
这下我们只需要

  1. roslaunch zed_wrapper zed.launch camera_model:=zed
  2. roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="–delete_db_on_start" frame_id:=base_link
    还是报错,虽然报错中提示的topic都有了,然后去掉了一些不存在的topic(但是会launch不成功,说一定要设置,不能为空,后来没去)但是还是报错,不知道为什么。
    不会改了。。。

pocess has died [pid 3367, exit code -6, cmd /home/asber/catkin_ws/devel/lib/rtabmap_ros/rtabmapviz -d ~/.ros/rtabmap_gui.ini rgb/image:=/zed/zed_node/rgb/image_rect_color depth/image:=/zed/zed_node/depth/depth_registered rgb/camera_info:=/zed/zed_node/rgb/camera_info rgbd_image:=rgbd_image_relay left/image_rect:=/stereo_camera/left/image_rect_color right/image_rect:=/stereo_camera/right/image_rect left/camera_info:=/stereo_camera/left/camera_info right/camera_info:=/stereo_camera/right/camera_info scan:=/scan scan_cloud:=/scan_cloud odom:=/zed/zed_node/odom __name:=rtabmapviz __log:=/home/asber/.ros/log/e05748a6-3927-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmapviz-5.log].
log file: /home/asber/.ros/log/e05748a6-3927-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmapviz-5*.log
[rtabmap/rtabmap-4] process has died [pid 3366, exit code -11, cmd /home/asber/catkin_ws/devel/lib/rtabmap_ros/rtabmap --delete_db_on_start rgb/image:=/zed/zed_node/rgb/image_rect_color depth/image:=/zed/zed_node/depth/depth_registered rgb/camera_info:=/zed/zed_node/rgb/camera_info rgbd_image:=rgbd_image_relay left/image_rect:=/stereo_camera/left/image_rect_color right/image_rect:=/stereo_camera/right/image_rect left/camera_info:=/stereo_camera/left/camera_info right/camera_info:=/stereo_camera/right/camera_info scan:=/scan scan_cloud:=/scan_cloud user_data:=/user_data user_data_async:=/user_data_async gps/fix:=/gps/fix tag_detections:=/tag_detections odom:=/zed/zed_node/odom imu:=/imu/data __name:=rtabmap __log:=/home/asber/.ros/log/e05748a6-3927-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmap-4.log].
log file: /home/asber/.ros/log/e05748a6-3927-11ea-9130-74dfbfcbcc4c/rtabmap-rtabmap-4*.log

总之,最终是把第二个教程活生生改成了第一个教程的错误提示,还算有进步吧。。。。

你可能感兴趣的:(Robot)