ros/src/dirt_detection/src/dirt_detector.cpp
//Getting the mid point of the maximum and minimum values for the obstacle along the y axis
Getting the mid point of the maximum and minimum values for the obstacle along the y axis
Getting the mid point of the maximum and minimum values for the obstacle along the y axis
float DirtDetector::GetDirtY(std::vector<geometry_msgs::Pose> dirtCoordinates)
{
    float min = dirtCoordinates[0].position.y;
    float max = dirtCoordinates[0].position.y;
    for (int i = 0; i < dirtCoordinates.size(); ++i)
    {
        if (dirtCoordinates[i].position.y < min)
        {
            min = dirtCoordinates[i].position.y;
        }
    }
    for (int i = 0; i < dirtCoordinates.size(); ++i)
    {
        if (dirtCoordinates[i].position.y > max)
        {
            max = dirtCoordinates[i].position.y;
        }
    }
    return (min + max) / 2;
}
float DirtDetector :: GetDirtY ( std :: vector < geometry_msgs :: Pose > dirtCoordinates ) { float min = dirtCoordinates [ 0 ] . position . y ; float max = dirtCoordinates [ 0 ] . position . y ; for ( int i = 0 ; i < dirtCoordinates . size ( ) ; ++ i ) { if ( dirtCoordinates [ i ] . position . y < min ) { min = dirtCoordinates [ i ] . position . y ; } } for ( int i = 0 ; i < dirtCoordinates . size ( ) ; ++ i ) { if ( dirtCoordinates [ i ] . position . y > max ) { max = dirtCoordinates [ i ] . position . y ; } } return ( min + max ) / 2 ; }
Getting the mid point of the maximum and minimum values for the obstacle along the y axis
Getting the mid point of the maximum and minimum values for the obstacle along the y axis