new HybridSmoother::relinearize method
parent
82fc21a7e6
commit
d27583ba92
|
@ -101,6 +101,12 @@ void HybridSmoother::update(const HybridNonlinearFactorGraph &newFactors,
|
||||||
std::optional<size_t> maxNrLeaves,
|
std::optional<size_t> maxNrLeaves,
|
||||||
const std::optional<Ordering> given_ordering) {
|
const std::optional<Ordering> given_ordering) {
|
||||||
HybridGaussianFactorGraph linearizedFactors = *newFactors.linearize(initial);
|
HybridGaussianFactorGraph linearizedFactors = *newFactors.linearize(initial);
|
||||||
|
|
||||||
|
// Record the new nonlinear factors and
|
||||||
|
// linearization point for relinearization
|
||||||
|
allFactors_.push_back(newFactors);
|
||||||
|
linearizationPoint_.insert_or_assign(initial);
|
||||||
|
|
||||||
const KeySet originalNewFactorKeys = newFactors.keys();
|
const KeySet originalNewFactorKeys = newFactors.keys();
|
||||||
#ifdef DEBUG_SMOOTHER
|
#ifdef DEBUG_SMOOTHER
|
||||||
std::cout << "hybridBayesNet_ size before: " << hybridBayesNet_.size()
|
std::cout << "hybridBayesNet_ size before: " << hybridBayesNet_.size()
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace gtsam {
|
||||||
class GTSAM_EXPORT HybridSmoother {
|
class GTSAM_EXPORT HybridSmoother {
|
||||||
private:
|
private:
|
||||||
HybridNonlinearFactorGraph allFactors_;
|
HybridNonlinearFactorGraph allFactors_;
|
||||||
|
Values linearizationPoint_;
|
||||||
|
|
||||||
HybridBayesNet hybridBayesNet_;
|
HybridBayesNet hybridBayesNet_;
|
||||||
/// The threshold above which we make a decision about a mode.
|
/// The threshold above which we make a decision about a mode.
|
||||||
|
@ -125,6 +126,16 @@ class GTSAM_EXPORT HybridSmoother {
|
||||||
/// Optimize the hybrid Bayes Net, taking into accound fixed values.
|
/// Optimize the hybrid Bayes Net, taking into accound fixed values.
|
||||||
HybridValues optimize() const;
|
HybridValues optimize() const;
|
||||||
|
|
||||||
|
void relinearize() {
|
||||||
|
allFactors_ = allFactors_.restrict(fixedValues_);
|
||||||
|
HybridGaussianFactorGraph::shared_ptr linearized =
|
||||||
|
allFactors_.linearize(linearizationPoint_);
|
||||||
|
HybridBayesNet::shared_ptr bayesNet = linearized->eliminateSequential();
|
||||||
|
HybridValues delta = bayesNet->optimize();
|
||||||
|
linearizationPoint_ = linearizationPoint_.retract(delta.continuous());
|
||||||
|
reInitialize(*bayesNet);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Helper to compute the ordering if ordering is not given.
|
/// Helper to compute the ordering if ordering is not given.
|
||||||
Ordering maybeComputeOrdering(const HybridGaussianFactorGraph& updatedGraph,
|
Ordering maybeComputeOrdering(const HybridGaussianFactorGraph& updatedGraph,
|
||||||
|
|
|
@ -287,6 +287,8 @@ class HybridSmoother {
|
||||||
std::optional<size_t> maxNrLeaves = std::nullopt,
|
std::optional<size_t> maxNrLeaves = std::nullopt,
|
||||||
const std::optional<gtsam::Ordering> given_ordering = std::nullopt);
|
const std::optional<gtsam::Ordering> given_ordering = std::nullopt);
|
||||||
|
|
||||||
|
void relinearize();
|
||||||
|
|
||||||
gtsam::Ordering getOrdering(const gtsam::HybridGaussianFactorGraph& factors,
|
gtsam::Ordering getOrdering(const gtsam::HybridGaussianFactorGraph& factors,
|
||||||
const gtsam::KeySet& newFactorKeys);
|
const gtsam::KeySet& newFactorKeys);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue