Ask Your Question
0

How to publish tf between base_link camera

asked 2019-03-20 12:29:40 -0500

Sotte17 gravatar image

updated 2019-03-20 12:42:52 -0500

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()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-03-20 14:11:58 -0500

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_... ) 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.

edit flag offensive delete link more

Comments

Can you tell me what is wrong in my previous code because it is not broadcasting any transform

Sotte17 gravatar imageSotte17 ( 2019-03-21 02:43:50 -0500 )edit
  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
stevemacenski gravatar imagestevemacenski ( 2019-03-21 02:46:28 -0500 )edit

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

Sotte17 gravatar imageSotte17 ( 2019-03-23 13:15:18 -0500 )edit

One is enough, but for standards and convenience, I would seriously consider not doing this.

stevemacenski gravatar imagestevemacenski ( 2019-03-25 14:42:07 -0500 )edit

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: 2019-03-20 12:29:40 -0500

Seen: 208 times

Last updated: Mar 20