-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSolver.h
More file actions
71 lines (57 loc) · 1.89 KB
/
Copy pathSolver.h
File metadata and controls
71 lines (57 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef SOLVER_H
#define SOLVER_H
#include "common.h"
#include "EigenUtil.h"
#include "DebugHelper.hpp"
#include "cuda_helper/helper_cuda.h"
#include <cublas_v2.h>
#include <cuda_runtime.h>
#include <array>
#include "SE3.h"
//#include <thrust/device_vector.h>
//#include <thrust/device_ptr.h>
using namespace Eigen;
//using thrust::device_vector;
class Solver {
public:
unsigned int numIters = 10;
void BuildLinearSystem(const float4* , const float4* , const float4* , const float* , int , int );
void PrintSystem();
void SolveJacobianSystem(const Matrix6x6f& JTJ, const Vector6f& JTr);
Solver();
~Solver();
Matrix4x4f getTransform() {return SE3Exp(estimate);};
double getError() {return TotalError;};
private:
int JAC_SIZE;
int RES_SIZE;
int JTJ_SIZE;
int JTr_SIZE;
const int num_vars_in_jac = 6;
std::array<float,36> raw_JTJ_matrix;
Vector6f update, estimate; //Will hold solution
bool solution_exists = false;
//Matrix4x4f deltaT; //intermediate estimated transform
Vector6f JTr; //for cost func [(T*src - dest)^2]
//MatrixXf Jac;
//VectorXf residual;
double TotalError;
int numCorrPairs = 0;
Matrix6x6f JTJ, JTJinv;
void CalculateJacobians(MatrixXf& J, const vec3& destVert,
const vec3& destNormal, int index);
void ComputeJTJandJTr(const Vector6f& J, Vector6f& JTJ, Vector6f& JTr);
Matrix4x4f DelinearizeTransform(const Vector6f& x);
//CUDA stuff
cudaError_t cudaStat;
cublasStatus_t stat;
cublasHandle_t handle;
//thrust::device_vector<float> d_Jac; //Computed on device
//thrust::device_vector<float> d_residual; //Computed on device
//thrust::device_vector<float> d_JTr; //then multiplied on device
//thrust::device_vector<float> d_JTJ; //finally this is computed
float* d_Jac = nullptr;
float* d_JTr = nullptr;
float* d_JTJ = nullptr;
};
#endif