Skip to content

Commit a61d71d

Browse files
committed
Added parameters to set solver max iterations and max threads
1 parent 15c14bf commit a61d71d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/dllnode.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class DLLNode
6666
m_initZOffset = 0.0;
6767
if(!lnh.getParam("align_method", m_alignMethod))
6868
m_alignMethod = 1;
69+
if(!lnh.getParam("solver_max_iter", m_solverMaxIter))
70+
m_solverMaxIter = 75;
71+
if(!lnh.getParam("solver_max_threads", m_solverMaxThreads))
72+
m_solverMaxThreads = 8;
6973

7074
// Init internal variables
7175
m_init = false;
@@ -75,6 +79,10 @@ class DLLNode
7579
// Compute trilinear interpolation map
7680
m_grid3d.computeTrilinearInterpolation();
7781

82+
// Setup solver parameters
83+
m_solver.setMaxNumIterations(m_solverMaxIter);
84+
m_solver.setMaxNumThreads(m_solverMaxThreads);
85+
7886
// Launch subscribers
7987
m_pcSub = m_nh.subscribe(m_inCloudTopic, 1, &DLLNode::pointcloudCallback, this);
8088
m_initialPoseSub = lnh.subscribe("initial_pose", 2, &DLLNode::initialPoseReceived, this);
@@ -397,7 +405,7 @@ class DLLNode
397405
tf::Transform m_lastGlobalTf;
398406
bool m_doUpdate;
399407
double m_updateRate;
400-
int m_alignMethod;
408+
int m_alignMethod, m_solverMaxIter, m_solverMaxThreads;
401409
ros::Time m_lastPeriodicUpdate;
402410

403411
//! Node parameters

src/dllsolver.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ class DLLSolver
9090

9191
// Optimizer parameters
9292
int _max_num_iterations;
93+
int _max_num_threads;
9394

9495
public:
9596

9697
DLLSolver(Grid3d &grid) : _grid(grid)
9798
{
9899
google::InitGoogleLogging("DLLSolver");
99100
_max_num_iterations = 100;
101+
_max_num_threads = 8;
100102
}
101103

102104
~DLLSolver(void)
@@ -115,6 +117,17 @@ class DLLSolver
115117
return false;
116118
}
117119

120+
bool setMaxNumThreads(int n)
121+
{
122+
if(n>0)
123+
{
124+
_max_num_threads = n;
125+
return true;
126+
}
127+
else
128+
return false;
129+
}
130+
118131
bool solve(std::vector<pcl::PointXYZ> &p, double &tx, double &ty, double &tz, double &yaw)
119132
{
120133
// Initial solution
@@ -136,7 +149,7 @@ class DLLSolver
136149
options.minimizer_progress_to_stdout = false;
137150
options.linear_solver_type = ceres::DENSE_QR;
138151
options.max_num_iterations = _max_num_iterations;
139-
options.num_threads = 1;
152+
options.num_threads = _max_num_threads;
140153
Solver::Summary summary;
141154
Solve(options, &problem, &summary);
142155

0 commit comments

Comments
 (0)