TypeError for built-in operation
In working with tf.Transformer, I've run into this error many times.
TypeError: bad argument type for built-in operation
The most frustrating part of getting this message is that the traceback blames seemingly random lines of code for the error. Here's one reduced way to get the error.
#!/usr/bin/python
import roslib; roslib.load_manifest('tf')
import tf, rospy
from geometry_msgs.msg import TransformStamped
if __name__ == '__main__':
tfman = tf.Transformer(True, rospy.Duration(10.0))
angle = tf.transformations.quaternion_from_euler(0,0,0)
m = TransformStamped()
m.header.frame_id = 'root'
m.child_frame_id = 'child'
print type(angle), type(m.transform.rotation)
m.transform.rotation = angle
tfman.setTransform(m)
for i in range(1):
print i
This outputs:
<type 'numpy.ndarray'=""> <class 'geometry_msgs.msg._quaternion.quaternion'=""> 0 Traceback (most recent call last): File "src/error.py", line 18, in <module> for i in range(1): TypeError: bad argument type for built-in operation
The clearest way to fix this is to set the rotation using a quaternion, not a numpy array. However, is there some way to get a clearer error message?
Edit: I guess the clearer question is: Why would this mistake cause a TypeError on line 18? Also, I put the error here so that the next person who searches for the error message on the board will find it here.
The error is actually coming from CPython from another thread (so it has nothing to do with the command on line 18).
This type of print-outs happen in cases when python cannot raise an exception (e.g. if an exception was thrown in __del__). TypeError probably means a non-existing method was called, which makes sense, since you changed the type of m.transform.rotation.