0
$\begingroup$

Rosanswers logo

I have a bag file in which some are custom messages whereas others are string messages. How can i display the contents of the topics which have message of type strings (without converting it to a .csv file) ?image description

for example, From the attached image, how can i read the messages of the topic /pnc/relative_carstatus


Originally posted by aks on ROS Answers with karma: 667 on 2018-04-11

Post score: 3


Original comments

Comment by kharkad on 2018-04-11:
I do have a question for you, how do you convert a rosbag file into a csv file? Anyway, why don't you use the rosbag play to play your bag file, and then in another terminal you just see the messages passing into the topic with rostopic echo /pnc/relative_carstatus?

Comment by aks on 2018-04-11:
Hi to convert a bag file to .csv format, use rostopic echo /topicname -b bagFileName.bag -p > file.csv And to the second part, I only have a bag file and when i play it, unfortunately no new nodes are created and no topics as well. That is why i cannot echo any topic.

Comment by kharkad on 2018-04-11:
Personally, whenever I use rosbag I start all nodes manually, and then play the bad file to publish on the wanted topics. I don't think rosbag starts nodes.

Comment by jayess on 2018-04-12:
@aakash_sehgal please don't use an image to display text. Images are not searchable and people cannot copy and paste the text from the image. See http://wiki.ros.org/Support#Do

Comment by aks on 2018-04-12:
@kharkad how do you start all the nodes manually when you receive a bag file from someone else ?

Comment by gvdhoorn on 2018-04-12:
I am confused: @aakash_sehgal: which nodes are you talking about? rosbag publishes msgs as if the original nodes were running. rosbag does not need the original nodes. If you're referring to "the rest" of the application (ie: consumers of msgs), that would be something else.

Comment by aks on 2018-04-12:
@gvdhoorn yes, that is correct. I wanted to reply to @kharkad 's previous comment and then realised that rosbag do not requires original nodes. Question : that means just by playing a bagfile i cannot access the messages. am i right ?

Comment by gvdhoorn on 2018-04-12:
You can, as long as the system on which you are playing the bag has the necessary msgs. rostopic echo should be able to show msg content though, just as it would with 'normal' publications.

Comment by aks on 2018-04-12:
@gvdhoorn Ohh yes... i was making some very basic mistake. thanks for it. Another related question : when i echo the topic, i get data : !! Binary | and some unreadable characters below. This is the same when i visualize the topics in rqt_bag. can i convert these ?

Comment by gvdhoorn on 2018-04-12:
This would seem to be a new question. It would be better to post a new one, provided no-one has answered this before (use google: rostopic echo data binary site:answers.ros.org).

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

You can use Rosbag API to access messages using a simple script

http://wiki.ros.org/rosbag/Code%20API#cpp_api


Originally posted by ZainMehdi with karma: 225 on 2018-04-11

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by jayess on 2018-04-12:
Can you please update your question with a minimum working example?

Comment by aks on 2018-04-12:
@zainmehdi is it possible that i can execute this script in the terminal or do i need to specifically put this in the bagfiles directory and then execute it ?

Comment by aks on 2018-04-12:
@jayess ill try and do that and next time will take care about the image with text.

Comment by ZainMehdi on 2018-04-29:
Sorry for the late response. I hope your problem has been resolved. and to answer your question yes you can execute it like a normal script

$\endgroup$
0
$\begingroup$

Rosanswers logo

I recently wrote ros_readbagfile. You can use it like this:

ros_readbagfile <mybagfile.bag> [topic1] [topic2] [topic3] [...] [topic1000]

I wrote a tutorial for it too, here: http://wiki.ros.org/ROS/Tutorials/reading%20msgs%20from%20a%20bag%20file

See the tutorial for full instructions.

Thanks to this answer for getting me started: https://answers.ros.org/question/240829/filter-out-messages-from-a-ros-bag/?answer=240861#post-id-240861.

See also: https://answers.ros.org/question/240829/filter-out-messages-from-a-ros-bag/?answer=355983#post-id-355983


Originally posted by eRCaGuy with karma: 171 on 2020-08-25

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Stephen Montgomery-Smith on 2020-12-07:
BTW, it is only a very few changes to get it to work with python3. Important to noetic users. I don't know how to contact you. I am at [email protected]

Comment by eRCaGuy on 2021-09-21:
@Stephen Montgomery-Smith, see my latest version of the code here: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/useful_scripts/ros_readbagfile.py. I upgraded it to Python3 a while back. Please ensure it works with Python3 now. I've also updated the ROS tutorial linked-to in my answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.