Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible function arguments error when optimizing Unit3 in Python #305

Closed
johhat opened this issue Mar 6, 2023 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@johhat
Copy link
Contributor

johhat commented Mar 6, 2023

Describe the bug
Optimizing a factor with an sf.Unit3 type as input in python yields an incompatible function arguments error.

To Reproduce
See the error of the following example

import symforce

symforce.set_epsilon_to_symbol("epsilon")

import sym
import numpy as np

import symforce.symbolic as sf
from symforce.opt.factor import Factor
from symforce.opt.optimizer import Optimizer
from symforce.values import Values


def residual(unit3: sf.Unit3) -> sf.V3:
    return unit3.to_unit_vector()


def main():
    values = Values(
        {
            "unit3": sym.Unit3.from_vector(np.array([0, 0, 1]), sym.epsilon),
        }
    )

    optimizer = Optimizer(
        factors=[
            Factor(
                residual=residual,
                keys=["unit3"],
            )
        ],
        optimized_keys=["unit3"],
    )

    # Fails here
    result = optimizer.optimize(values)


if __name__ == "__main__":
    main()

Expected behavior
I'd expect the optimization to run without error.

Environment

  • This Debian based docker image with python 3.8.16
  • SymForce Version 0.8.0

Example dockerfile

FROM python:3.8.16
RUN pip3 install symforce
COPY example.py /example.py
CMD ["python", "example.py"]

Additional context
Excerpt of the error message

TypeError: set(): incompatible function arguments. The following argument types are supported:
    1. (self: cc_sym.Values, key: cc_sym.Key, value: float) -> bool
    2. (self: cc_sym.Values, key: index_entry_t, value: float) -> None
    3. (self: cc_sym.Values, key: cc_sym.Key, value: Rot2) -> bool
    ...

Invoked with: <Valuesd entries=0 array=0 storage_dim=0 tangent_dim=0
>, x_0, <Unit3 [0.0, 0.0, 0.0, 1.0]>
@johhat johhat added the bug Something isn't working label Mar 6, 2023
@aaron-skydio aaron-skydio self-assigned this Mar 7, 2023
@aaron-skydio
Copy link
Member

Thanks for reporting, we forgot to add Unit3 to the Python wrappers when we added it - will have a fix shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants