# sendTransform() takes exactly 6 arguments (2 given)

I was trying to run this tutorial in python code, but i got above error when i try to run it. My python converted program of given tutorial is:

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import JointState
import tf
import geometry_msgs.msg
import math

def talker():
pub = rospy.Publisher('joint_states', JointState, queue_size=1)
rospy.init_node('state_publisher')

rate = rospy.Rate(30) # 10hz
M_PI = 3.145
degree = M_PI/180;

# robot state
tilt = 0
tinc = degree
swivel=0
angle=0
height=0
hinc=0.005

# message declarations
t = geometry_msgs.msg.TransformStamped()
hello_str = JointState()
t.child_frame_id = "axis"

while not rospy.is_shutdown():
# update joint_state
hello_str.name = ['swivel','tilt','periscope']
hello_str.position = swivel
hello_str.velocity = tilt
hello_str.effort = height

t.transform.translation.x = math.cos(angle)*2
t.transform.translation.y = math.sin(angle)*2
t.transform.translation.z = .7
#t.transform.rotation = tf.createQuaternionMsgFromYaw(angle+M_PI/2)
t.transform.rotation = tf.transformations.quaternion_from_euler(0, 0, angle)
# send the joint state and transform
pub.publish(hello_str)

# Create new robot state
tilt += tinc
if (tilt<-.5 or tilt>0):
tinc *= -1
height += hinc
if (height>.2 or height<0):
hinc *= -1
swivel += degree
angle += degree/4

rate.sleep()

if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass


How can i remove this, i am using ros indigo. Even if i change that line with :

broadcaster.sendTransform((0.5,1.0,0),tf.transformations.quaternion_from_euler(0, 0, angle+M_PI/2),rospy.Time.now(),"odom","axis") Its not working. Than it shows error:

 field position must be a list or tuple type
[state_pub-2] process has died [pid 11654, exit co

edit retag close merge delete

Sort by ยป oldest newest most voted

It looks like you might want to use the sendTrasformMessage method

more