gtsam/slam/Simulated3D.h

93 lines
2.4 KiB
C
Raw Normal View History

/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
2009-08-22 06:23:24 +08:00
/**
2010-01-14 06:25:03 +08:00
* @file Simulated3D.h
* @brief measurement functions and derivatives for simulated 3D robot
* @author Alex Cunningham
**/
2009-08-22 06:23:24 +08:00
// \callgraph
#pragma once
#include <gtsam/base/Matrix.h>
#include <gtsam/geometry/Point3.h>
#include <gtsam/linear/VectorValues.h>
#include <gtsam/nonlinear/NonlinearFactor.h>
2010-10-09 06:04:47 +08:00
#include <gtsam/nonlinear/Key.h>
#include <gtsam/nonlinear/TupleValues.h>
2009-08-22 06:23:24 +08:00
// \namespace
namespace gtsam {
2010-01-14 06:25:03 +08:00
namespace simulated3D {
typedef gtsam::TypedSymbol<Point3, 'x'> PoseKey;
typedef gtsam::TypedSymbol<Point3, 'l'> PointKey;
2010-01-14 06:25:03 +08:00
typedef LieValues<PoseKey> PoseValues;
typedef LieValues<PointKey> PointValues;
typedef TupleValues2<PoseValues, PointValues> Values;
2010-01-14 06:25:03 +08:00
2009-08-22 06:23:24 +08:00
/**
2010-01-14 06:25:03 +08:00
* Prior on a single pose
*/
Point3 prior(const Point3& x, boost::optional<Matrix&> H = boost::none);
2010-01-14 06:25:03 +08:00
2009-08-22 06:23:24 +08:00
/**
2010-01-14 06:25:03 +08:00
* odometry between two poses
*/
Point3 odo(const Point3& x1, const Point3& x2,
boost::optional<Matrix&> H1 = boost::none,
boost::optional<Matrix&> H2 = boost::none);
2010-01-14 06:25:03 +08:00
2009-08-22 06:23:24 +08:00
/**
2010-01-14 06:25:03 +08:00
* measurement between landmark and pose
*/
Point3 mea(const Point3& x, const Point3& l,
boost::optional<Matrix&> H1 = boost::none,
boost::optional<Matrix&> H2 = boost::none);
2010-01-14 06:25:03 +08:00
struct PointPrior3D: public NonlinearFactor1<Values, PoseKey> {
2010-01-14 06:25:03 +08:00
Point3 z_;
2010-01-14 06:25:03 +08:00
PointPrior3D(const Point3& z,
const SharedGaussian& model, const PoseKey& j) :
NonlinearFactor1<Values, PoseKey> (model, j), z_(z) {
}
2010-01-14 06:25:03 +08:00
Vector evaluateError(const Point3& x, boost::optional<Matrix&> H =
2010-01-14 06:25:03 +08:00
boost::none) {
return (prior(x, H) - z_).vector();
2010-01-14 06:25:03 +08:00
}
2009-08-22 06:23:24 +08:00
};
2010-01-14 06:25:03 +08:00
struct Simulated3DMeasurement: public NonlinearFactor2<Values,
PoseKey, PointKey> {
2010-01-14 06:25:03 +08:00
Point3 z_;
2010-01-14 06:25:03 +08:00
Simulated3DMeasurement(const Point3& z,
const SharedGaussian& model, PoseKey& j1, PointKey j2) :
NonlinearFactor2<Values, PoseKey, PointKey> (
model, j1, j2), z_(z) {
}
2010-01-14 06:25:03 +08:00
Vector evaluateError(const Point3& x1, const Point3& x2, boost::optional<
2010-01-14 06:25:03 +08:00
Matrix&> H1 = boost::none, boost::optional<Matrix&> H2 = boost::none) {
return (mea(x1, x2, H1, H2) - z_).vector();
2010-01-14 06:25:03 +08:00
}
2009-08-22 06:23:24 +08:00
};
2010-01-14 06:25:03 +08:00
}} // namespace simulated3D