Ask Your Question

Easiest way to set 2 cameras relative transformation ?

asked 2016-10-03 11:00:55 -0500

Rouno gravatar image

Hi guys,

I've set up a system with downward facing camera and a visual odometry algorithm running on it. I would like to plug a 2nd camera that is facing forward and that would benefit from the first camera localization.

The idea is being able to see some AR markers in a rviz camera view from the 2nd camera perspective.

I read a couple of tutorial of tf, urdf, robot models etc. but can't figure out the easiest way to set it. What would you recommend ?

My system runs ROS Kinetic on an Odroid C2

Thanks !

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-03 13:32:23 -0500

lucasw gravatar image

updated 2016-10-03 13:35:36 -0500

The easiest way is two static transform publishers in a launch file :

<node pkg="tf" type="static_transform_publisher"
    args="x1 y1 z1 yaw1 pitch1 roll1 base_link camera1_link 100" />

<node pkg="tf" type="static_transform_publisher" 
    args="x2 y2 z2 yaw2 pitch2 roll2 base_link camera2_link 100" />

Replace x1 y1 etc. with the translation and rotation values you've determined for each camera relative to the base_link frame on your system (which could be anywhere you want it to). If you want to tweak those values you would kill the roslaunch that is running those broadcasters, edit them, and relaunch. They could be replaced with roslaunch args and passed in from the command line to make that relaunching process a little more convenient.

And camera1 would be set up to use camera1_linkin the Image header frame_id, and likewise for camera2.

Later you might want to replace this with a urdf/xacro derived robot_description that creates these two frames and other parts of your system they are attached to.

Or later maybe you have a live calibration process to determine where camera1 is relative to camera2, and you want to be able to change the transforms live with no disruption while values are edited and nodes are killed and relaunched- then you'd probably be setting up a python node that has a service or topic that it listens to that that determines the transform values and has a transfrom broadcaster through the python tf api, but that is the least easiest here.

edit flag offensive delete link more


Hey Lucasw, this is just the perfect answer I was looking for. I'll give it a try asap !!!

Thanks a lot for your help ;)

Rouno gravatar image Rouno  ( 2016-10-03 13:47:40 -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


Asked: 2016-10-03 11:00:55 -0500

Seen: 884 times

Last updated: Oct 03 '16