16 using namespace gtsam;
21 int main(
int argc,
char* argv[]) {
30 auto poses =
createPoses(init_pose, delta_pose1, steps);
31 auto poses2 =
createPoses(init_pose, delta_pose2, steps);
32 auto poses3 =
createPoses(init_pose, delta_pose3, steps);
35 poses.insert( poses.end(), poses2.begin(), poses2.end() );
36 poses.insert( poses.end(), poses3.begin(), poses3.end() );
53 Pose3_ body_T_sensor_(
'T', 0);
59 for (
size_t i = 0;
i < poses.size(); ++
i) {
60 auto world_T_sensor = poses[
i].compose(body_T_sensor_gt);
61 for (
size_t j = 0;
j < points.size(); ++
j) {
84 for (
size_t i = 0;
i < poses.size(); ++
i)
86 for (
size_t j = 0;
j < points.size(); ++
j)
92 std::cout <<
"initial error: " << graph.
error(initial) << std::endl;
94 std::cout <<
"final error: " << graph.
error(result) << std::endl;
98 body_T_sensor_gt.
print(
"\nGround truth body_T_sensor\n");
void print(const Matrix &A, const string &s, ostream &stream)
static Rot3 RzRyRx(double x, double y, double z, OptionalJacobian< 3, 1 > Hx={}, OptionalJacobian< 3, 1 > Hy={}, OptionalJacobian< 3, 1 > Hz={})
Rotations around Z, Y, then X axes as in http://en.wikipedia.org/wiki/Rotation_matrix, counterclockwise when looking from unchanging axis.
virtual const Values & optimize()
A non-templated config holding any types of Manifold-group elements.
const ValueType at(Key j) const
NonlinearFactorGraph graph
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
std::vector< gtsam::Point3 > createPoints()
static Point2 measurement(323.0, 240.0)
static Rot3 Rodrigues(const Vector3 &w)
Factor graph that supports adding ExpressionFactors directly.
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
double error(const Values &values) const
Expression< Point3 > Point3_
void print(const std::string &s="") const
print with optional string
static shared_ptr Sigmas(const Vector &sigmas, bool smart=true)
Expression< T > compose(const Expression< T > &t1, const Expression< T > &t2)
Simple example for the structure-from-motion problems.
void insert(Key j, const Value &val)
void addExpressionFactor(const Expression< T > &h, const T &z, const SharedNoiseModel &R)
Expression< T > between(const Expression< T > &t1, const Expression< T > &t2)
Expression< Pose3 > Pose3_
std::vector< gtsam::Pose3 > createPoses(const gtsam::Pose3 &init=gtsam::Pose3(gtsam::Rot3::Ypr(M_PI/2, 0,-M_PI/2), gtsam::Point3(30, 0, 0)), const gtsam::Pose3 &delta=gtsam::Pose3(gtsam::Rot3::Ypr(0,-M_PI/4, 0), gtsam::Point3(sin(M_PI/4) *30, 0, 30 *(1-sin(M_PI/4)))), int steps=8)