ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

YancenBOB's profile - activity

2021-09-02 17:38:01 -0500 received badge  Famous Question (source)
2021-09-02 17:38:01 -0500 received badge  Notable Question (source)
2021-09-02 17:38:01 -0500 received badge  Popular Question (source)
2021-07-12 15:16:07 -0500 received badge  Famous Question (source)
2021-05-20 11:13:07 -0500 received badge  Famous Question (source)
2021-04-21 04:16:28 -0500 received badge  Notable Question (source)
2021-04-09 01:08:13 -0500 received badge  Notable Question (source)
2020-10-14 02:32:31 -0500 received badge  Famous Question (source)
2020-10-14 02:32:31 -0500 received badge  Notable Question (source)
2020-10-14 02:32:31 -0500 received badge  Popular Question (source)
2020-10-05 18:37:33 -0500 marked best answer The problem about the double messages read from a rosbag file

I want to write the time stamps of rosbag in a .txt document. There, I use two kinds of methods to do that:

  1. Reference of C++ API link text.

  2. Use the callback fuction to subscribe the topics from the rosbag played in another terminal.

But I meet a strange problem about the quantity of time stamps between two methods. The first method will output almost the double quantity of time stamps while that of the second one is right.

The rosbag I choose is from the datase EuRoC MH_easy_01.bag. It is about the indoor UAV for vision and INS (vio) SLAM. I check the inforamtion of it and there are 3682 messages for two cameras.

path:        MH_01_easy.bag
version:     2.0
duration:    3:06s (186s)
start:       Jun 25 2014 03:02:59.81 (1403636579.81)

end:         Jun 25 2014 03:06:06.70 (1403636766.70)
size:        2.5 GB
messages:    47283
compression: none [2456/2456 chunks]
types:       geometry_msgs/PointStamped [c63aecb41bfdfd6b7e1fac37c7cbe7bf]
             sensor_msgs/Image          [060021388200f6f0f447d0fcd9c64743]
             sensor_msgs/Imu            [6a62c6daae103f4ff57a132d6f95cec2]
topics:      /cam0/image_raw    3682 msgs    : sensor_msgs/Image         
             /cam1/image_raw    3682 msgs    : sensor_msgs/Image         
             /imu0             36820 msgs    : sensor_msgs/Imu           
             /leica/position    3099 msgs    : geometry_msgs/PointStamped

For the fist method, I get almost double messages (7364) and for the second one I get the same number of rosbag file. And the double number has a strange phenomenon that each message has a copy. So, it has the double number.

My environment is Ubuntu 16.05 and ROS Kinetic. Two method codes are in the following:

The first one of C++ API

#include <ros/ros.h>
#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/Imu.h>

#include <boost/foreach.hpp>

#define foreach BOOST_FOREACH

#include <string>
#include <vector>
#include <stdio.h>

int main (int argc, char ** argv)
{
    //Initiliaze the node and bag
    ros::init(argc,argv,"read");
    ros::NodeHandle n;
    rosbag::Bag bag;
bag.open("/home/cyx/dataset/MH_01_easy.bag");
// bag.open("data.bag");

ROS_INFO("Open the bag");

FILE *fpOut0, *fpOut1, *fpout2;
fpOut0=fopen("cam0_MH.txt", "w");
fpOut1=fopen("cam1_MH.txt", "w");
fpout2=fopen("imu_MH.txt", "w");

//Topics name in the rosbag
std::vector<std::string> topics;
topics.push_back(std::string("/cam0/image_raw"));
topics.push_back(std::string("/cam1/image_raw"));
topics.push_back(std::string("/imu0"));

rosbag::View view(bag, rosbag::TopicQuery(topics));

ROS_INFO("Start to read");
//read the time stamp and write them to .txt
foreach(rosbag::MessageInstance const m, view)
{
    sensor_msgs::Image::ConstPtr img0 = m.instantiate<sensor_msgs::Image>();
    sensor_msgs::Image::ConstPtr img1 = m.instantiate<sensor_msgs::Image>();
    sensor_msgs::Imu::ConstPtr imu = m.instantiate<sensor_msgs::Imu>();

    if(img0!=NULL)
    {
        fprintf(fpOut0, "%.9lf\n", img0->header.stamp.toSec());
        // printf("t0 = %.9lf\n", img0->header.stamp.toSec());
    }

    if(img1!=NULL)
    {
        fprintf(fpOut1, "%.9lf\n", img1->header.stamp.toSec());
        // printf("t1 = %.9lf\n", img1->header.stamp.toSec());
    }

    if(imu!=NULL)
    {
        fprintf(fpout2, "%.9lf\n", imu->header.stamp.toSec());
    }

}

bag.close();

return 1;

}

And the second one of callback function

#include <ros/ros.h>
#include <rosbag/bag.h>
#include <sensor_msgs/Imu.h>
#include <sensor_msgs/Image.h>

#include <iostream>
#include <stdio.h>

FILE *fp0, *fp1, *fp2;

void ...
(more)
2020-10-05 18:37:23 -0500 received badge  Famous Question (source)
2020-08-12 22:31:43 -0500 received badge  Notable Question (source)
2020-08-08 19:16:30 -0500 received badge  Famous Question (source)
2020-08-07 05:01:15 -0500 received badge  Popular Question (source)
2020-07-24 04:42:38 -0500 received badge  Famous Question (source)
2020-04-06 22:18:46 -0500 received badge  Famous Question (source)
2020-04-06 22:18:46 -0500 received badge  Notable Question (source)
2020-04-06 22:18:46 -0500 received badge  Popular Question (source)
2020-03-12 05:43:48 -0500 received badge  Notable Question (source)
2020-03-12 04:14:15 -0500 edited question can not compile by catkin_make but catkin build

can not compile by catkin_make but catkin build Hi, everyone. My environment is Ubuntu 16.04 and ROS Kinetic. I meet a

2020-03-12 04:13:36 -0500 edited question can not compile by catkin_make but catkin build

can not compile by catkin_make but catkin build Hi, everyone. My environment is Ubuntu 16.04 and ROS Kinetic. I meet a

2020-03-12 03:20:15 -0500 edited question can not compile by catkin_make but catkin build

A catkin_make question about src/package.xml does not exist. Hi, everyone. My environment is Ubuntu 16.04 and ROS Kineti

2020-03-08 23:55:27 -0500 received badge  Popular Question (source)
2020-03-04 21:17:59 -0500 marked best answer An incomprehension about geometry_msgs/PoseWithCovariance Message

Hi, I have a question about pose covariance.

In the doc website (link text), I see the covariance is shown as a matrix with 6*6 size and the parameters are x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis in order.

I am confused about the size and the parameters. The x,y,z are the coordinate of a 3D point and they are 3 parameters? And then, three rotations are shown in 33 matrix respectively? If it is, the all parameters are 3 + 39 = 30. Why 6*6 here?

Thank you!

2020-03-04 00:44:18 -0500 edited question can not compile by catkin_make but catkin build

A catkin_make question about src/package.xml does not exist. Hi, everyone. My environment is Ubuntu 16.04 and ROS Kineti

2020-03-03 23:41:25 -0500 commented answer An incomprehension about geometry_msgs/PoseWithCovariance Message

Ok, I got it. Thanks you!

2020-03-03 21:40:54 -0500 edited question can not compile by catkin_make but catkin build

A catkin_make question about more than one package Hi, everyone. My environment is Ubuntu 16.04 and ROS Kinetic. I meet

2020-03-03 21:40:52 -0500 edited question can not compile by catkin_make but catkin build

A catkin_make question about more than one package Hi, everyone. My environment is Ubuntu 16.04 and ROS Kinetic. I meet

2020-03-03 21:34:03 -0500 edited question can not compile by catkin_make but catkin build

A catkin_make question about more than one package Hi, everyone. My environment is Ubuntu 16.04 and ROS Kinetic. I meet

2020-03-03 21:33:30 -0500 asked a question can not compile by catkin_make but catkin build

A catkin_make question about more than one package Hi, everyone. My environment is Ubuntu 16.04 and ROS Kinetic. I meet

2020-03-01 19:28:46 -0500 commented answer An incomprehension about geometry_msgs/PoseWithCovariance Message

Thanks for your answer. By the way, I guess that the TwistWithCovariance is about the linear velocity of xyz and the rot

2020-02-26 06:59:49 -0500 asked a question An incomprehension about geometry_msgs/PoseWithCovariance Message

An incomprehension about geometry_msgs/PoseWithCovariance Message Hi, I have a question about pose covariance. In the

2019-12-08 21:12:34 -0500 received badge  Popular Question (source)
2019-12-06 03:06:18 -0500 asked a question Difference between OpenCV installed by ROS and that from OpenCV itself

Difference between OpenCV installed by ROS and that from OpenCV itself Hi, I am a newer in SLAM. I offen use the OpenCV

2019-10-15 02:52:31 -0500 commented answer How to change the camera model when using image_pipeline?

Thanks for your help! Thank you!

2019-10-14 20:09:58 -0500 received badge  Popular Question (source)
2019-10-12 03:02:18 -0500 asked a question How to evaluate the calibration results from image_pipeline?

How to evaluate the calibration results from image_pipeline? Hi, I have successfully done the binocular calibration with

2019-10-11 22:07:18 -0500 commented answer How to change the camera model when using image_pipeline?

Thank you! I have got the baseline. For the camera model, I have another question that dose image_pipeline only support

2019-10-11 20:50:08 -0500 marked best answer How to change the camera model when using image_pipeline?

Hi, I do some binocular camera calibration tests with image_pipeline. For some reasons, I can not see the video in the image_pipeline/Tutorials page. I have to ask questions there. 1, How can I cange the camera model? You know that diferent cameras should choose the appropriate one. Further, I want to know all the models that image_pipeline supports. 2, How can I get the baseline after I do the calibration? I just get 3 files: left.yaml, right.yaml and ost.txt. I don't see the extrinsic parameters, which I mean a matrix to show transformation relationship between double cameras. Is there some commend to add it into the outputs? Thank you!

2019-10-11 06:37:14 -0500 asked a question How to change the camera model when using image_pipeline?

How to change the camera model when using image_pipeline? Hi, I do some binocular camera calibration tests with image_pi

2019-10-11 06:36:13 -0500 asked a question How to change the camera model when using image_pipeline?

How to change the camera model when using image_pipeline? Hi, I do some binocular camera calibration tests with image_pi

2019-10-01 10:01:19 -0500 received badge  Notable Question (source)
2019-09-24 08:03:45 -0500 received badge  Famous Question (source)
2019-09-21 11:04:52 -0500 received badge  Notable Question (source)
2019-08-28 02:25:01 -0500 received badge  Notable Question (source)