Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all 475 articles
Browse latest View live

Filter out messages from a ros bag

$
0
0
Hi, I'd like to filter out some "bad messages" from my rosbags. I'm using the C++ rosbag API. Should I open the bagfile in read mode and republish the good messages and record them in another bag using 'rosbag record'? Or is there a way to modify the bag in place when it's in read or write mode? I've gone through the C++ API of rosbag a bit, I couldn't find examples similar to what I want to do. Thanks. Update: Is there a method to find out the list of topics that are present in the bag and other statistics through the API? Is there a way to find out which topic, a particular message instance is from while iterating over them in a `boost foreach` loop as shown in the example [here](http://wiki.ros.org/rosbag/Code%20API#cpp_api)

Rosbag record dropping and corrupting data

$
0
0
Hello, I'm trying to store selected topics being published from various sensors sources (velodyne, monocular camera, IMUs) in a large bag file. I'm able to record the bagfile without seeing any errors. However, when I play back the file, I'm seeing the following errors: 1. Some of the frames of the Velodyne data are being dropped. I've tried recording multiple bagfiles but I see this behavior in all of them 2. From the monocular camera, I'm just recording the camera/image_raw topic . However, after about a minute into the bagfile, the camera input image splits into 2 unequal part and one of the parts get displaced (as seen in the pictures below). I'm seeing this behavior in most of the bagfiles and the time of split is random. ***Original Image:*** ![image description](/upfiles/14701659821686803.png) ***Corrupted Image*** ![image description](/upfiles/14701660129794149.png) A few details about my setup: 1. I have tried recording files at 2 buffer sizes 1024 and 0 (infinity) and I see these problems in both cases 2. I have tried recording bagfiles on and Odroid XU4 and a high-performance laptop but that did not help 3. I'm running ROS indigo on Ubuntu 14.04 ***Rosbag info:*** ![image description](/upfiles/14701677325167827.png) I will be happy to provide any relevant info that may be required. Thanks in advance!

add metadata to rosbag

$
0
0
Hello everybody, I am trying to add ros parameters to a bag file just after the record is done. I am writing a python script to do that and I have followed this link : [http://wiki.ros.org/rosbag/Cookbook](http://wiki.ros.org/rosbag/Cookbook). But I didn't manage to make it work. Nothing is added to the bag file and I have no error message ..... There is my code : record_args = "" try: for param in rospy.get_param_names(): record_args += str(param + ": " + str(rospy.get_param(param))+ " | ") subprocess.call(["rosbag", "record", "-a", "-O", "test"]) except KeyboardInterrupt: with rosbag.Bag('test.bag','a') as bag: dump = String(data = record_args) for _, _, t in bag.read_messages(): break bag.write('/rosparam', dump, t-rospy.rostime.Duration(0, 1)) finally: bag.close() Thanks in advance.

can't save point cloud in bag file complitly

$
0
0
Hy, i am trying to save the point cloud with size(480,640) in bag file by their coordinate values and then read them in another node so that machine determines which part of the point cloud has been changed in next frames and what are their coordinates so that they can be searched in coming frames and that surface with those points can be detected in next point cloud. My problem is when i save point cloud of size (479,50) range it saves and can be visualized, but as the size change to above 50, i get segmented error, what should i do? My codes are: To read the point cloud of size(50,50), determined by raw = 479, col = 50: #include #include #include #include #include #include #include #include #include #include #include #define pi 3.1453 #define pu 3779.527559055 #include "std_msgs/String.h" #include "std_msgs/Float32.h" #include "std_msgs/Int32.h" #include "rosbag/bag.h" #include #include #include #define foreach BOOST_FOREACH ros::Publisher pub; ros::Publisher marker_pub; void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input) { pcl::PointCloud output; pcl::fromROSMsg(*input,output); pcl::PointXYZ P[479][639]; for(int raw = 0;raw<479;raw++) { for(int col = 0;col<639;col++) { P[raw][col] = output.at(col,raw); } } int raw = 479, col = 50; rosbag::Bag bag("test.bag", rosbag::bagmode::Write); std_msgs::Float32 x[raw][col], y[raw][col], z[raw][col]; // y[480][640], z[480][640]; for(int k=0;k<=raw;k++) { for(int l=0;l<=col;l++) { x[k][l].data = P[k][l].x; y[k][l].data = P[k][l].y; z[k][l].data = P[k][l].z; } } for(int j=0;j<=raw;j++) { for(int k=0;k<=col;k++) { bag.write("numbers", ros::Time::now(), x[j][k]); bag.write("numbers", ros::Time::now(), y[j][k]); bag.write("numbers", ros::Time::now(), z[j][k]); // std::cout<("output",1); marker_pub = nh.advertise ("out",1); ros::spin(); } And the code for reading them is:(so that if some object moves in depth frame it could be deteted and saved, tracked, since every point in rigid object are always at same position with respect to each other with small error): void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input) { pcl::PointCloud output; pcl::fromROSMsg(*input,output); visualization_msgs::Marker points, line_strip, line_list; points.header.frame_id = line_strip.header.frame_id = line_list.header.frame_id = "/camera_depth_frame"; points.header.stamp = line_strip.header.stamp = line_list.header.stamp = ros::Time::now(); points.ns = line_strip.ns = line_list.ns = "lines"; points.action =line_strip.action = line_list.action = visualization_msgs::Marker::ADD; points.pose.orientation.w = line_strip.pose.orientation.w = line_list.pose.orientation.w = 1.0; points.id = 0; line_strip.id = 1; line_list.id = 2; points.type = visualization_msgs::Marker::POINTS; line_strip.type = visualization_msgs::Marker::LINE_STRIP; line_list.type = visualization_msgs::Marker::LINE_LIST; points.scale.x = 0.01; points.scale.y = 0.01; line_strip.scale.x = 0.005; line_strip.color.b = 1.0; line_strip.color.a = 1.0; points.color.r = 1.0f; points.color.a = 1.0; line_list.scale.x = 0.005; line_list.color.a = 1.0; geometry_msgs::Point p; pcl::PointXYZ P[479][639]; for(int raw = 0;raw<479;raw++) { for(int col = 0;col<639;col++) { P[raw][col] = output.at(col,raw); } } rosbag::Bag bag("test.bag"); //std_msgs::Float32 i[40000], y[40000], z[40000]; float xv[100000], yv[100000], zv[100000]; int iv = -1; rosbag::View view(bag, rosbag::TopicQuery("numbers")); BOOST_FOREACH(rosbag::MessageInstance const m, view) { std_msgs::Float32::ConstPtr i = m.instantiate(); iv = iv+1; // std::cout <<"z ="<<"\t"<data << std::endl; if(iv%3==0 || iv==0) { if(!isnan(i->data)) { xv[iv] = i->data; std::cout<<"xv"<data)) { yv[iv] = i->data; std::cout<<"yv"<data)) { zv[iv] = i->data; std::cout<<"zv"<

Iterating through bagfile messages yields nullpointer

$
0
0
Hi, I wrote the following class that iterates through the messages of a bagfile: BagReader.h: class BagReader { public: BagReader(std::string const &filename); ~BagReader(); void addTopic(std::string const &name); void readNextMessage(); template boost::shared_ptr getMessage() { if (!view) { view.reset(new rosbag::View(*bag, rosbag::TopicQuery(topics))); messageIterator = view->begin(); } // The instantiation of the message will be a smart pointer. boost::shared_ptr ptr = messageIterator->instantiate(); return ptr; } private: boost::scoped_ptr bag; boost::scoped_ptr view; rosbag::View::iterator messageIterator; std::vector topics; }; BagReader.cpp: #include "BagReader.h" BagReader::BagReader(std::string const &filename) : bag(new rosbag::Bag(filename)) { } BagReader::~BagReader() { bag->close(); } void BagReader::addTopic(std::string const &name) { topics.push_back(name); } void BagReader::readNextMessage() { if (messageIterator != view->end()) ++messageIterator; else messageIterator = view->begin(); } Now I initialize my reader giving it the path to a bagfile and adding the two topics i want to read from: std::string const &path = bagfilesDirectory + "/dice_detection.bag"; bagReader.reset(new BagReader(path)); bagReader->addTopic("/camera/depth_registered/points"); bagReader->addTopic("/tf"); Then I do the following to iterate through the messages of the bagfile: sensor_msgs::PointCloud2ConstPtr cloud = bagReader->getMessage(); // Do something with the cloud... bagReader->readNextMessage(); Now my problem is, that ptr is set to NULL and I don't know why. I roughly followed [this](http://wiki.ros.org/rosbag/Code%20API#cpp_api) tutorial.

Extract robot position from rosbag

$
0
0
I recorded tf-messages (while driving the robot) into a bagfile and wrote a ros node that should extract the positions (base_link-frame) from that bag file. My idea was to use a tf::Transformer and feed it with all the transforms stored in the tf-messages: rosbag::Bag bag; bag.open("tf.bag", rosbag::bagmode::Read); std::vector topics; topics.push_back("/tf"); rosbag::View view(bag, rosbag::TopicQuery(topics)); tf::Transformer transformer; BOOST_FOREACH(rosbag::MessageInstance const m, view) { //instantiate bag message tf::tfMessage::ConstPtr tfPtr = m.instantiate(); BOOST_FOREACH(geometry_msgs::TransformStamped const tfs, tfPtr->transforms) { tf::StampedTransform stampedTf; tf::transformStampedMsgToTF(tfs, stampedTf); //setTransform returns true! transformer.setTransform(stampedTf); ... } } The method setTransform(...) always returns true, so I thought that it works... Each time I get a transform with child_frame == /robot_1/base_link I want to get the map-base_link-transform at the time of this last transform. But the transformer returns false: if(transformer.canTransform(baseLink, mapFrame, stampedTf.stamp_)==true){ //lookup transform transformer.lookupTransform(baseLink, mapFrame, stampedTf.stamp_, temp); } A few additional facts: The transformer's latest common time is always = 0: transformer.getLatestCommonTime(baseLink, mapFrame, time, NULL) And printing all tf-messages of the bag shows that the tf-tree should be consistent (I'm using stage and used view_frames): /map -> /robot_1/odom -> /robot_1/base_footprint -> /robot_1/base_link -> /robot_1/base_laser_link Is something wrong with my code or idea? Any suggestions for a better solution? Thanks in advance!

Create Map from Rosbag

$
0
0
Hi I am having problem with creating map(.pgm and .yaml) files. First i tried to create a map using the existing bag file following [this](http://wiki.ros.org/slam_gmapping/Tutorials/MappingFromLoggedData#download) tutorial. I was successful to create map. Now I created a bag file following [this](http://wiki.ros.org/rosbag/Tutorials/Recording%20and%20playing%20back%20data) tutorial. I created a bag file. But when I try to create a map using this newly created bag file I am getting the message ras@ubuntu:~/bagfiles$ rosrun map_server map_saver -f ~/testmap [ INFO] [1470969136.155361289]: Waiting for the map I am confused what is wrong with creating the bag file. This is to mention, when i created bag file I made rosparam set use_sim_time false and when I create map using bag file I made rosparam set use_sim_time true Can anyone please help me regarding this. Thanks.

Problem with creating map with Robotino and without laser scan

$
0
0
I am using robotino and have no Laser Scanner. I am not having any topic publishing named /base_scan. But I want to user slam_gmapping to scan and create map from the bag file. i used the code below: -------------------------------- rosparam set use_sim_time true rosrun gmapping slam_gmapping scan:=base_scan rosbag play --clock myRobotinoBagFile rosrun map_server map_saver -f /tmp/mymapfile --------------------------------- In my bagfile I have /sonar_scan which is of type sensor_msgs/LaserScan ... but i do not know what is this actually. I have /odom (nav_msgs/Odemetry), /distance_sensors(sensor_msgs/pointclooud) , /cmd_val(geometry_msgs/Twist) etc. But the slam_gmapping requires topic of type sensor_msgs/LaserScan. As I do not have /base_scan , what is the solution to use this method for creating map. Is there any converter i need which can publish /odom or distance sensor data into LaserScan type.?(well it was a wild guss) Thank you all in advance.

rosbag play cannot return back?

$
0
0
Hello, I use `rosbag play -s 10 -u 10 a.bag` to publish the recorded messages. But I find that when I use the command before, I cannot use `rosbag play -s 1 -u 1 a.bag` to get the right result, which means if I use the parameter `-s` to set a particular time slot, I cannot play back to a time slot before. I want to ask if it is the limitation of `rosbag`, or if I use it in the wrong way. Thank you.

Convert a Video to a Rosbag

$
0
0
Hi, I have recorded a Video with 60 FPS on a Smartphone. I now want to use this in ROS. Therefore I like to convert that into a Rosbag. (If you have a other idea I'm open to it) But I didn't find any solution to this. (Here are only Ideas and its a few years old [answersROS](http://answers.ros.org/question/9345/is-there-a-conversion-tool-for-video-to-rosbag-file/)) I can make a rosbag, but I actually have no Idea how I can stream the video file into a Ros topic. (I like to use it with SVO) Thanks for Help

rawlog_mrpt_to_bagfile

$
0
0
Hi all, I need 2d laser data of horizontal terrain, but I am unable in getting that, so I am using data from (mrpt.org), rawlog format but can any please tell me how to convert the rawlog file in to bag or input data.

amcl does not publish transforms to "future"

$
0
0
I am using rosbag to playback a bag file with messages from `/tf`, `/scan`, and `/initialpose`. I am trying to use `amcl` to localize the robot within that bag. I have set `use_sim_time` to be true. The problem now is that the localization is not working properly: Even though `tf` messages indicate that the robot should be moving around, the localization from `amcl` is almost fixed around initial pose. I ran `rqt_tf_tree` (see below) and see that the timestamp of tf transforms from `/map` to `/odom` is less than the one from `/odom` to `/base_footprint`. I've tested several times, and it's always like this. According to amcl documentation, amcl publishes future dated transforms. So I believe if I fix the timestamp issue, amcl will work properly. ![image description](/upfiles/14732681134188096.png) Does anyone have any idea why `amcl` is not publishing future dated transforms? How to force it to do so? Additionally, here is an image with RVIZ showing the TF transforms. The problem is that, `/odom` is not fixed, but `/base_footprint` seems to be fixed. ![image description](/upfiles/14732686922287662.png) I appreciate your help.

tf::TransformListener gets wrong tf

$
0
0
Hello, TL;DR tf::TransformListener gets a different transform than shown in RVIZ I am having quite a strange problem. I am using a rosbag file to playback recorded data and I am adding new transforms and using them while doing that: rosparam set use_sim_time true rosbag play 2016-09-12-14-51-41.bag --clock The transform is published with a python node, where the origin is static (defined with cfg-values) and the rotation is coming from the values of an IMU. The interesting part how the tf is published should be this (in the callback of the IMU subscription): br = tf.TransformBroadcaster() br.sendTransform((frame_offset_x, frame_offset_y, frame_offset_z), quaternion, rospy.Time.now(), frame_child, frame_parent ) With the following values: frame_offset_x = 0 frame_offset_y = 0 frame_offset_z = 1.2 quaternion = rotation of the IMU (only around the x and y axis) frame_child = level_laser_2 frame_parent = base_footprint The created Transform in RVIZ looks like expected. It's 1.2m above base_footprint with some rotation on top. In the picture, the Fixed Frame is set to "base_footprint" ![level_tf in RVIZ](/upfiles/14737549797623874.png) However if I lookup the transform in a ROS node using the tf::TransformListener I get a different result: #include #include ... tf_listener_ = new tf::TransformListener( ros::Duration(10) ); // in the constructor ... void callback( const sensor_msgs::PointCloud2Ptr& cloud_in ) { ... if ( tf_listener_->waitForTransform(tf_target_, cloud_in->header.frame_id, cloud_in->header.stamp, ros::Duration( scan_time_ )) ) { tf::StampedTransform transform; tf_listener_->lookupTransform(tf_target_, cloud_in->header.frame_id, cloud_in->header.stamp, transform); ROS_INFO("%s %s -> %s\tat%lf", node_name_.c_str(), cloud_in->header.frame_id.c_str(), tf_target_.c_str(), cloud_in->header.stamp.toSec()); tfScalar tf[16]; transform.getOpenGLMatrix(tf); ROS_INFO("%s\n" "/ %lf\t%lf\t%lf\t%lf \\\n" "| %lf\t%lf\t%lf\t%lf |\n" "| %lf\t%lf\t%lf\t%lf |\n" "\\ %lf\t%lf\t%lf\t%lf /", node_name_.c_str(), tf[0], tf[4], tf[8], tf[12], tf[1], tf[5], tf[9], tf[13], tf[2], tf[6], tf[10], tf[14], tf[3], tf[7], tf[11], tf[15]); } else { // display error here } ... } The output of this is: [ INFO] [1473756806.521699009, 1473684710.202103154]: /level_laser_velodyne: base_footprint -> level_laser_2 at1473684709.395050 [ INFO] [1473756806.521764836, 1473684710.202103154]: /level_laser_velodyne: / 0.997645 0.001908 -0.068567 0.002741 \ | 0.001908 0.998454 0.055557 -0.002221 | | 0.068567 -0.055557 0.996098 -0.039822 | \ 0.000000 0.000000 0.000000 1.000000 / But it should be something like: [ INFO] [1473756806.521764836, 1473684710.202103154]: /level_laser_velodyne: / R R R 0 \ | R R R 0 | | R R R 1.2 | \ 0 0 0 1 / Does anybody know what I am doing wrong? Thank you for your help, Tobias

Rosbag and simulated time

$
0
0
Hello all, I am trying to run a bag file if simulated time but I am not succeeding on it. Here is what happens: After I run the bag file with the command rosbag play --clock -l laser_scanner3.bag I am checking the timestamp published by the topic **\clock**, i.e. the simulated time, and the timestamp presented in another topic, which is not the same as the one from the \clock topic. I need to solve this dyssynchrony, because, otherwise, I will not be able to use the transformations from **TF**. I know that this file were originally recorded with ORCA and after transformed in **.bag** format. Maybe, the issue is here. Any guess on how I can solve this issue? Thanks!

How to Detect Subscriber Drops a Message

$
0
0
I made a subscriber which reads LIDAR data from rosbag-play. I use C++(roscpp). But when I do rosbag-play with normal speed, subscriber's callback function cannot catch up with LIDAR stream speed, then subscriber's queue become easily full, and many data is dropped and algorithm doesn't work properly. So I have to control the speed of rosbag-play, and to decide appropriate speed, I need to know whether subscriber is dropping data or not. How can I detect that ? (Making queue-size very big is not my choice, because it's just a matter of time until the queue gets full...) (I googled about this question and expected someone already answered, but I could not find any concrete solutions) Thank you for your time, in advance. --- Best regards, Nanoha.

Play ordered multiple bags from a launch file

$
0
0
Hi, I have a question that might be a bit silly, but i do not really find a answer that satisfy me. I have recorded a sequence of 15 minutes splitted in 1 minute rosbag. I want to reproduce them 1 by 1. Can I do that from a roslaunch just by indicating the path to the folder? I intened to automatize the process, so the idea is not to have to write by hand the paths to the rosbags, because they will be different every time, just to have to indicate the folder as a paramenter or something like that. Can I do that from a launch file or from a c++ file? I think that by doing: rosbag play *.bag The rosbags should be played according to their timestamps. However I do not know if that is the best way of doing it because the rosbags will be very large (more tan 15GB) and I have tried that but it takes a looooot of time to load all the rosbags files, that is why I ask if there is any other option. Thanks a lot UPDATED: I intend to use at first the `rosbag play *.bag` and later try to implement a new methow using the rosbag API. However when I try to use it from a roslaunch I obtain this error. [ INFO] [1475569615.047917389]: Opening /home/kailegh/Descargas/Custom/20Jul16/*.bag [FATAL] [1475569615.048150633]: Error opening file: /home/kailegh/Descargas/Custom/20Jul16/*.bag The roslaunch I use looks like this: Could you tell me how to use the * in a launch file? Because I think the problem is something related to that, because using the complete name of the bag the launch works well. Since the topic of the question has changed quite a little I have post the *.bag problem in a new one: http://answers.ros.org/question/244960/shell-bash-used-in-a-roslaunch/

Rosbag in Roslaunch, save rosbag to specific directory

$
0
0
Hey I wanted to use robsbag record in a roslaunch file like: How do I specify that I want to save the bag with a timestamp and to a specific location? I am running on an embedded hardware and have therefore installed the needed ros packages for perception: ros-indigo-perception and ros-indigo-rosbag. Do I need any other packages?

how to use rosbag to test costmap/navigation

$
0
0
I modified a costmap in navigation, and I want to use recorded data to test it. So, I use rosbag record -a -x "(/primesense(.*))?(/move_base(.*))?" -O test.bag to record all data except pointcloud and move_base and then use rosbag play --clock test.bag,but things didn't work out. I changed use_sim_time to ture when rosbag play.

Store ROS messages in file ?

$
0
0
Hello I am working on Some project, I have to store ROS messages in some File using C++ API's. I knew ROS BAG files which is excellent for storing ROS messages But i want to knew Is their any other supported files in ROS to store ROS message using C++ API's. If yes then which one is it ? Can anyone Suggest. Can I read ROS .bag file in Reverse order ? If yes then how it can be done. Please can anyone tell me.

rosbag randomly missing topics on record

$
0
0
Hi all. We've got a very weird case. Our configuration: - main_computer: running roscore - slave_A_computer (ROS_MASTER_URI=main_computer) - slave_B_computer (ROS_MASTER_URI=main_computer) - slave_C_computer (ROS_MASTER_URI=main_computer) - ROS: indigo - Ubuntu 14.04 (x86) All computers are connected in one GigE network and synced using chrony. On main_computer we run https://github.com/ros-drivers/nmea_navsat_driver and on each slave computers we run GigE camera driver and record the image and gps topics (along with some other low bandwidth stuff (diagnostics, tf, etc)) with rosbag (using c++ program, i.e. rosrun rosbag record). Recordings on all 3 computers are done simulatenously but locally on each computer. Now a mysterious thing that happens is that in every e.g. 1 out of 100 bags recorded on slave computers we do not get ONE of the gps topics (out of 4 that nmea_navsat_driver publishes). So for instance slave_A and slave_B have all the topics but on slave_C `/gps/fix` would be missing. This is all happening on a field robot during operation and where it is impossible to actually pause and debug. So my question is how to debug an issue like this? Clearly the topic is being advertised and active since 2 computers get it. Also since the 3rd computer gets 3 of 4 topics from the nmea_navsat_driver the network link is up. Is it then a rosbag tool that is not able to build up all socket connections? Can I somehow constantly log a list of active topics for every computer? thx upfront
Viewing all 475 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>