Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

The Kinect model uses the DepthCamera sensor that I believe it's not finished. If you look at the source code in sensors/DepthCameraSernsor.cc, you will see that there's no topic publication. I think these will be the set of steps to make it work:

  1. Change the model.sdf to include a `depth_camera> section:

    <sensor name="camera" type="depth">
      <update_rate>20</update_rate>
      <visualize>true</visualize>
      <always_on>1</always_on>
      <camera>
        <horizontal_fov>1.047198</horizontal_fov>
        <image>
          <width>640</width>
          <height>480</height>
          <format>R8G8B8</format>
        </image>
        <clip>
          <near>0.05</near>
          <far>3</far>
        </clip>
        <depth_camera>
          <output>points</output>
        </depth_camera>
      </camera>
    </sensor>
    
  2. Add to the DepthCameraSensor.cc the topic publication. You can use as a template the code in CameraSensor.cc. In the DepthCameraSensor case, the size of each pixel would be 4 bytes corresponding to a float. Also, we would access the depth information with this->camera->GetDepthData().

    if (this->imagePub && this->imagePub->HasConnections())
    {
      msgs::ImageStamped msg;
      msgs::Set(msg.mutable_time(), this->scene->GetSimTime());
      msg.mutable_image()->set_width(this->camera->GetImageWidth());
      msg.mutable_image()->set_height(this->camera->GetImageHeight());
      msg.mutable_image()->set_pixel_format(13);
    
     msg.mutable_image()->set_step(this->camera->GetImageWidth() * 4);
     msg.mutable_image()->set_data(this->camera->GetDepthData(),
     msg.image().width() * 4 * msg.image().height());
    
     this->imagePub->Publish(msg);
    }
    

I'm assuming that the code in rendering:DepthCamera works and the depth image is properly rendered. If you don't want to use gazebo_ros_pgk you would have to modify the Gazebo source code, include those changes and probably debug it until it works. It will be fun and a nice contribution if you make it work.

The Kinect model uses the DepthCamera sensor that I believe it's not finished. If you look at the source code in sensors/DepthCameraSernsor.cc, sensors/DepthCameraSensor.cc, you will see that there's no topic publication. I think these will be the set of steps to make it work:

  1. Change the model.sdf to include a `depth_camera> section:

    <sensor name="camera" type="depth">
      <update_rate>20</update_rate>
      <visualize>true</visualize>
      <always_on>1</always_on>
      <camera>
        <horizontal_fov>1.047198</horizontal_fov>
        <image>
          <width>640</width>
          <height>480</height>
          <format>R8G8B8</format>
        </image>
        <clip>
          <near>0.05</near>
          <far>3</far>
        </clip>
        <depth_camera>
          <output>points</output>
        </depth_camera>
      </camera>
    </sensor>
    
  2. Add to the DepthCameraSensor.cc the topic publication. You can use as a template the code in CameraSensor.cc. In the DepthCameraSensor case, the size of each pixel would be 4 bytes corresponding to a float. Also, we would access the depth information with this->camera->GetDepthData().

    if (this->imagePub && this->imagePub->HasConnections())
    {
      msgs::ImageStamped msg;
      msgs::Set(msg.mutable_time(), this->scene->GetSimTime());
      msg.mutable_image()->set_width(this->camera->GetImageWidth());
      msg.mutable_image()->set_height(this->camera->GetImageHeight());
      msg.mutable_image()->set_pixel_format(13);
    
     msg.mutable_image()->set_step(this->camera->GetImageWidth() * 4);
     msg.mutable_image()->set_data(this->camera->GetDepthData(),
     msg.image().width() * 4 * msg.image().height());
    
     this->imagePub->Publish(msg);
    }
    

I'm assuming that the code in rendering:DepthCamera works and the depth image is properly rendered. If you don't want to use gazebo_ros_pgk you would have to modify the Gazebo source code, include those changes and probably debug it until it works. It will be fun and a nice contribution if you make it work.

The Kinect model uses the DepthCamera sensor that I believe it's not finished. If you look at the source code in sensors/DepthCameraSensor.cc, you will see that there's no topic publication. I think these will be the set of steps to make it work:

  1. Change the model.sdf to include a `depth_camera> section:

    <sensor name="camera" type="depth">
      <update_rate>20</update_rate>
      <visualize>true</visualize>
      <always_on>1</always_on>
      <camera>
        <horizontal_fov>1.047198</horizontal_fov>
        <image>
          <width>640</width>
          <height>480</height>
          <format>R8G8B8</format>
        </image>
        <clip>
          <near>0.05</near>
          <far>3</far>
        </clip>
        <depth_camera>
          <output>points</output>
        </depth_camera>
      </camera>
    </sensor>
    
  2. Add to the DepthCameraSensor.cc the topic publication. You can use as a template the code in CameraSensor.cc. In the DepthCameraSensor case, the size of each pixel would be 4 bytes corresponding to a float. Also, we would access the depth information with this->camera->GetDepthData().

    if (this->imagePub && this->imagePub->HasConnections())
    {
      msgs::ImageStamped msg;
      msgs::Set(msg.mutable_time(), this->scene->GetSimTime());
      msg.mutable_image()->set_width(this->camera->GetImageWidth());
      msg.mutable_image()->set_height(this->camera->GetImageHeight());
      msg.mutable_image()->set_pixel_format(13);
    
     msg.mutable_image()->set_step(this->camera->GetImageWidth() * 4);
     msg.mutable_image()->set_data(this->camera->GetDepthData(),
     msg.image().width() * 4 * msg.image().height());
    
     this->imagePub->Publish(msg);
    }
    

I'm assuming that the code in rendering:DepthCamera works and the depth image is properly rendered. If you don't want to use gazebo_ros_pgk gazebo_ros_pkgs, you would have to modify the Gazebo source code, include those changes and probably debug it until it works. It will be fun and a nice contribution if you make it work.