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

Revision history [back]

click to hide/show revision 1
initial version

So, I got some progress and stuck in the different place. I will write everything I've got, maybe it could be useful for understanding the problem I have now and for others to refer in the future.

1) Calibration. I follow the instruction described on wiki page for visp_camera_calibration

rosdep install visp_camera_calibration
rosmake visp_camera_calibration
roslaunch launch/lagadic_grid.launch

At the end you find all calibration parameters you need for the launch file as it is described there or in ~/.ros/calibration.ini

2) Launch file looks like this for me:

<launch>
    <arg name="kinect" default="false"/>
    <param name="use_sim_time" value="false"/>

    <node pkg="rviz" type="rviz" name="rviz" />
        args="-d $(find ar_pose)/demo/demo_single.vcg"/> 

    <node pkg="tf" type="static_transform_publisher" name="world_to_cam"
        args="1 0 0 0 0 0 world camera_link 10" />

    <node name="camera" pkg="openni_camera" type="openni_node" respawn="false" output="log">

        <param name="camera_frame_id" type="string" value="camera"/>
        <param name="video_device" type="string" value="/dev/bus/usb/002/009"/>
        <param name="camera_frame_id" type="string" value="camera"/>

        <param name="io_method" type="string" value="mmap"/>
        <param name="image_width" type="int" value="640"/>
        <param name="image_height" type="int" value="480"/>
        <param name="pixel_format" type="string" value="mjpeg"/> 

        <rosparam param="D">[-0.01019, 0.00000, 0.00000, 0.00000, 0.00000]</rosparam>
        <rosparam param="K">[548.83913,0.00000,309.68288,0.00000,541.05367,246.39086, 0.00000, 0.00000, 1.00000]</rosparam>
        <rosparam param="R">[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]</rosparam>
        <rosparam param="P">[548.83913,0.00000,309.68288,0.00000,0.00000,541.05367,246.39086, 0.00000, 0.00000 0.00000, 1.00000, 0.00000]</rosparam>

    </node>

    <node name="ar_pose" pkg="ar_pose" type="ar_single" respawn="false" output="screen">
        <param name="marker_pattern" type="string" value="data/patt.hiro"/>

        <param name="marker_width" type="double" value="80.0"/>
        <param name="marker_center_x" type="double" value="0.0"/>
        <param name="marker_center_y" type="double" value="0.0"/>
        <param name="threshold" type="int" value="100"/>
        <param name="use_history" type="bool" value="true"/>    

        <remap if="$(arg kinect)" from="/usb_cam/image_raw"   to="/camera/rgb/image_color"/>
            <remap if="$(arg kinect)" from="/usb_cam/camera_info" to="/camera/rgb/camera_info"/>

            <remap unless="$(arg kinect)" from="/usb_cam/image_raw" to="/wide_stereo/left/image_rect_color"/>
            <remap unless="$(arg kinect)" from="/usb_cam/camera_info" to="/wide_stereo/left/camera_info"/>  

    </node>

</launch>

Two crucial lines were(pay attention to the names of package and types you specify):

 args="1 0 0 0 0 0 world camera_link 10" />

<node name="camera" pkg="openni_camera" type="openni_node" respawn="false" output="log">

3) Rviz. I rviz I've chosen 3 topics: TF, Camera (/camera/rgb/image_rect_color) and Marker (visualization_marker). Fixed frame - /world and nothing for Target Frame. I get image from the camera and the transformation between world and camera seem to ok, but ar markers are not recognized.

4) I changed camera topics in include/ar_pose/ar_single.h to the following existing topics:

const std::string cameraImageTopic_ = "/camera/rgb/image_raw";
const std::string cameraInfoTopic_  = "/camera/rgb/camera_info";

Subscribing to info topics seems to be fine, but subscribing to image topics gives me the following error:

OpenCV Error: Image step is wrong () in cvInitMatHeader, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1308/modules/core/src/array.cpp, line 162
terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1308/modules/core/src/array.cpp:162: error: (-13)  in function cvInitMatHeader

I figure out that the problem is with this line:

   capture_ = bridge_.imgMsgToCv (image_msg, "bgr8");

(probably with a format I specify), but I tried different formats(bgr, rgb, mono) in lower and upper cases and no success. Could anyone please help me with that?

So, I got some progress and stuck in the different place. I will write everything I've got, maybe it could be useful for understanding the problem I have now and for others to refer in the future.

1) Calibration. I follow the instruction described on wiki page for visp_camera_calibration

rosdep install visp_camera_calibration
rosmake visp_camera_calibration
roslaunch launch/lagadic_grid.launch

At the end you find all calibration parameters you need for the launch file as it is described there or in ~/.ros/calibration.ini

2) Launch file looks like this for me:

<launch>
    <arg name="kinect" default="false"/>
    <param name="use_sim_time" value="false"/>

    <node pkg="rviz" type="rviz" name="rviz" />
        args="-d $(find ar_pose)/demo/demo_single.vcg"/> 

    <node pkg="tf" type="static_transform_publisher" name="world_to_cam"
        args="1 0 0 0 0 0 world camera_link 10" />

    <node name="camera" pkg="openni_camera" type="openni_node" respawn="false" output="log">

        <param name="camera_frame_id" type="string" value="camera"/>
        <param name="video_device" type="string" value="/dev/bus/usb/002/009"/>
        <param name="camera_frame_id" type="string" value="camera"/>

        <param name="io_method" type="string" value="mmap"/>
        <param name="image_width" type="int" value="640"/>
        <param name="image_height" type="int" value="480"/>
        <param name="pixel_format" type="string" value="mjpeg"/> 

        <rosparam param="D">[-0.01019, 0.00000, 0.00000, 0.00000, 0.00000]</rosparam>
        <rosparam param="K">[548.83913,0.00000,309.68288,0.00000,541.05367,246.39086, 0.00000, 0.00000, 1.00000]</rosparam>
        <rosparam param="R">[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]</rosparam>
        <rosparam param="P">[548.83913,0.00000,309.68288,0.00000,0.00000,541.05367,246.39086, 0.00000, 0.00000 0.00000, 1.00000, 0.00000]</rosparam>

    </node>

    <node name="ar_pose" pkg="ar_pose" type="ar_single" respawn="false" output="screen">
        <param name="marker_pattern" type="string" value="data/patt.hiro"/>

        <param name="marker_width" type="double" value="80.0"/>
        <param name="marker_center_x" type="double" value="0.0"/>
        <param name="marker_center_y" type="double" value="0.0"/>
        <param name="threshold" type="int" value="100"/>
        <param name="use_history" type="bool" value="true"/>    

        <remap if="$(arg kinect)" from="/usb_cam/image_raw"   to="/camera/rgb/image_color"/>
            <remap if="$(arg kinect)" from="/usb_cam/camera_info" to="/camera/rgb/camera_info"/>

            <remap unless="$(arg kinect)" from="/usb_cam/image_raw" to="/wide_stereo/left/image_rect_color"/>
            <remap unless="$(arg kinect)" from="/usb_cam/camera_info" to="/wide_stereo/left/camera_info"/>  

    </node>

</launch>

Two crucial lines were(pay attention to the names of package and types you specify):

 args="1 0 0 0 0 0 world camera_link 10" />

<node name="camera" pkg="openni_camera" type="openni_node" respawn="false" output="log">

3) Rviz. I rviz I've chosen 3 topics: TF, Camera (/camera/rgb/image_rect_color) and Marker (visualization_marker). Fixed frame - /world and nothing for Target Frame. I get image from the camera and the transformation between world and camera seem to ok, but ar markers are not recognized.

4) I changed camera topics in include/ar_pose/ar_single.h to the following existing topics:

const std::string cameraImageTopic_ = "/camera/rgb/image_raw";
const std::string cameraInfoTopic_  = "/camera/rgb/camera_info";

Subscribing to info topics seems to be fine, but subscribing to image topics gives me the following error:

OpenCV Error: Image step is wrong () in cvInitMatHeader, file /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1308/modules/core/src/array.cpp, line 162
terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/buildd/ros-fuerte-opencv2-2.4.2-1precise-20130312-1308/modules/core/src/array.cpp:162: error: (-13)  in function cvInitMatHeader

I figure out that the problem is with this line:

   capture_ = bridge_.imgMsgToCv (image_msg, "bgr8");

(probably with a format I specify), but I tried different formats(bgr, rgb, mono) in lower and upper cases and no success. Could anyone please help me with that?

5) kinect.launch file

<launch>
  <arg name="debug" default="false"/>
  <arg if="$(arg debug)" name="launch_prefix" value="xterm -rv -e gdb -ex run - args"/>
  <arg unless="$(arg debug)" name="launch_prefix" value=""/>

    <node pkg="tf" type="static_transform_publisher" name="k1_world_tfb" args="-0.37 0.94 1.04 0 0.83 -1.57 /world_base_link /kinect_1_link  40" />
    <node pkg="tf" type="static_transform_publisher" name="k2_world_tfb" args=" 0.37 0.98 1.02 0 0.80 -1.57 /world_base_link /kinect_2_link  40" />

<!-- first kinect -->
  <node pkg="openni_camera" type="openni_node" name="openni_node1" ns="camera1" launch-prefix="$(arg launch_prefix)" output="screen">
    <param name="device_id" value="A00365911792039A"/>
    <param name="rgb_frame_id" value="/camera1/rgb/image_raw"/>
    <param name="depth_frame_id" value="/camera1/depth/image_raw"/>
    <param name="use_indices" value="false" />
    <param name="depth_registration" value="true" />
    <param name="image_mode" value="2" />
    <param name="depth_mode" value="2" />
    <param name="debayering" value="2" />
    <param name="depth_time_offset" value="0" />
    <param name="image_time_offset" value="0" />
  </node>

<!-- second kinect -->
  <node pkg="openni_camera" type="openni_node" name="openni_node2" ns="camera2" launch-prefix="$(arg launch_prefix)"  output="screen">
    <param name="device_id" value="000000000000000"/> 
    <param name="rgb_frame_id" value="/camera2/rgb/image_raw"/>
    <param name="depth_frame_id" value="/camera2/depth/image_raw"/>
    <param name="use_indices" value="false" />
    <param name="depth_registration" value="true" />
    <param name="image_mode" value="2" />
    <param name="depth_mode" value="2" />
    <param name="debayering" value="2" />
    <param name="depth_time_offset" value="0" />
    <param name="image_time_offset" value="0" />
  </node>

  <node pkg="rviz" type="rviz" name="rviz" 
     args="-d $(find ar_marker_detection_multiple)/ar_marker_detection.vcg"/>

     <param name="marker_dist_threshold" type="double" value="0.02" />
     <param name="publish_tf" type="bool" value="true" />

  <node pkg="ar_marker_detection_multiple" type="ar_kinect" name="ar_kinect" respawn="false" output="screen"/>

</launch>