0
$\begingroup$

Rosanswers logo

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?


Originally posted by shankk on ROS Answers with karma: 18 on 2021-10-11

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by shankk with karma: 18 on 2021-10-11

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.