ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rviz tf movement w.r.t camera

asked 2018-01-16 03:33:15 -0500

Jeroenvdk gravatar image

Hi, I have a QR tracker which is using visp_auto_tracker. I want to have the QR position in rviz.

My code:

<!-- -*- xml -*-
     This tutorial relies on a live video sequence acquired with an 
     usb camera in front of a QR code planar target. The model 
     corresponding to this target is given into the models directory 
     of this package.
     Camera parameters are set as rosparam parameters. They need to be changed
     to be the one of your camera.
     See http://www.ros.org/wiki/visp_auto_tracker for more information.
  -->
<launch>
<!-- camera transforms -->
    <node pkg="tf" type="static_transform_publisher" 
        name="jeroen_cam_tf" args="0 0 1.0 -1.570796 0 -1.570796 /map /jeroen_camera 100"/>


  <!-- Launch the tracking node -->
  <node pkg="visp_auto_tracker" type="visp_auto_tracker" name="visp_auto_tracker1" output="screen">
    <param name="model_path" value="$(find visp_auto_tracker)/models" />
    <param name="model_name" value="pattern" />
    <param name="debug_display" value="True" />

    <remap from="/visp_auto_tracker1/camera_info" to="/usb_cam1/camera_info"/>
    <remap from="/visp_auto_tracker1/image_raw" to="/usb_cam1/image_raw"/>
  </node>

  <!-- Launch the usb camera acquisition node left -->

  <node pkg="usb_cam" type="usb_cam_node" name="usb_cam1" output="screen">

    <param name="image_width" value="640" />
    <param name="image_height" value="480" />
    <param name="video_device" value="/dev/video2" />      
    <param name="pixel_format" value="yuyv" />
<param name="auto_focus" type="bool" value="False" />
    <!-- rename the camera name topic into /camera/image_raw to match the one in visp_auto_tracker/models/calibration.ini file --> 
    <param name="camera_name" value="/camera/image_raw" />
    <param name="camera_info_url" value="package://visp_auto_tracker/models/calibration_right.ini" type="string" />
  </node>


  <node pkg="visp_auto_tracker" type="visp_auto_tracker" name="visp_auto_tracker2" output="screen">
    <param name="model_path" value="$(find visp_auto_tracker)/models" />
    <param name="model_name" value="pattern" />
    <param name="debug_display" value="True" />

    <remap from="/visp_auto_tracker2/camera_info" to="/usb_cam2/camera_info"/>
    <remap from="/visp_auto_tracker2/image_raw" to="/usb_cam2/image_raw"/>
  </node>

  <!-- Launch the usb camera acquisition node left -->

  <node pkg="usb_cam" type="usb_cam_node" name="usb_cam2" output="screen">

    <param name="image_width" value="640" />
    <param name="image_height" value="480" />
    <param name="video_device" value="/dev/video1" />      
    <param name="pixel_format" value="yuyv" />
<param name="auto_focus" type="bool" value="False" />
    <!-- rename the camera name topic into /camera/image_raw to match the one in visp_auto_tracker/models/calibration.ini file --> 
    <param name="camera_name" value="/camera/image_raw" />
    <param name="camera_info_url" value="package://visp_auto_tracker/models/calibration_left.ini" type="string" />
  </node>



</launch>

I'm using this line to have the position of the camera in rviz:

<!-- camera transforms -->
        <node pkg="tf" type="static_transform_publisher" 
            name="jeroen_cam_tf" args="0 0 1.0 -1.570796 0 -1.570796 /map /jeroen_camera 100"/>

But my object is moving with respect to the map, i want to let it move with respect to the camera. Who can help me?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-01-16 03:56:10 -0500

updated 2018-01-16 04:52:11 -0500

This is exactly the behaviour I would expect. Your QR code will be moving relative to your camera and because you have a static transform between /map and your camera, therefore your QR code will also be moving relative to the /map frame.

Are you expecting the QR code to be static in rviz and the camera frame to move when you view this? To do this you'll need to broadcast a dynamic TF between the QR code and the camera, if I remember correctly visp doesn't do this automatically but you could make a simple node that listens to the visp pose estimates and then publishes then as a TF.

Hope this helps.

Update: If you're not forced to use visp then I recommend trying the ar_track_alvar package instead, this does a very similar job to visp except it can track multiple targets and importantly for you publishes TF frames for each ar tag that it detects.

If you have to work with visp then you'll have to write a simple node that subscribes to the pose from visp and then publishes this pose as a TF frame. I recommend looking at the publisher and subscriber tutorial for the first part and the tf broadcaster tutorial for the second part, these are available for python and c++ so pick whichever language you're most comfortable with.

When you have this setup and running and you're viewing everything in rviz you can set the the 'fixed frame' drop down under 'global options' to that of the AR tag/QR code, then you will see the TF frame axes for the camera moving relative to the fixed QR code.

edit flag offensive delete link more

Comments

Thanks for your answers Pete, can you help me a bit further. I'am doing this for a school project so my experience with rviz/ros is on a low level.

Jeroenvdk gravatar image Jeroenvdk  ( 2018-01-16 04:00:38 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-01-16 03:33:15 -0500

Seen: 647 times

Last updated: Jan 16 '18