Skip to content

Commit

Permalink
Change the type of the buffer array
Browse files Browse the repository at this point in the history
As the lidar sends distance with the type float, we have to store those
datas in an array of float.
The conversion from float to int return zeros which messed up the median
filter.

Signed-off-by: Thomas Bonnefille <[email protected]>
  • Loading branch information
Taumille committed Nov 6, 2023
1 parent db9ae73 commit a6bdd09
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cluster_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void ClusterDetector::scan_callback(const sensor_msgs::msg::LaserScan msg){
return;
}

int val_list[2*NB_MEDIAN+1];
float val_list[2*NB_MEDIAN+1];
int i,add, access_index, buffer_index;
float buffer_val;
for (i = 0; i<NB_POINT_SCAN; i++){this->points[i].cluster_id=-1;}
Expand All @@ -29,7 +29,7 @@ void ClusterDetector::scan_callback(const sensor_msgs::msg::LaserScan msg){
for (add = -NB_MEDIAN; add <= NB_MEDIAN; add++){
access_index = i + add;
if (access_index < 0){access_index+=NB_POINT_SCAN;}
if (access_index >= NB_POINT_SCAN){access_index-=NB_POINT_SCAN;}
else if (access_index >= NB_POINT_SCAN){access_index-=NB_POINT_SCAN;}
val_list[NB_MEDIAN+add] = (msg.ranges[access_index] < 10) ? msg.ranges[access_index] : 30;
}

Expand Down

0 comments on commit a6bdd09

Please sign in to comment.