Robotics StackExchange | Archived questions

Camera_calibration is stuck - nothing happens (black window)

Hello,

I am having problems in trying to run camera calibration for a tello drone. I am using ros2, foxy distro, ubuntu 20.04.

I have installed tello drivers/nodes by using this package: https://github.com/tentone/tello-ros2 I run the launch file and works fine, I am able to control the drone (e.g. send command to takeoff, landing), and from the rviz gui I am able to see the image from the camera from the published \camera topic, and also able to select the different topics that are published.

Now i am trying to run camera calibration, but I am stuck. I run the following command:

ros2 run camera_calibration cameracalibrator --size 7x9 --square 0.16 image:=/image_raw camera:=/camera_info

The output looks more or less ok, except from the warnings:

[WARN] [1666088539.374651575] [rcl]: Found remap rule 'image:=/image_raw'. This syntax is deprecated. Use '--ros-args --remap image:=/image_raw' instead.
[WARN] [1666088539.374677600] [rcl]: Found remap rule 'camera:=/camera_info'. This syntax is deprecated. Use '--ros-args --remap camera:=/camera_info' instead.
Waiting for service camera/set_camera_info ...
OK
Waiting for service left_camera/set_camera_info ...
OK
Waiting for service right_camera/set_camera_info ...
OK

The 'display' window opens, but at this point, nothing happens. The display window remains black (it is supposed to show the image from the camera, I guess) and nothing else is printed on the terminal. I have been waiting for a few minutes, nothing happens. When I interrupt the command with ctrl+c, I see that the execution is stuck at this line:

Traceback (most recent call last):
  File "/opt/ros/foxy/lib/camera_calibration/cameracalibrator", line 11, in <module>
    load_entry_point('camera-calibration==2.2.0', 'console_scripts', 'cameracalibrator')()
  File "/opt/ros/foxy/lib/python3.8/site-packages/camera_calibration/nodes/cameracalibrator.py", line 146, in main
    node.spin()
  File "/opt/ros/foxy/lib/python3.8/site-packages/camera_calibration/camera_calibrator.py", line 229, in spin
    time.sleep(0.1)
KeyboardInterrupt

Any idea if I am doing something wrong? Any help would be appreciated. Thank you!

Asked by damiano on 2022-10-18 05:35:44 UTC

Comments

I just tested it with the RealSense D435 Camera, and it works. I used the following command ros2 run camera_calibration cameracalibrator --size 7x4 --square 0.035 --ros-args -r image:=/camera/color/image_raw -p camera:=/camera/color/camera_info.

I also noticed that the the Waiting for service blah blah blah OK is printed even with no camera. Therefore, can you please confirm that camera is attached, and images are available in the correct topic?

Asked by ravijoshi on 2022-10-18 06:37:21 UTC

Hi, I can see the camera images correctly displayed if I select the /camera topic in the rviz gui. Do you mean, to check in some other way?

Asked by damiano on 2022-10-18 07:32:54 UTC

Thank you very much. I understand.

  1. Can you confirm that camera_info is also being published? For example, you can run the following command to do so: rostopic echo /camera_info
  2. Can you also, make sure that image_raw and camera_info topic are correct. For example, both of these topic share same values in frame_id, height, width. Please see below an example:

    header:
      frame_id: camera_color_optical_frame
    height: 480
    width: 640
    

    In my test workspace, the image_raw and camera_info have following common values. In other words, the frame_id is camera_color_optical_frame in image_raw and camera_info and so on.

Asked by ravijoshi on 2022-10-18 07:48:20 UTC

I am using ros2, so I have tried with the following command:

ros2 topic echo /camera_info sensor_msgs/CameraInfo

This is the output:

    header:
  stamp:
    sec: 0
    nanosec: 0
  frame_id: ''
height: 0
width: 0
distortion_model: ''
d: []
k:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
r:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
p:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
binning_x: 0
binning_y: 0
roi:
  x_offset: 0
  y_offset: 0
  height: 0
  width: 0
  do_rectify: false

I thought it was normal to see all these zeros since the camera is not calibrated yet - is that not the case?

Asked by damiano on 2022-10-18 08:43:38 UTC

Ok, after some digging, I found out the root of the problem - topic /image_raw was not published. In fact, this line of the launch file fails: https://github.com/tentone/tello-ros2/blob/main/workspace/src/tello/tello/node.py#L271

And in the terminal of the launch file, after the 'streamon' command, I see a lot of these errors:

[tello-1] [h264 @ 0x7fd344013980] non-existing PPS 0 referenced
[tello-1] [h264 @ 0x7fd344013980] non-existing PPS 0 referenced
[tello-1] [h264 @ 0x7fd344013980] decode_slice_header error
[tello-1] [h264 @ 0x7fd344013980] no frame!

So it seems a problem with h264decoder? I'm investigating.

Asked by damiano on 2022-10-18 22:22:45 UTC

So after more digging, I found out the error in the output appears when calling the instruction get_frame_read(), here:

https://github.com/tentone/tello-ros2/blob/main/workspace/src/tello/tello/node.py#L262

interestingly, I tried to open python and run the code found in this answer on SO:

https://stackoverflow.com/a/72420343

And I am able to correctly see the live video of the tello camera. I think I need to add some 'wait' function in the node.py code as well...

Asked by damiano on 2022-10-19 01:05:26 UTC

seems like an issue with tello...

Asked by ravijoshi on 2022-10-19 01:10:45 UTC

Answers

Well, looks like I was an idiot :D

indeed, the topic name was incorrect. The image of the camera is published under the topic with name:

/camera

While in my calibration command I was giving the following:

image:=/image_raw

So the following command works:

ros2 run camera_calibration cameracalibrator --size 7x9 --square 0.16 image:=/camera camera:=/camera_info

Asked by damiano on 2022-10-19 02:39:38 UTC

Comments

glad you made it work!

Asked by ravijoshi on 2022-10-19 04:27:23 UTC