Skip to content

Commit fffc2fb

Browse files
committed
[V2.0] Added the final log output in readme file
-- Refactored code specific to occupancy probability -- Added logs and requirements in readme -- Removed frequent timing log in ray tracing
1 parent 40a5f8d commit fffc2fb

File tree

6 files changed

+129
-4
lines changed

6 files changed

+129
-4
lines changed

README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ The detailed requirements and goals for this project are outlined in the officia
115115

116116
[View Project Assignment](./project_assignment.pdf)
117117

118+
### Requirements Compliance
119+
120+
#### Mandatory Requirements
121+
122+
| Requirement | Implementation Details |
123+
|-------------|----------------|
124+
| **Modern CMake** | CMakeLists.txt uses modern practices with target_* commands |
125+
| **Custom Class** | OccupancyGrid, DataAnalyzer, ScanProcessor classes |
126+
| **STL Algorithm** | std::for_each, std::reduce, std::minmax_element, std::clamp |
127+
| **STL Container** | std::vector, std::unordered_set, std::array |
128+
| **Lambda Functions** | Multiple lambdas in Bresenham algorithm (drawLineH, drawLineV, drawLineD) |
129+
130+
#### Core Functionality
131+
132+
| Feature | Implementation Details |
133+
|---------|----------------|
134+
| **3D Bresenham Algorithm** | draw_bresenham3d_line() with complete 3D implementation |
135+
| **Occupancy Grid Mapping** | Log-odds updates via update_occupied() and update_free() |
136+
| **Data Loading API** | Uses dataloader::Dataset as specified |
137+
| **Open3D Visualization** | visualize() function called with occupied voxels |
138+
| **Comprehensive Timing** | Average scan time, total time, detailed statistics |
139+
118140
## References
119141

120142
This project was developed with the help of the following educational resources:
@@ -123,3 +145,102 @@ This project was developed with the help of the following educational resources:
123145
- **Bresenham's Line Algorithm Coding Tutorial**: A coding tutorial for a 2D implementation of Bresenham's algorithm that was adapted to 3D for this project. [Watch on YouTube](https://youtu.be/CceepU1vIKo).
124146
- **SLAM Lecture on Occupancy Grid Mapping**: A comprehensive lecture covering the theory behind occupancy grid maps, including the log-odds representation, inverse sensor models, and the static binary Bayes filter, all of which are fundamental concepts for this project. [Watch on YouTube](https://youtu.be/v-Rm9TUG9LA).
125147

148+
## Output Logs
149+
150+
### Final Execution Output
151+
152+
```bash
153+
saiga@sai-Ideapad:~/Downloads/ModernCppProject2025/build$ ./occupancy_grid_main ../src/Data
154+
Loading dataset...
155+
Found 6770 scans
156+
157+
=== ANALYZING WORKSPACE ===
158+
Analyzing 6770 poses...
159+
Processed 0/6770 scans...
160+
Processed 338/6770 scans...
161+
Processed 676/6770 scans...
162+
Processed 1014/6770 scans...
163+
Processed 1352/6770 scans...
164+
Processed 1690/6770 scans...
165+
Processed 2028/6770 scans...
166+
Processed 2366/6770 scans...
167+
Processed 2704/6770 scans...
168+
Processed 3042/6770 scans...
169+
Processed 3380/6770 scans...
170+
Processed 3718/6770 scans...
171+
Processed 4056/6770 scans...
172+
Processed 4394/6770 scans...
173+
Processed 4732/6770 scans...
174+
Processed 5070/6770 scans...
175+
Processed 5408/6770 scans...
176+
Processed 5746/6770 scans...
177+
Processed 6084/6770 scans...
178+
Processed 6422/6770 scans...
179+
Processed 6760/6770 scans...
180+
=== WORKSPACE ANALYSIS ===
181+
Robot trajectory bounds:
182+
Min: -135.352 -219.638 -7.10028
183+
Max: 141.576 124.18 40.7033
184+
Range: 276.928 343.819 47.8035
185+
Total poses: 6770
186+
Total points processed: 432690151
187+
Dataset Analysis time: 26.0093 seconds
188+
189+
=== OPTIMAL GRID CONFIGURATION ===
190+
Origin: -163.1 -254.1 -11.9
191+
Dimensions: 3324×4126×574
192+
Resolution: 0.1m (10cm voxels)
193+
Total voxels: 7872308976
194+
Estimated memory: 30030.5 MB
195+
Grid covers: [-163.1 -254.1 -11.9] to [169.3 158.5 45.5]
196+
WARNING: Large memory usage! Consider:
197+
- Increasing resolution (e.g., 0.2m instead of 0.1m)
198+
- Reducing safety margin
199+
- Processing subset of data first
200+
201+
=== APPLYING OPTIMIZATIONS ===
202+
Auto-adjusted resolution to: 0.5m
203+
Optimized memory usage: 148.276 MB
204+
205+
=== OPTIMIZED GRID CONFIGURATION ===
206+
Origin: -138.2 -223.1 -7.6
207+
Dimensions: 565×702×98
208+
Resolution: 0.5m (50cm per voxels)
209+
Total voxels: 38869740
210+
Estimated memory: 148.276 MB
211+
Grid covers: [-138.2 -223.1 -7.6] to [144.3 127.9 41.4]
212+
213+
=== STARTING MAPPING ===
214+
OccupancyGrid3D initialized:
215+
Dimensions: 565×702×98
216+
Resolution: 0.5m
217+
Origin: -138.2 -223.1 -7.6
218+
Total voxels: 38869740
219+
Grid creation time: 0.048459 seconds
220+
221+
=== PROCESSING LIDAR SCANS ===
222+
Mapped :: 0/6770 scans...
223+
Mapped :: 677/6770 scans...
224+
Mapped :: 1354/6770 scans...
225+
Mapped :: 2031/6770 scans...
226+
Mapped :: 2708/6770 scans...
227+
Mapped :: 3385/6770 scans...
228+
Mapped :: 4062/6770 scans...
229+
Mapped :: 4739/6770 scans...
230+
Mapped :: 5416/6770 scans...
231+
Mapped :: 6093/6770 scans...
232+
Mapping completed!
233+
=== SCAN STATISTICS ===
234+
Total scans processed: 6770
235+
Total execution time: 274.296 seconds
236+
Best scan time: 0.0155139 seconds Worst scan time: 0.0891447 seconds
237+
Average time per scan: 40.3671 ms
238+
Scan rate: 24.6814 scans/second
239+
=== EXTRACTING OCCUPIED VOXELS ===
240+
Extracted 245669 occupied voxels from 245669 tracked voxels (vs 38869740 total voxels)
241+
Voxel extraction time: 0.018703 seconds.
242+
Visualising Voxels using open3D ===
243+
Visualizing 245669 occupied voxels...
244+
Visualization time: 49.313 seconds.
245+
```
246+

analyser.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,4 +886,5 @@ Extracted 245669 occupied voxels from 245669 tracked voxels (vs 38869740 total v
886886
Voxel extraction time: 0.0204954 seconds.
887887
Visualising Voxels using open3D ===
888888
Visualizing 245669 occupied voxels...
889-
```
889+
Visualization time: 49.313 seconds.
890+
````

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "visualizer.hpp"
1111
//#define TEST
1212

13-
constexpr float OCCUPANCY_THRESHOLD = 0.5f;
13+
1414

1515
void printTimingStats(const std::vector<double>& scan_times, double total_time) {
1616
std::cout << "=== SCAN STATISTICS ===" << std::endl;

src/occupancy_grid.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void OccupancyGrid::update_occupied(const Vector3i& idx) {
6767
LOG_ODDS_MIN, LOG_ODDS_MAX);
6868

6969
float prob = 1.0f / (1.0f + std::exp(-grid_data[index]));
70-
if (prob > 0.5f) { // Threshold for "occupied"
70+
if (prob > OCCUPANCY_THRESHOLD) { // Threshold for "occupied"
7171
occupied_cells.emplace(idx);
7272
}
7373
}
@@ -80,7 +80,7 @@ void OccupancyGrid::update_free(const Vector3i& idx) {
8080
LOG_ODDS_MIN, LOG_ODDS_MAX);
8181

8282
float prob = 1.0f / (1.0f + std::exp(-grid_data[index]));
83-
if (prob <= 0.5f) {
83+
if (prob <= OCCUPANCY_THRESHOLD) {
8484
occupied_cells.erase(idx);
8585
}
8686
}

src/occupancy_grid.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Vector3dVector = std::vector<Eigen::Vector3d>;
99
using Vector3d = Eigen::Vector3d;
1010
using Vector3i = Eigen::Vector3i;
11+
constexpr float OCCUPANCY_THRESHOLD = 0.5f;
1112

1213
class OccupancyGrid {
1314
private:

src/scan_processor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ void ScanProcessor::processLidarScan(OccupancyGrid& grid, const Eigen::Matrix4d&
3333
}
3434
});
3535

36+
/* Enable only for debugging
3637
std::cout << "Scan completed. Best rayTrace: " << min_time
3738
<< " us, Worst rayTrace: " << max_time << " us\n";
39+
*/
3840
}

0 commit comments

Comments
 (0)