0
$\begingroup$

Rosanswers logo

I want to publish Transform between camera and base_link. But i am not able to please help and I have seen the predefined packages but since I use ROS kinetic I cannot use those.

I have done this till now

import rospy
from nav_msgs.msg import Odometry
import tf
#import turtlesim.msg

def func1(msg, name):
    br = tf.TransformBroadcaster()
    br.sendTransform((0,0,0),
                     tf.transformations.quaternion_from_euler(0, 0, 0),
                     rospy.Time.now(),name,
                     "base_link")

if __name__ == '__main__':
    rospy.init_node('optical_cam_transform_publisher')
    cam_frame="optical_came_frame"
    #odom=Odometry()
    rospy.Subscriber('/odom',
                     Odometry,
                     func1,cam_frame
                     )
    rospy.spin()

Originally posted by Sotte17 on ROS Answers with karma: 1 on 2019-03-20

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

That is one way you can do it. If this transform is static (i.e. your relationship between base link and the camera doesn't change in time) then you can use the Static TF Publisher (http://wiki.ros.org/static_transform_publisher) as a way to advertise the transform.

If you have more than just 1 transform to publish, that's a good candidate to make a URDF file with these transformations in XML format (many examples can be seen in any robot description package), and load those transforms in a roslaunch file.


Originally posted by stevemacenski with karma: 8272 on 2019-03-20

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Sotte17 on 2019-03-21:
Can you tell me what is wrong in my previous code because it is not broadcasting any transform

Comment by stevemacenski on 2019-03-21:\

  1. make sure that that callback is even being called
  2. the Broadcaster shouldn't be remade every execution of the callback, create it once and use it from there on out. There's alot of startup and tear down cost/time associate with that

Comment by Sotte17 on 2019-03-23:
What is the difference between this method and robot_state_publisher method for publishing transform. Are both of them needed or one of them is enough

Comment by stevemacenski on 2019-03-25:
One is enough, but for standards and convenience, I would seriously consider not doing this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.