Skip to content

LinAlgError: Matrix is not positive defined #348

@rodja

Description

@rodja

In simulation, I just got a weird error:

2025-06-23 05:18:33.191 [ERROR] rosys/event.py:85: could not emit listener=EventListener(callback=<bound method RobotLocator._handle_gnss_measurement of <field_friend.robot_locator.RobotLocator object at 0x14d635f50>>, filepath='/Users/rodja/Projects/field_friend/field_friend/robot_locator.py', line=48)
Traceback (most recent call last):
  File "/Users/rodja/Projects/field_friend/field_friend/robot_locator.py", line 173, in _update
    L = np.linalg.cholesky(S)
        ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rodja/Projects/field_friend/.venv/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 779, in cholesky
    r = gufunc(a, signature=signature, extobj=extobj)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rodja/Projects/field_friend/.venv/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 115, in _raise_linalgerror_nonposdef
    raise LinAlgError("Matrix is not positive definite")
numpy.linalg.LinAlgError: Matrix is not positive definite

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rodja/Projects/field_friend/.venv/lib/python3.11/site-packages/rosys/event.py", line 77, in emit
    result = listener.callback(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rodja/Projects/field_friend/field_friend/robot_locator.py", line 160, in _handle_gnss_measurement
    self._update(z=np.array(z), h=np.array(h), H=H, Q=Q)
  File "/Users/rodja/Projects/field_friend/field_friend/robot_locator.py", line 177, in _update
    L = np.linalg.cholesky(S)
        ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rodja/Projects/field_friend/.venv/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 779, in cholesky
    r = gufunc(a, signature=signature, extobj=extobj)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rodja/Projects/field_friend/.venv/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 115, in _raise_linalgerror_nonposdef
    raise LinAlgError("Matrix is not positive definite")
numpy.linalg.LinAlgError: Matrix is not positive definite

The error does not only appear once but in super high frequency. After a restart the error is gone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions