55 using namespace gtsam;
58 int main(
int argc,
char** argv) {
82 newFactors.
addPrior(priorKey, priorMean, priorNoise);
83 newValues.
insert(priorKey, priorMean);
84 newTimestamps[priorKey] = 0.0;
92 Key previousKey(1000 * (
time-deltaT));
96 newTimestamps[currentKey] =
time;
102 newValues.
insert(currentKey, currentPose);
105 Pose2 odometryMeasurement1 =
Pose2(0.61, -0.08, 0.02);
109 Pose2 odometryMeasurement2 =
Pose2(0.47, 0.03, 0.01);
117 smootherBatch.
update(newFactors, newValues, newTimestamps);
118 smootherISAM2.
update(newFactors, newValues, newTimestamps);
119 for(
size_t i = 1;
i < 2; ++
i) {
124 cout << setprecision(5) <<
"Timestamp = " <<
time << endl;
130 newTimestamps.clear();
137 cout <<
"After 3.0 seconds, " << endl;
138 cout <<
" Batch Smoother Keys: " << endl;
139 for(
const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp: smootherBatch.
timestamps()) {
140 cout << setprecision(5) <<
" Key: " << key_timestamp.first <<
" Time: " << key_timestamp.second << endl;
142 cout <<
" iSAM2 Smoother Keys: " << endl;
143 for(
const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp: smootherISAM2.
timestamps()) {
144 cout << setprecision(5) <<
" Key: " << key_timestamp.first <<
" Time: " << key_timestamp.second << endl;
152 auto &factorGraph = smootherISAM2.
getFactors();
155 boost::shared_ptr<GaussianFactorGraph> linearGraph = factorGraph.
linearize(result);
158 Matrix jacobian = linearGraph->jacobian().first;
159 cout <<
" Jacobian: " << jacobian << endl;
void print(const Matrix &A, const string &s, ostream &stream)
Result update(const NonlinearFactorGraph &newFactors=NonlinearFactorGraph(), const Values &newTheta=Values(), const KeyTimestampMap ×tamps=KeyTimestampMap(), const FactorIndices &factorsToRemove=FactorIndices()) override
std::map< Key, double > KeyTimestampMap
Typedef for a Key-Timestamp map/database.
A non-templated config holding any types of Manifold-group elements.
Factor Graph consisting of non-linear factors.
void insert(Key j, const Value &val)
IsDerived< DERIVEDFACTOR > push_back(boost::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
Values calculateEstimate() const override
void addPrior(Key key, const T &prior, const SharedNoiseModel &model=nullptr)
Result update(const NonlinearFactorGraph &newFactors=NonlinearFactorGraph(), const Values &newTheta=Values(), const KeyTimestampMap ×tamps=KeyTimestampMap(), const FactorIndices &factorsToRemove=FactorIndices()) override
int main(int argc, char **argv)
const KeyTimestampMap & timestamps() const
An LM-based fixed-lag smoother.
An iSAM2-based fixed-lag smoother.
static const double deltaT
Pose2 priorMean(0.0, 0.0, 0.0)
boost::shared_ptr< Diagonal > shared_ptr
static ConjugateGradientParameters parameters
RelinearizationThreshold relinearizeThreshold
Values calculateEstimate() const override
const NonlinearFactorGraph & getFactors() const
noiseModel::Diagonal::shared_ptr priorNoise
boost::shared_ptr< GaussianFactorGraph > linearize(const Values &linearizationPoint) const
Linearize a nonlinear factor graph.
std::uint64_t Key
Integer nonlinear key type.