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

How to publish more than 5 distortion parameters through sensor_msgs::CameraInfo structure?

asked 2021-10-11 06:46:39 -0500

shankk gravatar image

updated 2021-10-11 06:47:47 -0500

Hi guys. I have a node which publishes images to /image_raw topic and camera calibration data to /camera_info topic. It is setting lens distortion coefficients using the "d" vector of CameraInfo structure. Now, the camera sensor driver says lens distortion type is polynomial. Now, for distortion type polynomial, there are 6 radial distortion coefficients and 2 tangential distortion coefficients. How can I pass all eight through the d vector? I set the values correctly from d[0] to d[7] but when I use ros2 topic echo /camera_info it shows just the first five elements d[0] ... d[5]. It truncates the rest of the vector. The subsequent nodes in the pipeline need all the distortion coefficients but are unable to receive them due to this truncation.

Can someone help me with this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-11 10:10:51 -0500

shankk gravatar image

updated 2021-10-11 10:11:19 -0500

So, I figured out what was wrong with my code. Actually the d data member of sensor_msgs::msg::CameraInfo class is a vector and you need to resize it to the correct size before filling in the values. So if suppose your distortion model uses 8 coefficients then you need to resize the d vector to eight. In my case, I had three radial coefficients (remaining three radial coefficients had to be assumed to be zero) and two tangential coefficients returned by the sensor driver. And I was resizing the vector as d.resize(tangential_count + radial_count) which was equal to d.resize(3 + 2). So, although subsequent ROS nodes in my pipeline were expecting eight distortion coefficients (including three tangential coefficients that were zero), it was only receiving a vector of size five because I was using count variables to resize the vector.

So, it is more of a careless programming mistake on my part, but I would still leave this answer here in case anyone encounters something like this in the future.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-10-11 06:46:39 -0500

Seen: 222 times

Last updated: Oct 11 '21