ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
764 stars 912 forks source link

Incorrect number of messages obtained using read_messages() #2343

Open Mentaixg opened 1 year ago

Mentaixg commented 1 year ago

I have a problem with using read_messages() to get topic messages in rosbag. The number of messages in my bag is 101

When I use for topic, msg, t in patch_bag_.read_messages(topics=[topic]) to obtain, the number of msg obtained is 101

But when I use for topic, msg, t in bag.read_messages(topics=[topic], start_time=rospy.Time(start_time), end_time=rospy.Time(end_time))to specify start_time and end_time, the number of msgs obtained only 99

(Because of the problem of [https://github.com/ros/ros_comm/issues/952], I used self.bag_start_time = bag_.get_start_time() self.bag_end_time = bag_.get_end_time() for _, _, t in bag.read_messages(raw=True): self.bag_start_time = min(t.to_sec(), self.bag_start_time) self.bag_end_time = max(t.to_sec(), self.bag_end_time) to get the time)