简体   繁体   English

即使相机工作,ROS ORB_SLAM2 /orb_slam2_mono/debug_image 也是空白的

[英]ROS ORB_SLAM2 /orb_slam2_mono/debug_image is blank even if camera works

I want to get mapping to work using a Picamera.我想使用 Picamera 进行映射。 I have a Raspberry Pi running a cv_camera_node and an Ubuntu 20.04.1 running roscore , as well as, slam and rviz.我有一个运行 cv_camera_node 的 Raspberry Pi 和一个运行roscore以及 slam 和 rviz 的 Ubuntu 20.04.1。 I have OpenCV 4.2.0 and installed the following version of orb-slam2: https://github.com/appliedAI-Initiative/orb_slam_2_ros .我有 OpenCV 4.2.0 并安装了以下版本的 orb-slam2: https://github.com/appliedAI-Initiative/orb_slam_2_ros I am running ROS Noetic.我正在运行 ROS Noetic。 I have wrote the following launch file for slam:我为 slam 编写了以下启动文件:

<launch>
  <node name="orb_slam2_mono" pkg="orb_slam2_ros"
  
      type="orb_slam2_ros_mono" output="screen">
      
       <param name="publish_pointcloud" type="bool" value="true" />
       <param name="publish_pose" type="bool" value="true" />
       <param name="localize_only" type="bool" value="false" />
       <param name="reset_map" type="bool" value="true" />
       
<!-- static parameters -->

       <param name="load_map" type="bool" value="false" />
       <param name="map_file" type="string" value="map.bin" />
       <param name="voc_file" type="string" value="/home/dragonros/catkin_ws/src/orb_slam_2_ros/orb_slam2/Vocabulary/ORBvoc.txt" />
       <param name="pointcloud_frame_id" type="string" value="map" />
       <param name="camera_frame_id" type="string" value="camera_link" />
       <param name="min_num_kf_in_map" type="int" value="5" />
       
<!-- ORB parameters -->

       <param name="/ORBextractor/nFeatures" type="int" value="2000" />
       <param name="/ORBextractor/scaleFactor" type="double" value="1.2" />
       <param name="/ORBextractor/nLevels" type="int" value="8" />
       <param name="/ORBextractor/iniThFAST" type="int" value="20" />
       <param name="/ORBextractor/minThFAST" type="int" value="7" /> 
       
       <!-- Camera parameters -->
       <!-- Camera frames per second -->
       
       <param name="camera_fps" type="int" value="30" />
       <!-- Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale) -->
       <param name="camera_rgb_encoding" type="bool" value="true" />
        <!--If the node should wait for a camera_info topic to take the camera calibration data-->
       <param name="load_calibration_from_cam" type="bool" value="false" />
       
       <!-- Camera calibration and distortion parameters (OpenCV) -->
      <param name="camera_fx" type="double" value="615.546" />
      <param name="camera_fy" type="double" value="631.457" />
      <param name="camera_cx" type="double" value="354.361" />
      <param name="camera_cy" type="double" value="232.799" />
       <!-- Camera calibration and distortion parameters (OpenCV) -->
      <param name="camera_k1" type="double" value="0.0" />
      <param name="camera_k2" type="double" value="0.0" />
      <param name="camera_p1" type="double" value="0.0" />
      <param name="camera_p2" type="double" value="1.0" />
</node>
</launch>

Then I run another custom catkin package that has the following python script:然后我运行另一个具有以下 python 脚本的自定义 catkin package:

#!/usr/bin/env python
import rospy
import cv2
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
bridge = CvBridge()
def callback(data):
    frame = bridge.imgmsg_to_cv2(data, "bgr8")
    cv2.imshow('Video Feed', frame)
    cv2.waitKey(1)
    rospy.loginfo('Image feed received!')
def listener():
    rospy.init_node('vid_rec')
    #first parameter is the topic you want to subcribe sensor_msgs/Image from
    rospy.Subscriber('/orb_slam2_mono/debug_image', Image, callback) 
    rospy.spin()
if __name__ == '__main__':
    listener()

I am supposed to see a camera feed with all the points slam detects.我应该看到一个包含所有 slam 检测到的点的摄像头。 But the /orb_slam2_mono/debug_image has no data.但是/orb_slam2_mono/debug_image没有数据。 I confirmed that by running rostopic echo /orb_slam2_mono/debug_image .我通过运行rostopic echo /orb_slam2_mono/debug_image确认了这一点。 I know that there is a camera feed because both rviz and rqt_image_viewer can display images coming off of /cv_camera/image_raw .我知道有一个摄像头供稿,因为rvizrqt_image_viewer都可以显示来自/cv_camera/image_raw的图像。 I have thoroughly followed this guide: https://medium.com/@mhamdaan/implementing-orb-slam-on-ubuntu-18-04-ros-melodic-606e668deffa .我已彻底遵循本指南: https://medium.com/@mhamdaan/implementing-orb-slam-on-ubuntu-18-04-ros-melodic-606e668deffa What is the problem and how can I fix it?有什么问题,我该如何解决?

Maybe your camera isn't getting picked up.也许你的相机没有被拿起。 You are using cv_camera_node meaning that the default topic will be cv_camera but orb_slam2 requires just camera.您正在使用 cv_camera_node 意味着默认主题将是 cv_camera 但 orb_slam2 只需要相机。 To solve this, go into the cv_camera_node.cpp which will look like this:为了解决这个问题,将 go 放入 cv_camera_node.cpp,如下所示:

// Copyright [2015] Takashi Ogura<t.ogura@gmail.com>

#include "cv_camera/driver.h"

int main(int argc, char **argv)
{
  ros::init(argc, argv, "cv_camera");
  ros::NodeHandle private_node("~");
  cv_camera::Driver driver(private_node, private_node);

  try
  {
    driver.setup();
    while (ros::ok())
    {
      driver.proceed();
      ros::spinOnce();
    }
  }
  catch (cv_camera::DeviceError &e)
  {
    ROS_ERROR_STREAM("cv camera open failed: " << e.what());
    return 1;
  }

  return 0;
}

You will have to change the line that says ros::init(argc, argv, "cv_camera");您将不得不更改显示ros::init(argc, argv, "cv_camera");的行into this ros::init(argc, argv, "camera");进入这个ros::init(argc, argv, "camera"); . . Rerun everything and it should work.重新运行所有内容,它应该可以工作。

I had the same problem, I discovered that the problem was in the launch file, it was remapping the camera feed to a wrong ros topic, if you use the default launch file and open rqt node graph you will see that there's a floating topic with the name camera/rgb/image_raw and since no one is publishing that topic orbslam is not reading your camera feed.我有同样的问题,我发现问题出在启动文件中,它将相机源重新映射到错误的 ros 主题,如果您使用默认启动文件并打开 rqt 节点图,您将看到有一个浮动主题名称camera/rgb/image_raw并且由于没有人发布该主题 orbslam 没有阅读您的相机提要。 to solve this all I had to do was remove this line from the launch file为了解决这个问题,我所要做的就是从启动文件中删除这一行

 <!-- remove this -->
       <remap from="/camera/image_raw" to="/camera/rgb/image_raw" />

Before fixing the problem ros node graph showed that orbslam wasn't subscribed to the real camera footage, instead it was subscribed to that /rgb topic, but after the fix, it subscribed to the right camera topic.在修复问题之前,ros 节点图显示 orbslam 没有订阅真实的相机镜头,而是订阅了该 /rgb 主题,但在修复之后,它订阅了正确的相机主题。

Before the fix修复前

在此处输入图像描述


After the fix修复后

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM