changed template argument names
parent
10af1930bb
commit
503fe46306
|
@ -20,22 +20,22 @@ using namespace std;
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<class G, class T>
|
template<class Graph, class Config>
|
||||||
SubgraphSolver<G, T>::SubgraphSolver(const G& g, const T& theta0) {
|
SubgraphSolver<Graph, Config>::SubgraphSolver(const Graph& G, const Config& theta0) {
|
||||||
initialize(g,theta0);
|
initialize(G,theta0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<class G, class T>
|
template<class Graph, class Config>
|
||||||
void SubgraphSolver<G, T>::initialize(const G& g, const T& theta0) {
|
void SubgraphSolver<Graph, Config>::initialize(const Graph& G, const Config& theta0) {
|
||||||
|
|
||||||
// generate spanning tree
|
// generate spanning tree
|
||||||
PredecessorMap<Key> tree = g.template findMinimumSpanningTree<Key, Constraint>();
|
PredecessorMap<Key> tree = G.template findMinimumSpanningTree<Key, Constraint>();
|
||||||
list<Key> keys = predecessorMap2Keys(tree);
|
list<Key> keys = predecessorMap2Keys(tree);
|
||||||
|
|
||||||
// split the graph
|
// split the graph
|
||||||
if (verbose_) cout << "generating spanning tree and split the graph ...";
|
if (verbose_) cout << "generating spanning tree and split the graph ...";
|
||||||
g.template split<Key, Constraint>(tree, T_, C_);
|
G.template split<Key, Constraint>(tree, T_, C_);
|
||||||
if (verbose_) cout << T_.size() << " and " << C_.size() << " factors" << endl;
|
if (verbose_) cout << T_.size() << " and " << C_.size() << " factors" << endl;
|
||||||
|
|
||||||
// make the ordering
|
// make the ordering
|
||||||
|
@ -46,12 +46,12 @@ namespace gtsam {
|
||||||
|
|
||||||
// compose the approximate solution
|
// compose the approximate solution
|
||||||
Key root = keys.back();
|
Key root = keys.back();
|
||||||
theta_bar_ = composePoses<G, Constraint, Pose, T> (T_, tree, theta0[root]);
|
theta_bar_ = composePoses<Graph, Constraint, Pose, Config> (T_, tree, theta0[root]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<class G, class T>
|
template<class Graph, class Config>
|
||||||
boost::shared_ptr<SubgraphPreconditioner> SubgraphSolver<G, T>::linearize(const G& g, const T& theta_bar) const {
|
boost::shared_ptr<SubgraphPreconditioner> SubgraphSolver<Graph, Config>::linearize(const Graph& G, const Config& theta_bar) const {
|
||||||
SubgraphPreconditioner::sharedFG Ab1 = T_.linearize(theta_bar);
|
SubgraphPreconditioner::sharedFG Ab1 = T_.linearize(theta_bar);
|
||||||
SubgraphPreconditioner::sharedFG Ab2 = C_.linearize(theta_bar);
|
SubgraphPreconditioner::sharedFG Ab2 = C_.linearize(theta_bar);
|
||||||
#ifdef TIMING
|
#ifdef TIMING
|
||||||
|
@ -68,8 +68,8 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<class G, class T>
|
template<class Graph, class Config>
|
||||||
VectorConfig SubgraphSolver<G, T>::optimize(SubgraphPreconditioner& system) const {
|
VectorConfig SubgraphSolver<Graph, Config>::optimize(SubgraphPreconditioner& system) const {
|
||||||
VectorConfig zeros = system.zero();
|
VectorConfig zeros = system.zero();
|
||||||
|
|
||||||
// Solve the subgraph PCG
|
// Solve the subgraph PCG
|
||||||
|
|
|
@ -19,13 +19,13 @@ namespace gtsam {
|
||||||
* linearize: G * T -> L
|
* linearize: G * T -> L
|
||||||
* solve : L -> VectorConfig
|
* solve : L -> VectorConfig
|
||||||
*/
|
*/
|
||||||
template<class G, class T>
|
template<class Graph, class Config>
|
||||||
class SubgraphSolver {
|
class SubgraphSolver {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef typename T::Key Key;
|
typedef typename Config::Key Key;
|
||||||
typedef typename G::Constraint Constraint;
|
typedef typename Graph::Constraint Constraint;
|
||||||
typedef typename G::Pose Pose;
|
typedef typename Graph::Pose Pose;
|
||||||
|
|
||||||
// TODO not hardcode
|
// TODO not hardcode
|
||||||
static const size_t maxIterations_=100;
|
static const size_t maxIterations_=100;
|
||||||
|
@ -36,25 +36,25 @@ namespace gtsam {
|
||||||
boost::shared_ptr<Ordering> ordering_;
|
boost::shared_ptr<Ordering> ordering_;
|
||||||
|
|
||||||
/* the solution computed from the first subgraph */
|
/* the solution computed from the first subgraph */
|
||||||
boost::shared_ptr<T> theta_bar_;
|
boost::shared_ptr<Config> theta_bar_;
|
||||||
|
|
||||||
G T_, C_;
|
Graph T_, C_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SubgraphSolver() {}
|
SubgraphSolver() {}
|
||||||
|
|
||||||
SubgraphSolver(const G& g, const T& theta0);
|
SubgraphSolver(const Graph& G, const Config& theta0);
|
||||||
|
|
||||||
void initialize(const G& g, const T& theta0);
|
void initialize(const Graph& G, const Config& theta0);
|
||||||
|
|
||||||
boost::shared_ptr<Ordering> ordering() const { return ordering_; }
|
boost::shared_ptr<Ordering> ordering() const { return ordering_; }
|
||||||
|
|
||||||
boost::shared_ptr<T> theta_bar() const { return theta_bar_; }
|
boost::shared_ptr<Config> theta_bar() const { return theta_bar_; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* linearize the non-linear graph around the current config and build the subgraph preconditioner systme
|
* linearize the non-linear graph around the current config and build the subgraph preconditioner systme
|
||||||
*/
|
*/
|
||||||
boost::shared_ptr<SubgraphPreconditioner> linearize(const G& g, const T& theta_bar) const;
|
boost::shared_ptr<SubgraphPreconditioner> linearize(const Graph& G, const Config& theta_bar) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* solve for the optimal displacement in the tangent space, and then solve
|
* solve for the optimal displacement in the tangent space, and then solve
|
||||||
|
@ -63,9 +63,9 @@ namespace gtsam {
|
||||||
VectorConfig optimize(SubgraphPreconditioner& system) const;
|
VectorConfig optimize(SubgraphPreconditioner& system) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class G, class T> const size_t SubgraphSolver<G,T>::maxIterations_;
|
template<class Graph, class Config> const size_t SubgraphSolver<Graph,Config>::maxIterations_;
|
||||||
template<class G, class T> const bool SubgraphSolver<G,T>::verbose_;
|
template<class Graph, class Config> const bool SubgraphSolver<Graph,Config>::verbose_;
|
||||||
template<class G, class T> const double SubgraphSolver<G,T>::epsilon_;
|
template<class Graph, class Config> const double SubgraphSolver<Graph,Config>::epsilon_;
|
||||||
template<class G, class T> const double SubgraphSolver<G,T>::epsilon_abs_;
|
template<class Graph, class Config> const double SubgraphSolver<Graph,Config>::epsilon_abs_;
|
||||||
|
|
||||||
} // nsamespace gtsam
|
} // nsamespace gtsam
|
||||||
|
|
Loading…
Reference in New Issue