Simple Command to robot fails
I have a problem writing a simple node that publishes messages of a type called JointVelocity which has 2 objects called velocity of the type JointQuantity
and header of the type Header.
When I run the following code I get the message:
TypeError: unbound method serialize() must be called with JointVelocity instance as first agrugment (got String0 instance instead)
Thanks for your help! Code:
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
from std_msgs.msg import Header
from std_msgs.msg import Float32
from iiwa_msgs.msg import JointVelocity
def talker():
velPub = rospy.Publisher('iiwa/command/JointVelocity',JointVelocity ,queue_size=10)
rospy.init_node('Velocity_Transmitter', anonymous =False)
rate = rospy.Rate(0.5) # 10hz
x = 0
rospy.loginfo("Talker gestartet")
while not rospy.is_shutdown():
rospy.loginfo(str(x))
x = x + 1
vel = JointVelocity
vel.velocity = [Float32(0.1),Float32(0.2),Float32(0.1),Float32(0.1),Float32(0.1),Float32(0.1),Float32(0.1)]
vel.header= Header()
vel.header.stamp = rospy.Time.now()
vel.header.frame_id = ''
vel.header.seq=1
rospy.loginfo(vel.velocity[1])
rospy.loginfo("Velocity will be transmitted")
velPub.publish(vel)
rospy.loginfo("Velocity has been transmitted")
rate.sleep()
if __name__ == '__main__':
try:
talker()
#velocity_talker()
except rospy.ROSInterruptException:
pass
What's the full error? Many times there's an indication to what line is giving you problems. Also, is this all of your code? I just ran it and got no errors.