getting unexpected message from subcriber callback
here is code
class Robotreacher:
def __init__(self):
rospy.init_node('robot_control_node', anonymous=True)
self.waisttalker = rospy.Publisher('/rx150/waist_controller/command', Float64, queue_size=10)
self.shouldertalker = rospy.Publisher('/rx150/shoulder_controller/command', Float64, queue_size=10)
self.elbowtalker = rospy.Publisher('/rx150/elbow_controller/command', Float64, queue_size=10)
rospy.Subscriber('/rx150/joint_states', JointState, self.joint_callback)
#rospy.spin()
def joint_callback(self, data):
self.waistp = math.degrees(data.position[5])+180
self.shoulderp = abs(math.degrees(data.position[4])-90)
self.elbowp = abs(math.degrees(data.position[0])-90)
self.waistv = data.velocity[5]
self.shoulderv = data.velocity[4]
self.elbowv = data.velocity[0]
#print("joint is", position)
#time.sleep(0.1)
def joint_states(self):
return self.waistp, self.shoulderp, self.elbowp, self.waistv, self.shoulderv, self.elbowv
def give_force():
x = random.randrange(-4, 4, 1)
y = random.randrange(-4, 4, 1)
z = random.randrange(-4, 4, 1)
waisttalker.publish(x)
shouldertalker.publish(y)
elbowtalker.publish(z)
time.sleep(0.3)
#print("joint states are", self.waistp, self.shoulderp, self.elbowp, self.waistv, self.shoulderv, self.elbowv)
def Robotreacher_looper():
i = 0
reward = 0
for i in range(60):
r = Robotreacher()
print("r is", r.joint_states)
give_force()
if __name__ == '__main__':
try:
Robotreacher_looper()
except rospy.ROSInterruptException:
pass
this is the result I get from the terminal
r is <bound method Robotreacher.joint_states of <__main__.Robotreacher object at 0x7f78acd1cf40>>