Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry reading bag file messages without backslash in unit tests #108

Merged
merged 1 commit into from
Feb 9, 2020

Conversation

Achllle
Copy link
Contributor

@Achllle Achllle commented Feb 5, 2020

Description

This small fix addresses the case where the bag file specified for unit testing contains topics without a forward slash (/). If such a (legal) bag is used, currently the following error is returned:

    unable to parse value "/trajectory" (will be considered as string):
	list index out of range

The IndexError occurs because supplying the topic with forward slash returns the empty list. In the case that the user specified a non-existing topic, another IndexError will be raised as expected.

Testing

The following code produces a bag file that fails with current code and succeeds with this PR:

#!/usr/bin/env python
import rosbag

from trajectory_msgs.msg import JointTrajectory

bag = rosbag.Bag('test_some_state.bag', 'w')

try:
    jt = JointTrajectory()
    bag.write('trajectory', jt)  # succeeds when using '/trajectory

finally:
    bag.close()

@pschillinger
Copy link
Member

Thanks for including this case!

@pschillinger pschillinger merged commit 86c80ec into team-vigir:develop Feb 9, 2020
@Achllle Achllle deleted the fix/test_bagfile_topic branch February 11, 2020 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants