My code is not working

asked 2016-06-06 12:12:48 -0500

arcanum gravatar image

updated 2016-06-06 12:21:45 -0500

gvdhoorn gravatar image

I tried to make a node that uses tf2 to read a transform of frame 'a_link', and broadcasts another transform called 'b_link' that is one centimetre in the positive y direction from that frame.

It should also publish a pose message to a rostopic with a good name.

This is my code

But it is not working

#!/usr/bin/env python  
import roslib
import rospy
import math
import tf2_ros
import geometry_msgs.msg
import turtlesim.msg

if __name__ == '__main__':
  rospy.init_node('tf2_transform')

  tfBuffer =  tf2_ros.Buffer()
  listener =  tf2_ros.TransformListener(tfBuffer)
  rospy.wait_for_service('transform')


  while not rospy.is_shutdown():

  time_now= rospy.Time.now()
  listener.lookupTransform('new_link','a_link',time_now,transform)


  br = tf2_ros.TransformBroadcaster()
  t = geometry_msgs.msg.TransformStamped()
  t.header.stamp = rospy.Time.now()
  t.header.frame_id = "end_effector_tip"
  t.child_frame_id = end effector
  t.transform.translation.x = new_link.x;
  t.transform.translation.y = 1+new_link.y;
  t.transform.translation.z = new_link.z;
  q = tf.transformations.quaternion_from_euler(0, 0, new_link.theta)
  t.transform.rotation.x = q[0]
  t.transform.rotation.y = q[1]
  t.transform.rotation.z = q[2]
  t.transform.rotation.w = q[3]

  br.sendTransform(t) 

   if __name__ == '__main__':
    rospy.init_node('b_link')
    rospy.Subscriber('/%s/pose' 'b_link_transform' b_link.pose )

 rospy.spin()
edit retag flag offensive close merge delete

Comments

1

Please format code snippets with the Preformatted text button in the future. It's the one with 101010 on it.

gvdhoorn gravatar image gvdhoorn  ( 2016-06-06 12:22:18 -0500 )edit
2

And please change the title of your question. 'not working' is way too generic, and will probably not help other users providing useful answers.

gvdhoorn gravatar image gvdhoorn  ( 2016-06-06 12:23:53 -0500 )edit