ros-perception / vision_opencv

Apache License 2.0
536 stars 599 forks source link

Fix incorrect case for CameraInfo msg members in directed.py test #526

Closed ScottMonaghan closed 3 months ago

ScottMonaghan commented 3 months ago

tldr; this PR fixes a simple case bug in directed.py test, but directed.py tests are not run by colcon test

While working on the issue below,

I discovered two things:

  1. colcon test does not appear to be running they directed.py test for the python portion of the code
  2. directed.py produced the error below
=================================== FAILURES ===================================

___________________________ TestDirected.test_stereo ___________________________

self = <directed.TestDirected testMethod=test_stereo>

    def test_stereo(self):

...

        # These parameters taken from a real camera calibration

>       lmsg.D =  [-0.363528858080088, 0.16117037733986861, -8.1109585007538829e-05, -0.00044776712298447841, 0.0]

E       AttributeError: 'CameraInfo' object has no attribute 'D'

directed.py:32: AttributeError

The immediate fix was simple enough to correct the case on the CameraInfo object members.

After the fix the test ran with expected warning around the matrix object:

============================= test session starts ==============================

platform linux -- Python 3.10.12, pytest-7.4.3, pluggy-0.13.0

rootdir: /home/ros2/ros2_workspaces/src/vision_opencv

configfile: pytest.ini

plugins: ament-pep257-0.16.3, launch-testing-3.4.0, ament-xmllint-0.16.3, ament-copyright-0.16.3, launch-testing-ros-0.26.4, ament-lint-0.16.3, ament-flake8-0.16.3, rerunfailures-13.0, colcon-core-0.16.0, cov-3.0.0

collected 2 items                                                              

directed.py ..                                                           [100%]

=============================== warnings summary ===============================

image_geometry/test/directed.py: 425 warnings

  Warning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

======================= 2 passed, 425 warnings in 0.45s ========================

@ijnek, is it intentional that the directed.py tests aren't run with colcon test? If not I'll create a new issue for that.

ijnek commented 3 months ago

This test seems like it was commented out during the ROS 2 port. Please reenable the test.

ijnek commented 3 months ago

Just pushed one small change to disable test_monocular, since there are no tests runing inside it, and it clutters the terminal with misleading print outs.