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

getFrameStrings() fails if it called just after rospy.init_node() from tf 1.11.9 #152

Closed
k-okada opened this issue Aug 10, 2017 · 1 comment

Comments

@k-okada
Copy link
Contributor

k-okada commented Aug 10, 2017

I have travous on tf 1.11.9, where getFrameStrings() fails if it called just after rospy.init_node()

$ ./hoge.py 
Traceback (most recent call last):
  File "./hoge.py", line 8, in <module>
    print tflistener.getFrameStrings()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/tf/listener.py", line 98, in getFrameStrings
    return [p for p, _ in data.items()]

the code is

$ cat hoge.py 
#!/usr/bin/env python

import rospy
import tf
import time
rospy.init_node('test_tf')
tflistener = tf.TransformListener()
#time.sleep(1)
print tflistener.getFrameStrings()

and if we comment in time.sleep() then it works ok.This does not happens on 1.11.8, so maybe because of #149.
I do not well understand how tflistener.getFrameStrings called on 1.11.8, but for example, we can avoid this problem by.

    def getFrameStrings(self):
        """ Not a recommended API, only here for backwards compatibility """
        data = yaml.load(self._buffer.all_frames_as_yaml())
        return data and [p for p, _ in data.items()]
k-okada added a commit to tork-a/rtmros_nextage that referenced this issue Aug 10, 2017
tfoote added a commit that referenced this issue Aug 10, 2017
Fixes #152

The empty yaml was coming through as a list not a dict so was breaking the expectations.

I used the shorthand `or {}` since I know any valid data won't evaluate to zero. A more complete solution is described here: https://stackoverflow.com/a/35777649/604099
@tfoote
Copy link
Member

tfoote commented Aug 10, 2017

Ahh, if there's no data, by default the yaml parser creates a list but if there's data it's a dict. PS As that's a deprecated API please switch to one of the supported ones like: allFramesAsString()

tfoote added a commit that referenced this issue Aug 10, 2017
Fixes #152

The empty yaml was coming through as a list not a dict so was breaking the expectations.

I used the shorthand `or {}` since I know any valid data won't evaluate to zero. A more complete solution is described here: https://stackoverflow.com/a/35777649/604099
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

No branches or pull requests

2 participants