17 m_threadPool(amountOfThreads), m_amountOfThreads(amountOfThreads) {
54 geometry_msgs::msg::Point* lastPoint;
56 if (laneType ==
'l') {
60 else if (laneType ==
'c') {
64 else if (laneType ==
'r') {
69 for(geometry_msgs::msg::Point& point : laneDetectionSPtr->points) {
70 if (usable ==
false) {
77 double distanceCM = sqrt((point.x - lastPoint->x)*(point.x - lastPoint->x) + (point.y - lastPoint->y)*(point.y - lastPoint->y)) * 100;
78 if (distanceCM <= 1) {
83 double distanceX = lastPoint->x - point.x;
84 double distanceY = lastPoint->y - point.y;
85 for (
double p = 0; p < 1; p += 1/distanceCM) {
86 double pointX = point.x + p * distanceX;
87 double pointY = point.y + p * distanceY;
91 Vector2i absoluteCellPositionOnGrid =
Vector2i(std::round(pointX), std::round(pointY));
95 updateCell(absoluteCellPositionOnGrid, laneType);
101 if (laneType ==
'l') {
105 else if (laneType ==
'c') {
109 else if (laneType ==
'r') {
117 if(position[0] < 0 || position[0] >=
m_mapSize[0] || position[1] < 0 || position[1] >=
m_mapSize[1]) {
118 log_warning(
"MapDataLayer::updateCell: cannot update Cell (out of bounds) at Position (", position[0],
",", position[1],
")");
125 else if (laneType ==
'c')
127 else if (laneType ==
'r')
130 log_warning(
"Failure to updateMap. Wrong lanetype parameter value (l,c,r)");
137 Eigen::Rotation2Df rotationMatrix(-absoluteOrientation);
138 Eigen::Rotation2Df reverseRotationMatrix(absoluteOrientation);
145 Vector2i absolutePositionInteger =
Vector2i(std::round(absolutePositionCM[0]), std::round(absolutePositionCM[1]));
150 marginX = rotationMatrix * marginX;
151 marginY = rotationMatrix * marginY;
153 std::array<Vector2f, 4> windowEdges;
154 windowEdges[0] = absolutePositionCM - marginX;
155 windowEdges[1] = absolutePositionCM + marginX;
156 windowEdges[2] = windowEdges[0] + marginY;
157 windowEdges[3] = windowEdges[1] + marginY;
163 if(largerWindowBottomLeftCorner[0] < 0) {
164 log_warning(
"MapDataLayer::getLineObject: lookup (axis aligned) window size out of map size (X smaller than 0)");
165 largerWindowBottomLeftCorner[1] = 0;
167 if(largerWindowTopRightCorner[0] >=
m_mapSize[0]) {
168 log_warning(
"MapDataLayer::getLineObject: lookup (axis aligned) window size out of map size (X larger than map)");
169 largerWindowTopRightCorner[0] =
m_mapSize[0] - 1;
171 if(largerWindowBottomLeftCorner[1] < 0) {
172 log_warning(
"MapDataLayer::getLineObject: lookup (axis aligned) window size out of map size (Y smaller than 0)");
173 largerWindowBottomLeftCorner[1] = 0;
175 if(largerWindowTopRightCorner[1] >=
m_mapSize[1]) {
176 log_warning(
"MapDataLayer::getLineObject: lookup (axis aligned) window size out of map size (Y larger than map)");
177 largerWindowTopRightCorner[1] =
m_mapSize[1] - 1;
200 iterateThroughMap(largerWindowBottomLeftCorner[0], largerWindowTopRightCorner[0] + 1, largerWindowBottomLeftCorner[1], largerWindowTopRightCorner[1], absolutePositionInteger);
205 effectiveWindowSize[0] = largerWindowTopRightCorner[0] - largerWindowBottomLeftCorner[0];
206 assert(effectiveWindowSize[0] >= 0);
207 effectiveWindowSize[1] = largerWindowTopRightCorner[1] - largerWindowBottomLeftCorner[1];
208 assert(effectiveWindowSize[1] >= 0);
214 MapCell const* cellPtr =
nullptr;
215 for(
int x = arrayStartX; x < arrayEndX; ++x) {
216 for(
int y = arrayStartY; y <= arrayEndY; ++y) {
221 m_linesObjectSPtr->leftLine.insert(x - absoluteCarPosition[0], y - absoluteCarPosition[1]);
224 m_linesObjectSPtr->centerLine.insert(x - absoluteCarPosition[0], y - absoluteCarPosition[1]);
227 m_linesObjectSPtr->rightLine.insert(x - absoluteCarPosition[0], y - absoluteCarPosition[1]);