LidarRansac-C, Lidar sensör verilerini işleyerek 2D ortamda RANSAC (Random Sample Consensus) algoritması ile doğru (line) tespiti yapan, saf C dilinde yazılmış performans odaklı bir projedir.
Bu proje, gürültülü sensör verilerinden anlamlı geometrik şekiller çıkarmak ve robotik haritalama/konumlandırma (SLAM) süreçlerine temel oluşturmak amacıyla geliştirilmiştir.
(Not: Görsel, proje çalıştırıldıktan sonra gnuplot ile üretilmektedir)
- TOML Veri İşleme: Lidar tarama verilerini (
scan.toml) okur ve ayrıştırır. - Esnek Veri Girişi: Yerel dosyalardan veya doğrudan URL üzerinden veri okuyabilir.
- Gürültü Filtreleme: Ham veriyi işleyerek aykırı değerleri temizler.
- RANSAC Algoritması: Nokta bulutu içerisindeki en uygun doğruları (lines) iteratif olarak tespit eder.
- Segmentasyon: Tespit edilen doğruları ve bu doğrulara ait "inlier" (içeride kalan) noktaları ayırır.
- Görselleştirme Desteği:
gnuplotkullanarak sonuçları (.datdosyaları üzerinden) görselleştirir ve PNG formatında çıktı verir. - Mesafe ve Açı Analizi: Tespit edilen doğrular arasındaki açıları ve robotun (0,0) en yakın nesneye olan uzaklığını hesaplar.
Projeyi derlemek ve görselleştirmek için aşağıdaki araçlara ihtiyacınız vardır:
- GCC Compiler: C kodunu derlemek için.
- Gnuplot: Veri analizi sonuçlarını görselleştirmek için.
- Curl: URL üzerinden veri indirmek için (Genellikle Linux sistemlerde yüklü gelir).
sudo apt update
sudo apt install build-essential gnuplot curlHomebrew paket yöneticisi ile:
brew install gcc gnuplot(Curl genellikle yüklü gelir)
En iyi deneyim için WSL (Windows Subsystem for Linux) kullanılması önerilir (Linux adımlarını takip edin). Alternatif olarak:
- MinGW (GCC derleyicisi için) kurun.
- Gnuplot'u resmi sitesinden indirip kurun ve sistem yoluna (PATH) ekleyin.
- Curl Windows 10 ve üzeri sürümlerde varsayılan olarak mevcuttur.
Projeyi çalıştırmak için aşağıdaki adımları takip edin:
Matematik kütüphanesini (-lm) bağlamayı unutmayın:
gcc main.c -o lidar-ransac -lmProgramı farklı şekillerde kullanabilirsiniz:
-
Varsayılan (Dizindeki
scan.tomldosyasını arar):./lidar-ransac
-
Yerel Bir Dosya ile:
./lidar-ransac verilerim/oda_taramasi.toml
-
Bir URL ile (Dosyayı indirir ve işler):
./lidar-ransac http://ornek.com/lidar_verisi.toml
Program analiz sonuçlarını .dat dosyalarına yazacaktır.
Üretilen .dat dosyalarını kullanarak grafiği oluşturun:
gnuplot cizim.gpBu işlem sonucunda dizinde proje_ciktisi.png adında bir görsel oluşacaktır.
LidarRansac-C is a performance-oriented project written in pure C that processes Lidar sensor data to perform 2D line detection using the RANSAC (Random Sample Consensus) algorithm.
This project is designed to extract meaningful geometric shapes from noisy sensor data, serving as a foundation for robotic mapping and localization (SLAM) processes.
(Note: The image is generated via gnuplot after running the project)
- TOML Data Parsing: Reads and parses Lidar scan data from
scan.toml. - Flexible Input: Supports reading data from local files or directly from URLs.
- Noise Filtering: Processes raw data to remove outliers.
- RANSAC Algorithm: Iteratively detects the best-fitting lines within the point cloud.
- Segmentation: Separates detected lines and their corresponding "inlier" points.
- Visualization Support: Uses
gnuplotto visualize results (via.datfiles) and outputs them in PNG format. - Distance & Angle Analysis: Calculates angles between detected lines and the distance from the robot (0,0) to the nearest object.
To compile and visualize the project, you need the following tools:
- GCC Compiler: To compile the C code.
- Gnuplot: To visualize the data analysis results.
- Curl: To download data from URLs (Usually pre-installed on Linux).
sudo apt update
sudo apt install build-essential gnuplot curlUsing Homebrew package manager:
brew install gcc gnuplot(Curl comes pre-installed)
For the best experience, using WSL (Windows Subsystem for Linux) is recommended (follow Linux steps). Alternatively:
- Install MinGW (for GCC compiler).
- Download and install Gnuplot from the official website and add it to PATH.
- Curl is available by default on Windows 10/11.
Follow these steps to run the project:
Don't forget to link the math library (-lm):
gcc main.c -o lidar-ransac -lmYou can use the program in different ways:
-
Default (Looks for
scan.tomlin the current directory):./lidar-ransac
-
With a Local File:
./lidar-ransac my_data/room_scan.toml
-
With a URL (Downloads and processes the file):
./lidar-ransac http://example.com/lidar_data.toml
The program will write analysis results to .dat files.
Generate the graph using the produced .dat files:
gnuplot cizim.gpThis process will create an image named proje_ciktisi.png in the directory.
LidarRansac-C/
├── main.c # Source code (RANSAC implementation)
├── scan.toml # Default input data / Varsayılan veri
├── cizim.gp # Gnuplot visualization script
├── .gitignore # Git ignore file
└── README.md # Documentation / Dokümantasyon
This project is open-source and available for educational/development purposes.