Skip to content

Commit d68d98f

Browse files
committed
comparison-algorithm
1 parent 88aab14 commit d68d98f

File tree

20 files changed

+2819
-144
lines changed

20 files changed

+2819
-144
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@ add_executable(consistency src/simulation/consistency.cpp)
4343
target_link_libraries(consistency ${catkin_LIBRARIES} ${PCL_LIBRARIES})
4444

4545
add_executable(benchmark_virtual src/benchmark/benchmark_virtual.cpp)
46-
target_link_libraries(benchmark_virtual ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES})
46+
target_link_libraries(benchmark_virtual ${catkin_LIBRARIES} ${PCL_LIBRARIES})
4747

4848
add_executable(benchmark_realworld src/benchmark/benchmark_realworld.cpp)
4949
target_link_libraries(benchmark_realworld ${catkin_LIBRARIES} ${PCL_LIBRARIES})
5050

51+
add_executable(PA_test src/compare_test/PA_test.cpp)
52+
target_link_libraries(PA_test ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES})
5153

54+
add_executable(BAREG_test src/compare_test/BAREG_test.cpp)
55+
target_link_libraries(BAREG_test ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES})
5256

57+
add_executable(BALM1_test src/compare_test/BALM1_test.cpp)
58+
target_link_libraries(BALM1_test ${catkin_LIBRARIES} ${PCL_LIBRARIES})
5359

60+
add_executable(EF_test src/compare_test/EF_test.cpp src/compare_test/SE3/SO3.cpp src/compare_test/SE3/SE3.cpp)
61+
target_link_libraries(EF_test ${catkin_LIBRARIES} ${PCL_LIBRARIES})
5462

5563

Supplementary/Supplementary.pdf

2.5 KB
Binary file not shown.

include/tools.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ class PointCluster
338338
P = stat.R*sigv.P*stat.R.transpose() + rp + rp.transpose() + N*stat.p*stat.p.transpose();
339339
}
340340

341+
void transform(const PointCluster &sigv, const Eigen::Matrix3d &R, const Eigen::Vector3d &p)
342+
{
343+
N = sigv.N;
344+
v = R*sigv.v + N*p;
345+
Eigen::Matrix3d rp = R * sigv.v * p.transpose();
346+
P = R*sigv.P*R.transpose() + rp + rp.transpose() + N*p*p.transpose();
347+
}
348+
341349
};
342350

343351

launch/compare.launch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<launch>
2+
<arg name="rviz" default="true" />
3+
4+
<param name="tseed" type="int" value="2" />
5+
<!-- <node pkg="balm2" type="PA_test" name="PA_test" output="screen"/> -->
6+
<!-- <node pkg="balm2" type="BAREG_test" name="BAREG_test" output="screen"/> -->
7+
<!-- <node pkg="balm2" type="BALM1_test" name="BALM1_test" output="screen"/> -->
8+
<node pkg="balm2" type="EF_test" name="EF_test" output="screen"/>
9+
10+
<group if="$(arg rviz)">
11+
<node launch-prefix="nice" pkg="rviz" type="rviz" name="rviz" args="-d $(find balm2)/rviz_cfg/back.rviz" />
12+
</group>
13+
14+
</launch>

rviz_cfg/back.rviz

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Panels:
3030
Experimental: false
3131
Name: Time
3232
SyncMode: 0
33-
SyncSource: path
33+
SyncSource: Test
3434
Preferences:
3535
PromptSaveOnExit: true
3636
Toolbars:
@@ -281,25 +281,25 @@ Visualization Manager:
281281
Views:
282282
Current:
283283
Class: rviz/Orbit
284-
Distance: 51.05740737915039
284+
Distance: 9.436324119567871
285285
Enable Stereo Rendering:
286286
Stereo Eye Separation: 0.05999999865889549
287287
Stereo Focal Distance: 1
288288
Swap Stereo Eyes: false
289289
Value: false
290290
Field of View: 0.7853981852531433
291291
Focal Point:
292-
X: -3.909618616104126
293-
Y: -3.380894660949707
294-
Z: -1.017249584197998
292+
X: 0
293+
Y: 0
294+
Z: 0
295295
Focal Shape Fixed Size: false
296296
Focal Shape Size: 0.05000000074505806
297297
Invert Z Axis: false
298298
Name: Current View
299299
Near Clip Distance: 0.009999999776482582
300-
Pitch: 1.285398006439209
300+
Pitch: 0.5953984260559082
301301
Target Frame: <Fixed Frame>
302-
Yaw: 2.7353944778442383
302+
Yaw: 1.7353978157043457
303303
Saved: ~
304304
Window Geometry:
305305
Displays:

src/benchmark/benchmark_virtual.cpp

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <geometry_msgs/PoseArray.h>
77
#include <random>
88
#include <ctime>
9-
#include "PA_ceres_head.hpp"
109
using namespace std;
1110

1211
const double one_three = (1.0 / 3.0);
@@ -101,134 +100,6 @@ void data_show(const vector<IMUST> &xBuf, vector<pcl::PointCloud<PointType>::Ptr
101100
pub_pl_func(pl_send, pub_test);
102101
}
103102

104-
class PlaneAdjustmentCeres
105-
{
106-
public:
107-
double ceres_iteration(vector<IMUST> &x_stats, vector<pcl::PointCloud<PointType>::Ptr> &plSurfs)
108-
{
109-
printf("Plane Adjustment (PA) is used.\n");
110-
111-
PLV(3) rot_params, pos_params, pla_params;
112-
vector<PLM(4)*> plvecMat4s;
113-
114-
int win_size = x_stats.size();
115-
for(int i=0; i<win_size; i++)
116-
{
117-
rot_params.push_back(Log(x_stats[i].R));
118-
pos_params.push_back(x_stats[i].p);
119-
}
120-
121-
for(pcl::PointCloud<PointType>::Ptr plPtr : plSurfs)
122-
{
123-
plvecMat4s.push_back(new PLM(4)(winSize));
124-
PLM(4) &plvecVoxel = *plvecMat4s.back();
125-
126-
for(Eigen::Matrix4d &mat : plvecVoxel)
127-
mat.setZero();
128-
129-
PointCluster vf;
130-
for(PointType &ap : plPtr->points)
131-
{
132-
int fn = ap.intensity;
133-
Eigen::Vector4d pvec(ap.x, ap.y, ap.z, 1);
134-
plvecVoxel[fn] += pvec * pvec.transpose();
135-
vf.push(x_stats[fn].R * pvec.head(3) + x_stats[fn].p);
136-
}
137-
138-
for(Eigen::Matrix4d &mat : plvecVoxel)
139-
{
140-
Eigen::SelfAdjointEigenSolver<Eigen::Matrix4d> saes(mat);
141-
Eigen::Vector4d evalue = saes.eigenvalues();
142-
Eigen::Matrix4d mleft = saes.eigenvectors();
143-
Eigen::Matrix4d mvalue; mvalue.setZero();
144-
for(int i=0; i<4; i++)
145-
{
146-
if(evalue[i] > 0)
147-
mvalue(i, i) = sqrt(evalue[i]);
148-
}
149-
mat = (mleft * mvalue).transpose();
150-
// mat = mat.llt().matrixL().transpose();
151-
}
152-
153-
Eigen::Vector3d center = vf.v / vf.N;
154-
Eigen::Matrix3d covMat = vf.P / vf.N - center * center.transpose();
155-
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> saes(covMat);
156-
Eigen::Vector3d pi = saes.eigenvectors().col(0);
157-
double d = - pi.dot(center);
158-
pla_params.push_back(d * pi);
159-
}
160-
161-
double t1 = ros::Time::now().toSec();
162-
163-
ceres::Problem problem;
164-
for(int i=0; i<win_size; i++)
165-
{
166-
ceres::LocalParameterization *parametrization = new ParamSO3();
167-
problem.AddParameterBlock(rot_params[i].data(), 3, parametrization);
168-
problem.AddParameterBlock(pos_params[i].data(), 3);
169-
}
170-
// problem.SetParameterBlockConstant(rot_params[0].data());
171-
// problem.SetParameterBlockConstant(pos_params[0].data());
172-
173-
for(int i=0; i<plvecMat4s.size(); i++)
174-
{
175-
PLM(4) &plvecVoxel = *plvecMat4s[i];
176-
for(int j=0; j<win_size; j++)
177-
{
178-
PACeresFactor *f = new PACeresFactor(plvecVoxel[j]);
179-
problem.AddResidualBlock(f, NULL, rot_params[j].data(), pos_params[j].data(), pla_params[i].data());
180-
}
181-
}
182-
183-
ceres::Solver::Options options;
184-
// options.linear_solver_type = ceres::SPARSE_SCHUR;
185-
options.linear_solver_type = ceres::DENSE_SCHUR;
186-
options.trust_region_strategy_type = ceres::LEVENBERG_MARQUARDT;
187-
options.max_num_iterations = 1000;
188-
options.minimizer_progress_to_stdout = true;
189-
190-
options.function_tolerance = 1e-10;
191-
options.parameter_tolerance = 1e-10;
192-
193-
options.use_inner_iterations = true;
194-
ceres::ParameterBlockOrdering* ordering = new ceres::ParameterBlockOrdering;
195-
for(int i=0; i<win_size; i++)
196-
{
197-
ordering->AddElementToGroup(rot_params[i].data(), 0);
198-
ordering->AddElementToGroup(pos_params[i].data(), 1);
199-
}
200-
for(int i=0; i<pla_params.size(); i++)
201-
{
202-
ordering->AddElementToGroup(pla_params[i].data(), 2);
203-
}
204-
options.inner_iteration_ordering.reset(ordering);
205-
206-
ceres::Solver::Summary summary;
207-
ceres::Solve(options, &problem, &summary);
208-
// cout << summary.BriefReport() << endl;
209-
// cout << summary.FullReport() << endl;
210-
211-
for(int i=0; i<win_size; i++)
212-
{
213-
x_stats[i].R = Exp(rot_params[i]);
214-
x_stats[i].p = pos_params[i];
215-
}
216-
217-
for(int j=1; j<winSize; j++)
218-
{
219-
x_stats[j].p = x_stats[0].R.transpose() * (x_stats[j].p - x_stats[0].p);
220-
x_stats[j].R = x_stats[0].R.transpose() * x_stats[j].R;
221-
}
222-
223-
x_stats[0].R.setIdentity();
224-
x_stats[0].p.setZero();
225-
226-
double t2 = ros::Time::now().toSec();
227-
return t2 - t1;
228-
}
229-
230-
};
231-
232103
class BALM2
233104
{
234105
public:
@@ -674,8 +545,6 @@ int main(int argc, char **argv)
674545
printf("pstSize: %d\n", ptsSize);
675546

676547
int tseed = time(0);
677-
// int tseed = 1662299903;
678-
679548
default_random_engine e(tseed);
680549
uniform_real_distribution<double> randNorml(-M_PI, M_PI);
681550
uniform_real_distribution<double> randRange(-surf_range, surf_range);

0 commit comments

Comments
 (0)