-
Notifications
You must be signed in to change notification settings - Fork 919
Adds a Lie-Group aware differentiable spline curve implementation #2212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
cda9782
fa4f311
8b85bee
bbf6d54
6abd217
dc2f1cc
7619ddb
95aac63
acd924b
55bdd9b
842e9d3
580db7e
7cab6c8
e391125
5c2bc15
7c47248
6b060a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,230 @@ | ||||||
|
|
||||||
| #include <gtsam/nonlinear/Expression.h> | ||||||
| #include <gtsam/basis/polynomial/TrajectoryModel.h> | ||||||
| #include <gtsam/basis/polynomial/IrwinHall.h> | ||||||
| #include <gtsam/geometry/Pose3.h> | ||||||
|
|
||||||
| /** | ||||||
| * In this example, we estimate pose from pictures and landmarks using bundle adjustment in the usual way | ||||||
| * we also capture acceleration and rotation rates with a mems IMU on the camera. | ||||||
| * Notably, we don't assume that the camera, accelerometer, or gryo clocks are related to each other. | ||||||
| * We pick one sensor to be the clock datum, the other sensors' clocks are modelled as drifting in | ||||||
| * relation to that datum. | ||||||
| * we'll choose the camera's frame rate to be the datum clock for this example. | ||||||
| */ | ||||||
|
|
||||||
|
|
||||||
| // structs to collect and name the important measurements from each sensor | ||||||
| struct { | ||||||
| gtsam::Key camera_pose; // allow bundle adjustment to associate a Pose3 with a Key | ||||||
| double timestamp; // the timestamp (in seconds) for the shutter based on the camera's frame rate. | ||||||
| } shutter_event_t; | ||||||
|
|
||||||
| struct { | ||||||
| Vector3 acceleration; // raw acceleration measurement | ||||||
| double timestamp; // the timestamp (in seconds) extrapolated from the accelerometer sample rate | ||||||
| } acceleration_t; | ||||||
|
|
||||||
| struct { | ||||||
| Vector3 angular_velocity; // raw angular velocity measurement | ||||||
| double timestamp; // the timestamp (in seconds) extrapolated from the gyro sample rate | ||||||
| } angular_rate_t; | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| // alias the time derivatives of pose so we can express intent through types | ||||||
| using Vector3_ = Expression<Vector3>; | ||||||
| using Vector6_ = Expression<Vector6>; | ||||||
|
|
||||||
| using Pose3Deriv_ = Expression<typename traits<Pose3>::TangentVector>; // Vector6_ | ||||||
| using Pose3Vel_ = Pose3Deriv_; | ||||||
| using Pose3Accel_ = Pose3Deriv_; | ||||||
|
|
||||||
| using Point3Deriv_ = Vector3_; | ||||||
| using Point3Accel_ = Point3Deriv_; | ||||||
|
|
||||||
| using Rot3Deriv_ = Vector3_; | ||||||
| using Rot3Vel_ = Rot3Deriv_; | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| // We need to extract rotation and translation components from time derivatives of Pose3 | ||||||
| Rot3Deriv_ pose3DerivativeRotation(Pose3Deriv_ pose_derivative, OptionalJacobian<3, 6> H = {}){ | ||||||
| if (H) *H << I_3x3, Z_3x3; | ||||||
| return pose_derivative.seq(0,2); | ||||||
| } | ||||||
| Point3Deriv_ pose3DerivativeTranslation(Pose3Deriv_ pose_derivative, OptionalJacobian<3, 6> H = {}){ | ||||||
|
||||||
| Point3Deriv_ pose3DerivativeTranslation(Pose3Deriv_ pose_derivative, OptionalJacobian<3, 6> H = {}){ | |
| Point3Deriv_ pose3DerivativeTranslation(const Pose3Deriv_& pose_derivative, OptionalJacobian<3, 6> H = {}){ |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable 'accel_drift_key' is undefined. Should be 'accel_clock_drift_key' based on the declaration on line 144.
| initial_values.insert<double>(accel_drift_key, 0.0); | |
| initial_values.insert<double>(accel_clock_drift_key, 0.0); |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function 'sample_camera_add_slam_factors()' is undefined and not declared anywhere in the file.
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function 'sample_accelerometer()' is undefined and not declared anywhere in the file.
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function 'sample_gyro()' is undefined and not declared anywhere in the file.
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid syntax: 'Vector6()::Zero()' should be 'Vector6::Zero()' - cannot call static member function on temporary object.
| Vector6()::Zero(), | |
| Vector6::Zero(), |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
|
|
||
| #include "IrwinHall.h" | ||
| namespace gtsam { | ||
| namespace kernels { | ||
|
|
||
| /** | ||
| * coefficients for the Irwin Hall Probability Density Functions | ||
| * https://oeis.org/A188816 | ||
| */ | ||
|
|
||
| const PiecewisePolynomial<0,1> IrwinHall0({ | ||
| {1.}, | ||
| {0.,1.}, | ||
| 1./2. | ||
| }); | ||
| const PiecewisePolynomial<1,2> IrwinHall1({ | ||
| { 0., 1., | ||
| 2., -1.}, | ||
| {0.,1.,2.}, | ||
| 1. | ||
| }); | ||
| const PiecewisePolynomial<2,3> IrwinHall2({ | ||
| { 0. , 0. , 1./2., | ||
| -3./2., 6./2., -2./2., | ||
| 9./2., -6./2., 1./2.}, | ||
| {0.,1.,2.,3.}, | ||
| 3./2. | ||
| }); | ||
| const PiecewisePolynomial<3,4> IrwinHall3({ | ||
| { 0. , 0., 0., 1./6., | ||
| 2./3., -2., 2., -1./2., | ||
| -22./3., 10., -4., 1./2., | ||
| 32./3., -8., 2., -1./6.}, | ||
| {0.,1.,2.,3.,4.}, | ||
| 2. | ||
| }); | ||
| const PiecewisePolynomial<4,5> IrwinHall4({ | ||
| { 0. , 0. , 0. , 0. , 1./24., | ||
| -5./24., 5./6., -5./4., 5./6., -1./6. , | ||
| 155./24., -25./2., 35./4., -5./2., 1./4. , | ||
| -655./24., 65./2., -55./4., 5./2., -1./6. , | ||
| 625./24., -125./6., 25./4., -5./6., 1./24.}, | ||
| {0.,1.,2.,3.,4.,5.}, | ||
| 5./2. | ||
| }); | ||
| const PiecewisePolynomial<5,6> IrwinHall5({ | ||
| { 0. , 0. , 0. , 0. , 0. , 1./120., | ||
| 1./20., -1./4., 1./2., -1./2., 1./4., -1./24. , | ||
| -79./20., 39./4., -19./2., 9./2., -1. , 1./12. , | ||
| 731./20., -231./4., 71./2., -21./2., 3./2., -1./12. , | ||
| -1829./20., 409./4., -89./2., 19./2., -1. , 1./24. , | ||
| 324./5. , -54. , 18. , -3. , 1./4., -1./120.}, | ||
| {0.,1.,2.,3.,4.,5.,6.}, | ||
| 3. | ||
| }); | ||
| const PiecewisePolynomial<6,7> IrwinHall6({ | ||
| { 0. , 0. , 0. , 0. , 0. , 0. , 1./720., | ||
| -7./720., 7./120., -7./48., 7./36., -7./48., 7./120., -1./120., | ||
| 1337./720., -133./24. , 329./48., -161./36., 77./48., -7./24. , 1./48. , | ||
| -12089./360., 196./3. , -1253./24., 196./9. , -119./24., 7./12. , -1./36. , | ||
| 59591./360., -700./3. , 3227./24., -364./9. , 161./24., -7./12. , 1./48. , | ||
| -208943./720., 7525./24. , -6671./48., 1169./36., -203./48., 7./24. , -1./120., | ||
| 117649./720., -16807./120., 2401./48., -343./36., 49./48., -7./120., 1./720.}, | ||
| {0.,1.,2.,3.,4.,5.,6.,7.}, | ||
| 7./2. | ||
| }); | ||
|
|
||
| } // namespace kernels | ||
| } // namespace gtsam |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #pragma once | ||
|
|
||
| #include "PiecewisePolynomial.h" | ||
|
|
||
| namespace gtsam { | ||
| namespace kernels { | ||
|
|
||
| /** | ||
| * Irwin Hall coefficients are used by TrajectoryModel to implement | ||
| * canonical (monotonic) spline basis functions. | ||
| * These functions are piecewise-defined polynomials continuous up to the (N-1)th derivative | ||
| * Irwin Hall CDF 0 is a basis for a zeroth order spline (linear interpolation) | ||
| * Irwin Hall CDF 2 is a basis for a cubic polynomial, so it has linear accelerations | ||
| * | ||
| * This series of fucntions converges pretty quickly to a gaussian. | ||
| * If you need higher orders (N), you can use a gaussian kernel and CDF directly | ||
| * approximately e^(-(1/2)((x-N/2)/(0.3*N/2)^2 ) | ||
| */ | ||
|
|
||
| // https://oeis.org/A188816 | ||
| extern const PiecewisePolynomial<0,1> IrwinHall0; | ||
| extern const PiecewisePolynomial<1,2> IrwinHall1; | ||
| extern const PiecewisePolynomial<2,3> IrwinHall2; | ||
| extern const PiecewisePolynomial<3,4> IrwinHall3; | ||
| extern const PiecewisePolynomial<4,5> IrwinHall4; | ||
| extern const PiecewisePolynomial<5,6> IrwinHall5; | ||
| extern const PiecewisePolynomial<6,7> IrwinHall6; | ||
|
|
||
| // https://oeis.org/A188668 | ||
| extern const PiecewisePolynomial<1,1> IrwinHallCDF0; // produces a linear interpolator | ||
| extern const PiecewisePolynomial<2,2> IrwinHallCDF1; | ||
| extern const PiecewisePolynomial<3,3> IrwinHallCDF2; // produces a cubic spline | ||
| extern const PiecewisePolynomial<4,4> IrwinHallCDF3; | ||
| extern const PiecewisePolynomial<5,5> IrwinHallCDF4; | ||
| extern const PiecewisePolynomial<6,6> IrwinHallCDF5; | ||
| extern const PiecewisePolynomial<7,7> IrwinHallCDF6; | ||
|
|
||
| } // namespace kernels | ||
| } // namespace gtsam |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parameter should be passed by const reference for efficiency: 'const Pose3Deriv_& pose_derivative'