Ask Your Question
1

Method for filtering out gps topic in a bag file

asked 2018-03-13 08:35:48 -0600

tuandl gravatar image

Hi everyone, I have recorded a bag file which contains gps topic for using with robot_localization pkg. I want to modify my gps topic to mimic a scenario where gps signal is not available, e.g transition from indoor to outdoor and vice versa. Using topic tools I was able to drop/filter out my gps messages. The result is in the following picture: drop gps messages

topic_tools drops X out of Y messages regularly as it is supposed to (blue dots). My question is: is there any method that can drop messages for a specific time length? For clarification, I would like something like this: image description

where the yellow lines are my gps messages and the gaps between them are dropped gps messages. I appreciate your help!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-03-13 14:32:34 -0600

stevejp gravatar image

updated 2018-03-13 14:33:05 -0600

This cmd line would extract all messages on topic /odometry/gps between t1 and t2 and between t3 and t4 (you can keep extending it for other intervals). Is that what you want?

rosbag filter bag_in.bag bag_out.bag "topic == '/odometry/gps' and ((m.header.stamp.secs > t1 and m.header.stamp.secs < t2) or (m.header.stamp.secs > t3 and m.header.stamp.secs < t4))"
edit flag offensive delete link more

Comments

Yes, this is exactly what I need. Thank you for your help!

tuandl gravatar imagetuandl ( 2018-03-14 06:35:46 -0600 )edit

This would filter out everything except the /odometry/gps from those times. I think tuandl is asking how to drop those messages instead of filtering everything else from the bagfile.

bmgatten gravatar imagebmgatten ( 2019-09-24 18:55:56 -0600 )edit
0

answered 2018-03-13 08:45:16 -0600

updated 2018-03-13 10:45:21 -0600

It should be quite easy to rewrite the bag using the rosbag Python API. The wiki gives you more information and some examples.

Edit: Apparently, you can also filter using the standard rosbag utility, see rosbag filter.

edit flag offensive delete link more

Comments

@Maarten: thank you for your reply. Could you be a bit specific? Do you suggest to create a new bag with selected numbers of messages? I haven't tried it yet but I guess it might work. However, is there any more elaborate methods since I have a big gps topic in my rosbag file.

tuandl gravatar imagetuandl ( 2018-03-13 09:08:08 -0600 )edit

You can either create a new bag with only the messages in the time intervals you want to keep, or you can write a custom bag processor which only publishes the messages in the time intervals you want to keep.

Maarten gravatar imageMaarten ( 2018-03-13 10:42:33 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-03-13 08:35:48 -0600

Seen: 163 times

Last updated: Mar 13 '18