Skip to content

Commit e4b1564

Browse files
committed
Allow for different sized point clouds
1 parent c76d9e4 commit e4b1564

12 files changed

+3598
-28
lines changed

Doxyfile

+2,732
Large diffs are not rendered by default.

book/asset/doxygen-style.css

+788
Large diffs are not rendered by default.

book/asset/img/closed-folder.png

365 Bytes
Loading

book/asset/img/document.png

535 Bytes
Loading

book/asset/img/off_sync.png

1.1 KB
Loading

book/asset/img/on_sync.png

876 Bytes
Loading

book/asset/img/opened-folder.png

562 Bytes
Loading

book/main.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
\mainpage Introduction
2+
3+
\section overview_sec Overview
4+
5+
<table>
6+
<tr>
7+
<th style="text-align:left; vertical-align:top">Item</th>
8+
<th style="text-align:left; vertical-align:top">Location</th>
9+
</tr>
10+
<tr>
11+
<td style="text-align:left; vertical-align:top"><b>Documentation</b></td>
12+
<td style="text-align:left; vertical-align:top">icp.h</td>
13+
</tr>
14+
<tr>
15+
<td style="text-align:left; vertical-align:top"><b>Repository</b></td>
16+
<td style="text-align:left; vertical-align:top">
17+
<a href="https://github.com/cornellev/scan-matching">https://github.com/cornellev/scan-matching</a>
18+
</td>
19+
</tr>
20+
<tr>
21+
<td style="text-align:left; vertical-align:top"><b>Contents</b></td>
22+
<td style="text-align:left; vertical-align:top">
23+
\ref overview_sec <br>
24+
\ref feature_sec <br>
25+
\ref install_sec <br>
26+
\ref example_sec
27+
</td>
28+
</tr>
29+
</table>
30+
31+
\section feature_sec Features
32+
33+
\section install_sec Usage
34+
35+
\subsection install_unix_subsec Unix-like (MacOS, Linux)
36+
37+
\subsection install_windows_subsec Windows
38+
39+
\section example_sec Example

sim.conf

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
# editing code to make sin wave makes a lot of these useless/weird now
2+
13
window_width = 1200
24
window_height = 900
35

4-
n = 700
6+
n = 300
57
scale = 2
68

79
slope = -1.0
8-
intercept = 200
10+
intercept = -450
911

10-
x_delta = -200
12+
x_delta = -100
1113

1214
perturbation_range = 10
1315

14-
x_displace = 300
15-
y_displace = 300
16+
x_displace = 50
17+
y_displace = 0
1618

17-
angle_displace = 0.5
19+
angle_displace = 0.1
1820

1921
# angle_displace = 0.785398 # M_PI_4 in radians

src/icp/icp.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ namespace icp {
6262
std::vector<double> dist;
6363

6464
/** A new ICP instance for `n`-point matching and an optimization rate
65-
* of `rate` */
66-
ICP(size_t n, double rate);
65+
* of `rate`. @deprecated `n` is ignored. */
66+
ICP(size_t n = 0, double rate = 0.01);
6767

6868
public:
6969
virtual ~ICP() = default;
@@ -96,10 +96,14 @@ namespace icp {
9696
* methods. */
9797
static const std::vector<std::string>& registered_methods();
9898

99-
/** Factory constructor for the ICP method `name`. @pre `name` is a
100-
* valid registered method. */
101-
static std::unique_ptr<ICP> from_method(std::string name, size_t n,
102-
double rate);
99+
/**
100+
* Factory constructor for the ICP method `name`. @pre `name` is a
101+
* valid registered method.
102+
*
103+
* @deprecated `n` is ignored.
104+
*/
105+
static std::unique_ptr<ICP> from_method(std::string name, size_t n = 0,
106+
double rate = 0.01);
103107
};
104108

105109
struct Methods {

src/icp/point_to_point.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ namespace icp {
1414
const std::vector<icp::Point>& b) override {
1515
size_t n = a.size();
1616
size_t m = b.size();
17+
pair.resize(n);
18+
dist.resize(n);
1719

1820
// compute center of mass of a
1921
double a_cm_x = 0;

src/sim/lidar_view.cpp

+19-16
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ void LidarView::construct_instance() {
3434
// Create a line of points for the wall
3535
for (int i = 0; i < sim_config::n; ++i) {
3636
double x = i * sim_config::scale;
37-
double y = sim_config::slope * x + sim_config::intercept + dis(gen);
37+
double y = ((std::sin(i / 10.0) + 1) * sim_config::scale * 100)
38+
+ sim_config::intercept + dis(gen); // now this is ugly fix
3839
wall[i] = {x, y};
3940
}
4041

4142
// Sample the first 3/4th and the last 3/4th as our LiDAR scans
4243
source.assign(wall.begin(), wall.begin() + sim_config::n * 3 / 4);
4344
destination.assign(wall.begin() + sim_config::n - (sim_config::n * 3 / 4),
4445
wall.end());
46+
double shift_because_scans_same_start = destination[0].x - source[0].x;
4547

4648
// Separate the scans to simulate robot movement
4749
for (icp::Point& point: source) {
@@ -51,6 +53,11 @@ void LidarView::construct_instance() {
5153
- y_unshift;
5254
}
5355

56+
double dest_move_x = sim_config::window_width / 2
57+
+ sim_config::x_displace / 2 - x_unshift;
58+
double dest_move_y = sim_config::window_height / 2
59+
+ sim_config::y_displace / 2 - y_unshift;
60+
5461
// TODO: make less scuffed way to do this
5562
icp->iterate(source, source);
5663
double cx = icp->transform().cx;
@@ -62,15 +69,10 @@ void LidarView::construct_instance() {
6269
for (icp::Point& point: source) {
6370
double new_x = com_rot.transform_x(point.x, point.y);
6471
double new_y = com_rot.transform_y(point.x, point.y);
65-
point.x = new_x + sim_config::x_delta;
72+
point.x = new_x + sim_config::x_delta + shift_because_scans_same_start;
6673
point.y = new_y;
6774
}
6875

69-
double dest_move_x = sim_config::window_width / 2
70-
+ sim_config::x_displace / 2 - x_unshift;
71-
double dest_move_y = sim_config::window_height / 2
72-
+ sim_config::y_displace / 2 - y_unshift;
73-
7476
for (icp::Point& point: destination) {
7577
point.x += dest_move_x + sim_config::x_delta;
7678
point.y += dest_move_y;
@@ -83,6 +85,7 @@ void LidarView::construct_instance() {
8385
// where you should be. if it works it works but should clean
8486
point.x += dest_move_x + sim_config::x_delta;
8587
point.y += dest_move_y;
88+
std::cout << point.x << ',' << point.y << '\n';
8689
}
8790
}
8891

@@ -101,22 +104,22 @@ void LidarView::draw(SDL_Renderer* renderer, const SDL_Rect* frame,
101104
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
102105
SDL_RenderClear(renderer);
103106

104-
SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE);
105-
for (const icp::Point& point: source) {
106-
SDL_DrawCircle(renderer, point.x, point.y, CIRCLE_RADIUS);
107-
}
107+
// SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE);
108+
// for (const icp::Point& point: source) {
109+
// SDL_DrawCircle(renderer, point.x, point.y, CIRCLE_RADIUS);
110+
// }
108111

109-
SDL_SetRenderDrawColor(renderer, 128, 128, 128, SDL_ALPHA_OPAQUE);
110-
for (const icp::Point& point: wall) {
111-
SDL_DrawCircle(renderer, point.x, point.y, CIRCLE_RADIUS);
112-
}
112+
// SDL_SetRenderDrawColor(renderer, 128, 128, 128, SDL_ALPHA_OPAQUE);
113+
// for (const icp::Point& point: wall) {
114+
// SDL_DrawCircle(renderer, point.x, point.y, CIRCLE_RADIUS);
115+
// }
113116

114117
SDL_SetRenderDrawColor(renderer, 0, 0, 255, SDL_ALPHA_OPAQUE);
115118
for (const icp::Point& point: destination) {
116119
SDL_DrawCircle(renderer, point.x, point.y, CIRCLE_RADIUS);
117120
}
118121

119-
SDL_SetRenderDrawColor(renderer, 0, 255, 255, 100);
122+
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 100);
120123
for (const icp::Point& point: source) {
121124
SDL_DrawCircle(renderer, icp->transform().transform_x(point.x, point.y),
122125
icp->transform().transform_y(point.x, point.y), CIRCLE_RADIUS);

0 commit comments

Comments
 (0)