4 roslib.load_manifest(
'nao_description')
8 from tf
import TransformListener
9 from tf
import transformations
13 from naoqi
import ALProxy
15 print(
"Error importing NaoQI. Please make sure that Aldebaran's NaoQI API is in your PYTHONPATH.")
21 if space == motion.SPACE_TORSO:
23 elif space == motion.SPACE_WORLD:
25 elif space == motion.SPACE_NAO:
26 return "BaseFootprint" 32 row = result[4*i:4*i+4]
33 rstr =
''.join([
"%s" %str(k).center(maxColumnWidth)
for k
in (row)] )
48 return np.matrix(
'0 0 1 0;-1 0 0 0; 0 -1 0 0; 0 0 0 1')
50 if __name__ ==
'__main__':
51 rospy.init_node(
'test_tf')
55 proxy = ALProxy(
"ALMotion", ip, port)
56 print "motionproxy ready" 57 space = motion.SPACE_TORSO
59 currentSensor = proxy.getPosition(chainName, space,
True)
60 current = proxy.getPosition(chainName, space,
False)
61 print "Position of %s in space %s:"%(chainName,
space_to_str(space))
64 rpy = currentSensor[3:]
66 DCM = apply(transformations.euler_matrix,rpy)
68 tTHSensor = proxy.getTransform(chainName, space,
True)
69 tTH = proxy.getTransform(chainName, space,
False)
70 print "Transform %s to %s:"%(
space_to_str(space),chainName)
73 chainName =
"CameraTop" 74 tTCSensor = proxy.getTransform(chainName, space,
True)
75 tTC = proxy.getTransform(chainName, space,
False)
76 print "Transform %s to %s:"%(
space_to_str(space),chainName)
79 T = np.matrix([tTCSensor[0:4],tTCSensor[4:8],tTCSensor[8:12],tTCSensor[12:]])
82 print "Transform %s to %s (with rotated coordinate frame):"%(
space_to_str(space),chainName)
87 frame2 =
'CameraTop_frame' 89 listener.waitForTransform(frame1,frame2,stamp,rospy.Duration(1.0))
90 (trans,rot) = listener.lookupTransform(frame1,frame2,stamp)
91 except tf.Exception
as e:
92 print "ERROR using TF" 96 m = transformations.quaternion_matrix(rot)
99 print "[tf] Transform %s to %s:"%(frame1,frame2)
102 e = np.linalg.norm(DCM - m)
105 print "ERROR: Something is wrong with your TF transformations. Transforms do not match!" 107 print "Test ok. Done"