Simplified way to define new types of factors from Matlab

Issue #251 on hold
Dimka Kopitkov created an issue

Hi,

In current state of gtsam, in case where I need new factor, I will need to go to C++, write new class for new factor, build it and wrap it for usage in Matlab. Such way is problematic for people that are unfamiliar with C++. It would be really helpful if there would be way to define new factor in Matlab, without any modification of C++ code.

The possible idea for implementing such feature can be related to the "Expression" factors in next gtsam release. We can add some general C++ class that accepts error function as its constructor argument and then propagates all calls for its "evaluateError" to this argument's function. In such form, there will be no need for defining new C++ class for new factor and Matlab (or any other wrap platform, like Python) users will be able to work with gtsam easier.

Comments (4)

  1. Frank Dellaert

    Indeed, ExpressionFactors are the way to go :-) But of course, you'd still be limited to composing existing functions. I don't see an easy way to add new functions in MATLAB. I'll think about it though...

  2. Frank Dellaert

    @dimka_kopitkov Just re-read your post. It might be possible, not using ExpressionFactors (which do a lot at compile time) but by subclassing from NoiseModelFactor. The main difficulty is then to find a way to pass a function from MATLAB into C++, at runtime, and have it work seamlessly with wrap. If you have an idea how to do that, feel free to prototype, and I can help integrate.

  3. Dimka Kopitkov reporter

    Yep, we need some way to create matlab callback for error and jacobians and to call it from c++. I'll think about something like this. Thanks!

  4. Log in to comment