|
NASA Astrobee Robot Software
0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
|
Go to the documentation of this file.
19 #ifndef GRAPH_OPTIMIZER_GRAPH_OPTIMIZER_H_
20 #define GRAPH_OPTIMIZER_GRAPH_OPTIMIZER_H_
30 #include <gtsam/nonlinear/NonlinearFactorGraph.h>
32 #include <boost/serialization/serialization.hpp>
63 void AddNodeAdder(std::shared_ptr<node_adders::NodeAdder> node_adder);
66 void AddFactorAdder(std::shared_ptr<factor_adders::FactorAdder> factor_adder);
77 int AddFactors(
const std::pair<localization_common::Time, localization_common::Time>& start_and_end_time);
84 boost::optional<gtsam::Matrix>
Covariance(
const gtsam::Key& key)
const;
88 boost::optional<gtsam::Matrix>
Covariance(
const gtsam::Key& key_a,
const gtsam::Key& key_b)
const;
91 const gtsam::NonlinearFactorGraph&
factors()
const;
94 gtsam::NonlinearFactorGraph&
factors();
97 template <
typename FactorType>
98 std::vector<boost::shared_ptr<const FactorType>>
Factors()
const;
104 template <
typename FactorType>
116 std::shared_ptr<nodes::Values>
values();
139 virtual void Print()
const;
146 boost::optional<const gtsam::Marginals&>
marginals()
const;
150 void AddAveragersAndTimers();
157 template <
class Archive>
158 void serialize(Archive& ar,
const unsigned int file_version) {
159 ar& BOOST_SERIALIZATION_NVP(params_);
160 ar& BOOST_SERIALIZATION_NVP(optimizer_);
161 ar& BOOST_SERIALIZATION_NVP(factors_);
162 ar& BOOST_SERIALIZATION_NVP(values_);
163 ar& BOOST_SERIALIZATION_NVP(factor_adders_);
164 ar& BOOST_SERIALIZATION_NVP(node_adders_);
165 ar& BOOST_SERIALIZATION_NVP(stats_logger_);
166 ar& BOOST_SERIALIZATION_NVP(optimization_timer_);
167 ar& BOOST_SERIALIZATION_NVP(optimization_timer_);
168 ar& BOOST_SERIALIZATION_NVP(optimization_iterations_averager_);
169 ar& BOOST_SERIALIZATION_NVP(total_error_averager_);
173 std::unique_ptr<optimizers::Optimizer> optimizer_;
174 gtsam::NonlinearFactorGraph factors_;
175 std::shared_ptr<nodes::Values> values_;
176 std::vector<std::shared_ptr<factor_adders::FactorAdder>> factor_adders_;
177 std::vector<std::shared_ptr<node_adders::NodeAdder>> node_adders_;
188 template <
typename FactorType>
190 std::vector<boost::shared_ptr<const FactorType>> factors_vector;
191 for (
const auto& factor :
factors()) {
192 const auto casted_factor = boost::dynamic_pointer_cast<const FactorType>(factor);
193 if (casted_factor) factors_vector.emplace_back(casted_factor);
195 return factors_vector;
198 template <
typename FactorType>
201 for (
const auto& factor :
factors()) {
202 const auto casted_factor = boost::dynamic_pointer_cast<const FactorType>(factor);
209 #endif // GRAPH_OPTIMIZER_GRAPH_OPTIMIZER_H_
localization_common::StatsLogger & stats_logger()
Definition: graph_optimizer.cc:104
int NumFactors() const
Definition: graph_optimizer.h:199
Definition: averager.h:34
double TotalGraphError() const
Definition: graph_optimizer.cc:112
std::vector< boost::shared_ptr< const FactorType > > Factors() const
Definition: graph_optimizer.h:189
GraphOptimizer()
Definition: graph_optimizer.h:57
Definition: stats_logger.h:30
Definition: graph_optimizer.h:51
void AddNodeAdder(std::shared_ptr< node_adders::NodeAdder > node_adder)
Definition: graph_optimizer.cc:40
int num_factors() const
Definition: graph_optimizer.cc:92
int AddFactors(const localization_common::Time start_time, const localization_common::Time end_time)
Definition: graph_optimizer.cc:49
virtual void Print() const
Definition: graph_optimizer.cc:123
virtual ~GraphOptimizer()=default
virtual bool ValidGraph() const
Definition: graph_optimizer.cc:121
std::shared_ptr< nodes::Values > values()
Definition: graph_optimizer.cc:98
Definition: graph_optimizer.h:39
const gtsam::Values & gtsam_values() const
Definition: graph_optimizer.cc:100
boost::optional< gtsam::Matrix > Covariance(const gtsam::Key &key) const
Definition: graph_optimizer.cc:80
const localization_common::Timer & optimization_timer() const
Definition: graph_optimizer.cc:106
void AddFactorAdder(std::shared_ptr< factor_adders::FactorAdder > factor_adder)
Definition: graph_optimizer.cc:45
int num_values() const
Definition: graph_optimizer.cc:94
bool Optimize()
Definition: graph_optimizer.cc:61
const gtsam::NonlinearFactorGraph & factors() const
Definition: graph_optimizer.cc:88
const GraphOptimizerParams & params() const
Definition: graph_optimizer.cc:96
Definition: graph_optimizer_params.h:22
double Time
Definition: time.h:23
void SaveGraphDotFile(const std::string &output_path="graph.dot") const
Definition: graph_optimizer.cc:128
boost::optional< const gtsam::Marginals & > marginals() const
Definition: graph_optimizer.cc:133
const localization_common::Averager & optimization_iterations_averager() const
Definition: graph_optimizer.cc:108
friend class boost::serialization::access
Definition: graph_optimizer.h:156