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

need help with camera simulation

asked 2012-08-11 03:56:12 -0500

dmeltz gravatar image

updated 2012-08-11 05:45:02 -0500

hi all.

i using ubuntu 12.04 with ros-fuerte

i trying to connect a camera sensor to a car urdf model that i created. i follow the example on http://ros.org/wiki/urdf/Tutorials/AddingSensorsToPR2.

this is the relevant part of my urdf (xacro) model :

<joint name="camera_joint" type="fixed">
  <origin xyz="${chassis_length/2} 0 ${chassis_hight/2}" rpy="0 0 0" />
  <parent link="base_link" />
  <child link="camera_link"/>
</joint>

<link name="camera_link">
  <inertial>
    <mass value="0.01" />
    <origin xyz="0 0 0" />
    <inertia ixx="0.001"  ixy="0.0"  ixz="0.0"
             iyy="0.001"  iyz="0.0"
             izz="0.001" />
  </inertial>
  <visual>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <geometry>
      <box size="0.001 0.001 0.001" />
    </geometry>
  </visual>
  <collision>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <geometry>
      <box size="0.001 0.001 0.001" />
    </geometry>
  </collision> 
 </link>  <gazebo reference="dany_car_camera">
 <sensor:camera name="dany_car_camera">
    <imageSize>640 480</imageSize>
    <imageFormat>R8G8B8</imageFormat>
    <hfov>90</hfov>
    <nearClip>0.01</nearClip>
    <farClip>100</farClip>
    <updateRate>20.0</updateRate>

     <controller:gazebo_ros_camera name="camera_controller" plugin="libgazebo_ros_camera.so">
      <alwaysOn>true</alwaysOn>
      <updateRate>20.0</updateRate>
      <imageTopicName>dany_car_camera/image</imageTopicName>
      <frameName>camera_link</frameName>
      <interface:camera name="dany_car_camera_iface"/>
    </controller:gazebo_ros_camera>
 </sensor:camera>
  <turnGravityOff>false</turnGravityOff>
  <material>Gazebo/Red</material>
</gazebo>

when i roslaunch empty_world.launch and my launch file

i get no errors about the camera. the simulation loads and runs correctly. but when i try to view the camera window by commanding

$ rosrun image_view image_view image:=dany_car_camera/image

i get an empty window.

pleas help me found my mistake. tanks.

edit retag flag offensive close merge delete

Comments

1

What is the result of a rostopic list btw?

SL Remy gravatar image SL Remy  ( 2012-08-12 18:16:38 -0500 )edit

Also, rostopic hz is useful to check whether anything is being published.

joq gravatar image joq  ( 2012-08-13 06:37:21 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-12-12 09:50:23 -0500

dmeltz gravatar image

updated 2012-12-12 09:51:38 -0500

I found my mistake :

the reference field must be equal to the link name on which the sensor (in this case camera) is positioned. here the correct code :

<!-- CAMERA : joint , link , sensor  -->
  <joint name="yuval_camera_joint" type="fixed">
    <origin rpy="0 0 0" xyz="0.5 0 0.1"/>
    <parent link="base_link"/>
    <child link="camera_link"/>
  </joint> 
 <link name="camera_link">
      <inertial>
        <mass value="0.01" />
        <origin xyz="0 0 0" />
        <inertia ixx="0.001"  ixy="0.0"  ixz="0.0"
                 iyy="0.001"  iyz="0.0"
                 izz="0.001" />
      </inertial>
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <box size="0.1 0.1 0.1" />
        </geometry>
        <material name="red"/>
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <box size="0.1 0.1 0.1" />
        </geometry>
      </collision>
    </link>
 <gazebo reference="camera_link">
    <sensor:camera name="dany_car_camera_sensor">
        <imageFormat>R8G8B8</imageFormat>
        <imageSize>704 480</imageSize>
        <hfov>45</hfov>
        <nearClip>0.1</nearClip>
        <farClip>100</farClip>
        <updateRate>20.0</updateRate>
        <controller:gazebo_ros_prosilica name="dany_car_CAMERA_controller" plugin="libgazebo_ros_prosilica.so">
            <cameraName>dany_car_camera_sensor</cameraName>
            <alwaysOn>true</alwaysOn>
            <updateRate>20.0</updateRate>
            <imageTopicName>/dany_car_sensors/camera/image_raw</imageTopicName>
            <cameraInfoTopicName>/dany_car_sensors/camera/camera_info</cameraInfoTopicName>
            <pollServiceName>/dany_car_sensors/camera/request_image</pollServiceName>
            <frameName>camera_link</frameName>
            <CxPrime>1224.5</CxPrime>
            <Cx>1224.5</Cx>
            <Cy>1025.5</Cy>    
            <focalLength>849.803363</focalLength>  <!--   focal_length = width_ / (2.0 * tan( HFOV/2.0 )) --> 
           <hackBaseline>0.0</hackBaseline>
           <distortionK1>0.0</distortionK1>
           <distortionK2>0.0</distortionK2>
           <distortionK3>0.0</distortionK3>
           <distortionT1>0.0</distortionT1>
           <distortionT2>0.0</distortionT2>
            <interface:camera name="dany_car_camera_iface" />
        </controller:gazebo_ros_prosilica>
    </sensor:camera>
    <turnGravityOff>false</turnGravityOff>
    <material>Gazebo/Red</material>
</gazebo>
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2012-08-11 03:56:12 -0500

Seen: 824 times

Last updated: Dec 12 '12