Skip to content

Commit

Permalink
Adding some comment to function create_message() of class ClusterDete…
Browse files Browse the repository at this point in the history
…ctor

Signed-off-by: Thomas Bonnefille <[email protected]>
  • Loading branch information
Taumille committed Nov 2, 2023
1 parent 825409f commit db9ae73
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cluster_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void ClusterDetector::create_message(){

int i,j,size;

// Sort every point by its cluster_id
for (i = 0; i<NB_POINT_SCAN; i++){
if (this->points[i].cluster_id != -1){
(buffer_cluster.at(this->points[i].cluster_id)).push_back(this->points[i]);
Expand All @@ -132,6 +133,7 @@ void ClusterDetector::create_message(){
r = 0;
size = buffer_cluster[i].size();
theta = 0;
// Get the furthest point and consider it to be the center of the circle
for (j = 0; j<size; j++){
r = std::max(r,buffer_cluster.at(i).at(j).r);

Expand All @@ -141,6 +143,7 @@ void ClusterDetector::create_message(){
theta *= 2 * PI/(NB_POINT_SCAN * size);
radius = 2 * sin(2 * PI *static_cast<double>(size)/(2*NB_POINT_SCAN)) * r;

// Place the measured parameters in the message
cdf_msgs::msg::CircleObstacle tmp_circle;
tmp_circle.radius = radius;
tmp_circle.center.x = r*cos(theta);
Expand Down

0 comments on commit db9ae73

Please sign in to comment.