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)
void print(const std::string &s="") const
print with optional string
virtual const Values & optimize()
A non-templated config holding any types of Manifold-group elements.
void insert(Key j, const Value &val)
static Rot3 RzRyRx(double x, double y, double z, OptionalJacobian< 3, 1 > Hx=boost::none, OptionalJacobian< 3, 1 > Hy=boost::none, OptionalJacobian< 3, 1 > Hz=boost::none)
Rotations around Z, Y, then X axes as in http://en.wikipedia.org/wiki/Rotation_matrix, counterclockwise when looking from unchanging axis.
NonlinearFactorGraph graph
std::vector< gtsam::Point3 > createPoints()
static Rot3 Rodrigues(const Vector3 &w)
const ValueType at(Key j) const
Factor graph that supports adding ExpressionFactors directly.
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
Expression< Point3 > Point3_
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)
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 addExpressionFactor(const Expression< T > &h, const T &z, const SharedNoiseModel &R)
double error(const Values &values) const
Expression< T > between(const Expression< T > &t1, const Expression< T > &t2)
Expression< Pose3 > Pose3_