gtsam  4.0.0
gtsam
Scenario.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 #pragma once
21 
22 namespace gtsam {
23 
25 class Scenario {
26  public:
27  // Quantities a Scenario needs to specify:
28 
29  virtual Pose3 pose(double t) const = 0;
30  virtual Vector3 omega_b(double t) const = 0;
31  virtual Vector3 velocity_n(double t) const = 0;
32  virtual Vector3 acceleration_n(double t) const = 0;
33 
34  // Derived quantities:
35 
36  Rot3 rotation(double t) const { return pose(t).rotation(); }
37  NavState navState(double t) const { return NavState(pose(t), velocity_n(t)); }
38 
39  Vector3 velocity_b(double t) const {
40  const Rot3 nRb = rotation(t);
41  return nRb.transpose() * velocity_n(t);
42  }
43 
44  Vector3 acceleration_b(double t) const {
45  const Rot3 nRb = rotation(t);
46  return nRb.transpose() * acceleration_n(t);
47  }
48 };
49 
58  public:
60  ConstantTwistScenario(const Vector3& w, const Vector3& v)
61  : twist_((Vector6() << w, v).finished()), a_b_(w.cross(v)) {}
62 
63  Pose3 pose(double t) const override { return Pose3::Expmap(twist_ * t); }
64  Vector3 omega_b(double t) const override { return twist_.head<3>(); }
65  Vector3 velocity_n(double t) const override {
66  return rotation(t).matrix() * twist_.tail<3>();
67  }
68  Vector3 acceleration_n(double t) const override { return rotation(t) * a_b_; }
69 
70  private:
71  const Vector6 twist_;
72  const Vector3 a_b_; // constant centripetal acceleration in body = w_b * v_b
73 };
74 
77  public:
80  AcceleratingScenario(const Rot3& nRb, const Point3& p0, const Vector3& v0,
81  const Vector3& a_n,
82  const Vector3& omega_b = Vector3::Zero())
83  : nRb_(nRb), p0_(p0), v0_(v0), a_n_(a_n), omega_b_(omega_b) {}
84 
85  Pose3 pose(double t) const override {
86  return Pose3(nRb_.expmap(omega_b_ * t), p0_ + v0_ * t + a_n_ * t * t / 2.0);
87  }
88  Vector3 omega_b(double t) const override { return omega_b_; }
89  Vector3 velocity_n(double t) const override { return v0_ + a_n_ * t; }
90  Vector3 acceleration_n(double t) const override { return a_n_; }
91 
92  private:
93  const Rot3 nRb_;
94  const Vector3 p0_, v0_, a_n_, omega_b_;
95 };
96 
97 } // namespace gtsam
const Rot3 & rotation(OptionalJacobian< 3, 6 > H=boost::none) const
get rotation
Definition: Pose3.cpp:272
AcceleratingScenario(const Rot3 &nRb, const Point3 &p0, const Vector3 &v0, const Vector3 &a_n, const Vector3 &omega_b=Vector3::Zero())
Construct scenario with constant acceleration in navigation frame and optional angular velocity in bo...
Definition: Scenario.h:80
Definition: Pose3.h:37
Navigation state composing of attitude, position, and velocity.
Definition: Point3.h:45
Navigation state: Pose (rotation, translation) + velocity NOTE(frank): it does not make sense to make...
Definition: NavState.h:34
Point3 cross(const Point3 &p, const Point3 &q, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2)
cross product
Definition: Point3.cpp:120
Accelerating from an arbitrary initial state, with optional rotation.
Definition: Scenario.h:76
Simple trajectory simulator.
Definition: Scenario.h:25
ConstantTwistScenario(const Vector3 &w, const Vector3 &v)
Construct scenario with constant twist [w,v].
Definition: Scenario.h:60
Matrix3 transpose() const
Return 3*3 transpose (inverse) rotation matrix.
Definition: Rot3M.cpp:115
Definition: Rot3.h:56
Scenario with constant twist 3D trajectory.
Definition: Scenario.h:57
static Pose3 Expmap(const Vector6 &xi, OptionalJacobian< 6, 6 > H=boost::none)
Exponential map at identity - create a rotation from canonical coordinates .
Definition: Pose3.cpp:120
Global functions in a separate testing namespace.
Definition: chartTesting.h:28