42 #ifndef EIGEN_USE_NEW_STDVECTOR 43 #define EIGEN_USE_NEW_STDVECTOR 44 #endif // EIGEN_USE_NEW_STDVECTOR 50 #include <Eigen/Geometry> 52 #include <Eigen/StdVector> 62 #define SBA_DENSE_CHOLESKY 0 63 #define SBA_SPARSE_CHOLESKY 1 64 #define SBA_GRADIENT 2 65 #define SBA_BLOCK_JACOBIAN_PCG 3 92 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
98 Eigen::Matrix<double,3,1>
trans;
103 if (arot > M_PI) arot -= 2.0*M_PI;
104 if (arot < -M_PI) arot += 2.0*M_PI;
108 Eigen::Matrix<double,2,3>
w2n;
139 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
150 Eigen::Matrix<double,3,3>
prec;
153 Eigen::Matrix<double,3,1>
err;
155 inline double calcErr(
const Node2d &nd0,
const Node2d &nd1);
158 double calcErrDist(
const Node2d &nd0,
const Node2d &nd1);
162 Eigen::Matrix<double,3,3> J0,J0t,J1,
J1t;
166 const static double qScale = 1.0;
177 void setJacobians(std::vector<
Node2d,Eigen::aligned_allocator<Node2d> > &nodes);
190 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
193 SysSPA2d() { nFixed = 1; verbose =
false; lambda = 1.0e-4, print_iros_stats=
false; }
197 int addNode(
const Vector3d &pos,
int id);
198 void removeNode(
int id);
204 bool addConstraint(
int nd0,
int nd1,
const Vector3d &mean,
const Matrix3d &prec);
205 bool removeConstraint(
int ndi0,
int ndi1);
209 std::vector<Node2d,Eigen::aligned_allocator<Node2d> >
nodes;
210 std::vector<Node2d,Eigen::aligned_allocator<Node2d> >
getNodes()
214 std::vector< std::vector< Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > >
scans;
220 std::vector<Con2dP2,Eigen::aligned_allocator<Con2dP2> >
p2cons;
224 double calcCost(
bool tcost =
false);
226 double calcCost(
double dist);
232 void writeSparseA(
char *fname,
bool useCSparse =
false);
236 void setupSys(
double sLambda);
237 void setupSparseSys(
double sLambda,
int iter,
int sparseType);
244 int doSPA(
int niter,
double sLambda = 1.0e-4,
int useCSparse =
SBA_SPARSE_CHOLESKY,
double initTol = 1.0e-8,
int CGiters = 50);
245 int doSPAwindowed(
int window,
int niter,
double sLambda,
int useCSparse);
249 void doDSIF(
int newnode);
251 void setupSparseDSIF(
int newnode);
274 void getGraph(std::vector<float> &graph);
int nFixed
Number of fixed nodes.
bool isValid
valid or not (could be out of bounds)
Eigen::Matrix< double, 3, 1 > trans
6DOF pose as a unit quaternion and translation vector
Eigen::Matrix< double, 2, 3 > w2n
Resultant transform from world to node coordinates;.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SysSPA2d()
constructor
bool verbose
if we want statistics
EIGEN_MAKE_ALIGNED_OPERATOR_NEW int ndr
Reference pose index.
SysSPA2d holds a set of nodes and constraints for sparse pose adjustment.
void normArot()
Normalize to [-pi,+pi].
EIGEN_MAKE_ALIGNED_OPERATOR_NEW int nodeId
node id - somewhat redundant, but can be useful, e.g., in KARTO links
CSparse2d csp
sparse matrix object
#define SBA_SPARSE_CHOLESKY
double sqMinDelta
Convergence bound (square of minimum acceptable delta change)
bool read2dP2File(char *fname, SysSPA2d spa)
constraint files
Eigen::Matrix< double, 3, 3 > prec
std::vector< Node2d, Eigen::aligned_allocator< Node2d > > getNodes()
Eigen::Matrix< double, 3, 3 > J1t
int nd1
Node2d index for the second node.
Eigen::Matrix< double, 3, 1 > err
error
std::vector< Node2d, Eigen::aligned_allocator< Node2d > > nodes
set of nodes (camera frames) for SPA system, indexed by position;
std::vector< Con2dP2, Eigen::aligned_allocator< Con2dP2 > > p2cons
Set of P2 constraints.
Vector3< kt_double > Vector3d
Eigen::MatrixXd A
linear system matrix and vector
Vector2< kt_double > Vector2d
bool isFixed
For SPA, is this camera fixed or free?
std::vector< std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d > > > scans
set of point scans, corresponding to nodes
Eigen::Matrix< double, 3, 1 > oldtrans
Eigen::Vector2d tmean
Mean vector, quaternion (inverse) and precision matrix for this constraint.
void useCholmod(bool yes)
use CHOLMOD or CSparse