Matlab wrapper for IMU preintegration

Issue #294 resolved
Y Simson created an issue

The example called IMUKittiExampleGPS.m, fails with the error:

Undefined variable "gtsam" or class "gtsam.ImuFactorPreintegratedMeasurements".

Error in IMUKittiExampleGPS (line 82)
    currentSummarizedMeasurement = gtsam.ImuFactorPreintegratedMeasurements( ...

There doesn't appear to be an appropriate wrapper for this function.

In addition example CameraFlyingExample.m fails on:

No appropriate method, property, or field 'dist' for class 'gtsam.Point2'.

Error in CameraFlyingExample (line 123)
        if i > 1 && baseCentroid{i}.dist(baseCentroid{j}) < options.cylinder.radius * 2

Example SBAExample.m fails on:

No appropriate method, property, or field 'retract' for class 'gtsam.Point3'.

Error in SBAExample (line 67)
    point_j = truth.points{j}.retract(0.1*randn(3,1));

How can these bugs be fixed?

I am using matlab R2016b, Ubuntu 14.04 LTS

Comments (9)

  1. Y Simson reporter

    Also from unstable examples the data file KittiRelativePose_metadata.txt is missing as well

  2. John Novotny

    Same issue (no retract on point3, no dist on point2), Ubuntu 18.04, Matlab 2018b. Anything to try here?

  3. Mike Sheffler

    I think it's a matter of those MATLAB examples being updated for GTSAM 4.0. For example, In the 4.0 MATLAB toolbox, Point2.m has the following signature:

    %class Point2, see Doxygen page for details
    %at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
    %
    %-------Constructors-------
    %Point2()
    %Point2(double x, double y)
    %Point2(Vector v)
    %
    %-------Methods-------
    %distance(Point2 p2) : returns double
    %equals(Point2 point, double tol) : returns bool
    %norm() : returns double
    %print(string s) : returns void
    %vector() : returns Vector
    %x() : returns double
    %y() : returns double
    %
    %-------Static Methods-------
    %identity() : returns gtsam::Point2
    %
    %-------Serialization Interface-------
    %string_serialize() : returns string
    %string_deserialize(string serialized) : returns Point2
    

    there is no dist function. Compare with Point2.m from the GTSAM 3.2.1 MATLAB toolbox:

    %class Point2, see Doxygen page for details
    %at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
    %
    %-------Constructors-------
    %Point2()
    %Point2(double x, double y)
    %Point2(Vector v)
    %
    %-------Methods-------
    %between(Point2 p2) : returns gtsam::Point2
    %compose(Point2 p2) : returns gtsam::Point2
    %dim() : returns size_t
    %dist(Point2 p2) : returns double
    %equals(Point2 pose, double tol) : returns bool
    %inverse() : returns gtsam::Point2
    %localCoordinates(Point2 p) : returns Vector
    %norm() : returns double
    %print(string s) : returns void
    %retract(Vector v) : returns gtsam::Point2
    %vector() : returns Vector
    %x() : returns double
    %y() : returns double
    %
    %-------Static Methods-------
    %Dim() : returns size_t
    %Expmap(Vector v) : returns gtsam::Point2
    %Logmap(Point2 p) : returns Vector
    %identity() : returns gtsam::Point2
    %
    %-------Serialization Interface-------
    %string_serialize() : returns string
    %string_deserialize(string serialized) : returns Point2
    

    There is a dist function.

    Can you run IMUKittiExampleGPS.m? I've updated that test to work with the 4.0 MATLAB toolbox.

  4. Frank Dellaert

    It's been a while since I worked in MATLAB. I think Mike is right on. If anyone is interested in creating a PR to update the MATLAB examples that would be awesome. Should be easy, and will help us to officially release GTSAM 4.

  5. John Novotny

    Thanks for the replies, they put me on the write track. In SFMExample.m I opened the corresponding C++ example, and was able to resolve the differences to bring the matlab more inline with the C++ to get it working. I replaced the pose3 retract calls with compose calls with a randn initalized rotation and Point3. I'm coming up to speed with GTSAM so the matlab visualization is helpful.

    Here's that snippet with my mods in SFMExample (during the initial estimate initialization) in case others find it useful:

    initialEstimate = Values;
    alpha = 0.5;
    for i=1:size(truth.cameras,2)
    %     pose_i = truth.cameras{i}.pose.retract(0.1*randn(6,1));
        pose_i = truth.cameras{i}.pose.compose(gtsam.Pose3(Rot3.Rodrigues(alpha*randn(1), alpha*randn(1), alpha*randn(1)), ...
            Point3(alpha*randn(1), alpha*randn(1), alpha*randn(1))));
        initialEstimate.insert(symbol('x',i), pose_i);
    end
    for j=1:size(truth.points,2)
        point_j = Point3(truth.points{j}.vector() + [alpha*randn(1), alpha*randn(1), alpha*randn(1)]');
        initialEstimate.insert(symbol('p',j), point_j);
    end
    initialEstimate.print(sprintf('\nInitial estimate:\n  '));
    
  6. Mike Sheffler

    Glad to hear it, @jnovot.

    @dellaert , I can probably take on updating the MATLAB examples. I have a few quick questions first, though. Do you have a preferred way I can contact you via e-mail (if it's possible through BitBucket, I don't immediately see it).

  7. Frank Dellaert

    Issue #297 was marked as a duplicate of this issue. It's not strictly the same issue but if there is a PR that makes matlab examples work, I think this is one of the problems to be solved.

  8. Log in to comment