Ask Your Question
0

sendTransform() takes exactly 6 arguments (2 given)

asked 2017-03-27 15:34:37 -0500

dinesh gravatar image

updated 2017-03-27 15:52:15 -0500

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
from std_msgs.msg import Header
import tf
import geometry_msgs.msg
import math

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

broadcaster = tf.TransformBroadcaster()   
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.header.frame_id = "odom"
t.child_frame_id = "axis"

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

    t.header.stamp = rospy.Time.now()
    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)
    broadcaster.sendTransform(t)

    # 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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-03-27 16:37:34 -0500

tfoote gravatar image

It looks like you might want to use the sendTrasformMessage method

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-03-27 15:34:37 -0500

Seen: 1,241 times

Last updated: Mar 27 '17