LocalizationFactor.cpp 574 B

1234567891011121314151617
  1. class UnaryFactor: public NoiseModelFactor1<Pose2> {
  2. double mx_, my_; ///< X and Y measurements
  3. public:
  4. UnaryFactor(Key j, double x, double y, const SharedNoiseModel& model):
  5. NoiseModelFactor1<Pose2>(model, j), mx_(x), my_(y) {}
  6. Vector evaluateError(const Pose2& q,
  7. boost::optional<Matrix&> H = boost::none) const
  8. {
  9. const Rot2& R = q.rotation();
  10. if (H) (*H) = (gtsam::Matrix(2, 3) <<
  11. R.c(), -R.s(), 0.0,
  12. R.s(), R.c(), 0.0).finished();
  13. return (Vector(2) << q.x() - mx_, q.y() - my_).finished();
  14. }
  15. };