Fix a bug in ExpressionFactor::initialize that changes the key ordering of factors derived from ExpressionFactor2. This impacts serialization and user expectation.

Example code:
Key key1 = 1, key2 = 2;
RangeFactorWithTransform factor(key2, key1,...); // keys_ should be {key2, key1}
After intialization, the bug will rearrange keys_ to an increasing order: keys_={key1, key2}.
release/4.3a0
Duy-Nguyen Ta 2016-03-07 15:20:42 -05:00
parent 83eeb58c7a
commit 8149bffcb7
2 changed files with 9 additions and 3 deletions

View File

@ -158,7 +158,13 @@ protected:
// Get keys and dimensions for Jacobian matrices // Get keys and dimensions for Jacobian matrices
// An Expression is assumed unmutable, so we do this now // An Expression is assumed unmutable, so we do this now
boost::tie(keys_, dims_) = expression_.keysAndDims(); if (keys_.empty())
boost::tie(keys_, dims_) = expression_.keysAndDims();
else {
std::map<Key, int> map;
expression_.dims(map);
for (Key key : keys_) dims_.push_back(map[key]);
}
} }
/// Recreate expression from keys_ and measured_, used in load below. /// Recreate expression from keys_ and measured_, used in load below.

View File

@ -38,8 +38,8 @@ typedef RangeFactor<Pose3, Point3> RangeFactor3D;
typedef RangeFactorWithTransform<Pose2, Point2> RangeFactorWithTransform2D; typedef RangeFactorWithTransform<Pose2, Point2> RangeFactorWithTransform2D;
typedef RangeFactorWithTransform<Pose3, Point3> RangeFactorWithTransform3D; typedef RangeFactorWithTransform<Pose3, Point3> RangeFactorWithTransform3D;
Key poseKey(1); Key poseKey(2);
Key pointKey(2); Key pointKey(1);
double measurement(10.0); double measurement(10.0);
/* ************************************************************************* */ /* ************************************************************************* */