ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Smoerebroed's profile - activity

2018-09-14 17:26:47 -0600 marked best answer 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
2018-07-03 05:34:01 -0600 received badge  Famous Question (source)
2017-12-04 02:41:18 -0600 received badge  Notable Question (source)
2017-12-01 20:39:12 -0600 received badge  Popular Question (source)
2017-12-01 09:48:34 -0600 asked a question Simple Command to robot fails

Simple Command to robot fails I have a problem writing a simple node that publishes messages of a type called JointVeloc