Skip to content

ROS2: Get the camera intrinsic from the gazebo camera object #2

@torydebra

Description

@torydebra

In ROS1 I managed to get the intrisic params directly from gazebo, for correct filling the camera info message. Now with recent versions of gazebo (the ones associated with ROS2) the methods I used are disappeared, and I am not sure how to do this correctly:

For now, the ROS2 branch compute the intrisic as did in the repo from which this one has been forked

  //TODO: these methods have been removed with gazebo versions for ros2. How to get the actual intrinsic that gazebo is using now?
  // info_msg.k[0] = cam->ImageFocalLengthX();
  // info_msg.k[4] = cam->ImageFocalLengthY();
  // info_msg.k[2] = cam->ImageOpticalCenterX();
  // info_msg.k[5] = cam->ImageOpticalCenterY();
  // info_msg.k[8] = 1.;
  float focal = 0.5 * image.width / tan(0.5 * cam->HFOV().Radian());

  info_msg.k[0] = focal;
  info_msg.k[4] = focal;
  info_msg.k[2] = info_msg.width * 0.5;
  info_msg.k[5] = info_msg.height * 0.5;
  info_msg.k[8] = 1.;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions