Go to the documentation of this file.
18 #ifndef OPEN_KARTO_KARTO_H
19 #define OPEN_KARTO_KARTO_H
37 #include <boost/thread.hpp>
40 #include <Poco/Mutex.h>
46 #define KARTO_Object(name) \
47 virtual const char* GetClassName() const { return #name; } \
48 virtual kt_objecttype GetObjectType() const { return ObjectType_##name; }
94 , m_ErrorCode(errorCode)
102 : m_Message(rException.m_Message)
103 , m_ErrorCode(rException.m_ErrorCode)
216 Poco::FastMutex::ScopedLock lock(m_Mutex);
230 Poco::FastMutex m_Mutex;
300 if (m_ParameterLookup.find(rName) != m_ParameterLookup.end())
302 return m_ParameterLookup[rName];
305 std::cout <<
"Unknown parameter: " << rName << std::endl;
404 std::string::size_type pos = rName.find_last_of(
'/');
405 if (pos != 0 && pos != std::string::npos)
407 throw Exception(
"Name can't contain a scope!");
481 return !(*
this == rOther);
508 void Parse(
const std::string& rName)
510 std::string::size_type pos = rName.find_last_of(
'/');
512 if (pos == std::string::npos)
518 m_Scope = rName.substr(0, pos);
519 m_Name = rName.substr(pos+1, rName.size());
543 for (
size_t i = 1; i < rName.size(); ++i)
548 throw Exception(
"Invalid character in name. Valid characters must be within the ranges A-Z, a-z, 0-9, '/', '_' and '-'.");
554 throw Exception(
"Invalid first character in name. Valid characters must be within the ranges A-Z, a-z, and '/'.");
565 return (isalpha(c) || c ==
'/');
575 return (isalnum(c) || c ==
'/' || c ==
'_' || c ==
'-');
623 virtual const char* GetClassName()
const = 0;
637 return m_pParameterManager;
647 return m_pParameterManager->Get(rName);
656 inline void SetParameter(
const std::string& rName, T value);
664 return m_pParameterManager->GetParameterVector();
774 Module(
const std::string& rName);
785 virtual void Reset() = 0;
1033 return (*
this - rOther).SquaredLength();
1183 rStream << rVector.
GetX() <<
" " << rVector.
GetY();
1213 template<
typename T>
1352 std::stringstream converter;
1353 converter.precision(std::numeric_limits<double>::digits10);
1357 return converter.str();
1631 else if (test < -0.499)
1645 rPitch = asin(2 * test);
1665 angle = pitch * 0.5;
1673 m_Values[0] = sYaw * sPitch * cRoll + cYaw * cPitch * sRoll;
1674 m_Values[1] = sYaw * cPitch * cRoll + cYaw * sPitch * sRoll;
1675 m_Values[2] = cYaw * sPitch * cRoll - sYaw * cPitch * sRoll;
1676 m_Values[3] = cYaw * cPitch * cRoll - sYaw * sPitch * sRoll;
1724 rStream << rQuaternion.
m_Values[0] <<
" "
1743 template<
typename T>
1830 return m_Size.GetWidth();
1848 return m_Size.GetHeight();
1857 m_Size.SetHeight(height);
2278 std::stringstream converter;
2279 converter.precision(std::numeric_limits<double>::digits10);
2283 return converter.str();
2399 kt_double oneMinusCos = 1.0 - cosRadians;
2413 m_Matrix[0][0] = xx * oneMinusCos + cosRadians;
2418 m_Matrix[1][1] = yy * oneMinusCos + cosRadians;
2423 m_Matrix[2][2] = zz * oneMinusCos + cosRadians;
2452 if (haveInverse ==
false)
2481 if (fabs(fDet) <= fTolerance)
2487 for (
size_t row = 0; row < 3; row++)
2489 for (
size_t col = 0; col < 3; col++)
2491 rkInverse.
m_Matrix[row][col] *= fInvDet;
2504 std::stringstream converter;
2505 converter.precision(std::numeric_limits<double>::digits10);
2507 for (
int row = 0; row < 3; row++)
2509 for (
int col = 0; col < 3; col++)
2511 converter <<
m_Matrix[row][col] <<
" ";
2515 return converter.str();
2559 for (
size_t row = 0; row < 3; row++)
2561 for (
size_t col = 0; col < 3; col++)
2723 catch (
const std::bad_alloc& ex)
2725 throw Exception(
"Matrix allocation error");
2730 throw Exception(
"Matrix allocation error");
2743 throw Exception(
"Matrix - RangeCheck ERROR!!!!");
2748 throw Exception(
"Matrix - RangeCheck ERROR!!!!");
2773 :
m_Minimum(999999999999999999.99999, 999999999999999999.99999)
2774 ,
m_Maximum(-999999999999999999.99999, -999999999999999999.99999)
2920 if (rPose1 == rPose2)
2934 if (rPose1.
GetX() != 0.0 || rPose1.
GetY() != 0.0)
2940 newPosition = rPose2;
2992 if (pParameterManger != NULL)
2994 pParameterManger->Add(
this);
3005 const std::string& rDescription,
3011 if (pParameterManger != NULL)
3013 pParameterManger->Add(
this);
3069 rStream.precision(6);
3070 rStream.flags(std::ios::fixed);
3088 template<
typename T>
3112 const std::string& rDescription,
3152 std::stringstream converter;
3154 return converter.str();
3163 std::stringstream converter;
3164 converter.str(rStringValue);
3208 int precision = std::numeric_limits<double>::digits10;
3209 std::stringstream converter;
3210 converter.precision(precision);
3212 converter.str(rStringValue);
3215 converter >> m_Value;
3221 std::stringstream converter;
3222 converter.precision(std::numeric_limits<double>::digits10);
3223 converter << m_Value;
3224 return converter.str();
3230 if (rStringValue ==
"true" || rStringValue ==
"TRUE")
3243 if (m_Value ==
true)
3301 if (m_EnumDefines.find(rStringValue) != m_EnumDefines.end())
3303 m_Value = m_EnumDefines[rStringValue];
3307 std::string validValues;
3311 validValues += iter->first +
", ";
3314 throw Exception(
"Unable to set enum: " + rStringValue +
". Valid values are: " + validValues);
3326 if (iter->second == m_Value)
3332 throw Exception(
"Unable to lookup enum");
3342 if (m_EnumDefines.find(rName) == m_EnumDefines.end())
3344 m_EnumDefines[rName] = value;
3348 std::cerr <<
"Overriding enum value: " << m_EnumDefines[rName] <<
" with " << value << std::endl;
3350 m_EnumDefines[rName] = value;
3453 return m_pOffsetPose->GetValue();
3462 m_pOffsetPose->SetValue(rPose);
3469 virtual kt_bool Validate() = 0;
3548 if ((m_Sensors.find(pSensor->
GetName()) != m_Sensors.end()) && !
override)
3550 throw Exception(
"Cannot register sensor: already registered: [" +
3552 "] (Consider setting 'override' to true)");
3555 std::cout <<
"Registering sensor: [" << pSensor->
GetName().
ToString() <<
"]" << std::endl;
3557 m_Sensors[pSensor->
GetName()] = pSensor;
3568 if (m_Sensors.find(pSensor->
GetName()) != m_Sensors.end())
3570 std::cout <<
"Unregistering sensor: " << pSensor->
GetName().
ToString() << std::endl;
3572 m_Sensors.erase(pSensor->
GetName());
3587 if (m_Sensors.find(rName) != m_Sensors.end())
3589 return m_Sensors[rName];
3592 throw Exception(
"Sensor not registered: [" + rName.
ToString() +
"] (Did you add the sensor to the Dataset?)");
3603 Sensor* pSensor = GetSensorByName(rName);
3605 return dynamic_cast<T*
>(pSensor);
3618 sensors.push_back(iter->second);
3631 if (pSensor == NULL)
3633 throw Exception(
"Invalid sensor: NULL");
3637 throw Exception(
"Invalid sensor: nameless");
3689 if (pSensorData == NULL)
3706 class LocalizedRangeScan;
3707 class CoordinateConverter;
3743 return m_pMinimumRange->GetValue();
3752 m_pMinimumRange->SetValue(minimumRange);
3754 SetRangeThreshold(GetRangeThreshold());
3763 return m_pMaximumRange->GetValue();
3772 m_pMaximumRange->SetValue(maximumRange);
3774 SetRangeThreshold(GetRangeThreshold());
3783 return m_pRangeThreshold->GetValue();
3793 m_pRangeThreshold->SetValue(
math::Clip(rangeThreshold, GetMinimumRange(), GetMaximumRange()));
3797 std::cout <<
"Info: clipped range threshold to be within minimum and maximum range!" << std::endl;
3807 return m_pMinimumAngle->GetValue();
3816 m_pMinimumAngle->SetValue(minimumAngle);
3827 return m_pMaximumAngle->GetValue();
3836 m_pMaximumAngle->SetValue(maximumAngle);
3847 return m_pAngularResolution->GetValue();
3858 m_pAngularResolution->SetValue(angularResolution);
3872 std::stringstream stream;
3873 stream <<
"Invalid resolution for Sick LMS100: ";
3874 stream << angularResolution;
3895 std::stringstream stream;
3896 stream <<
"Invalid resolution for Sick LMS291: ";
3897 stream << angularResolution;
3909 std::stringstream stream;
3910 stream <<
"Invalid resolution for Hokuyo_UTM_30LX: ";
3911 stream << angularResolution;
3923 std::stringstream stream;
3924 stream <<
"Invalid resolution for Hokuyo_URG_04LX: ";
3925 stream << angularResolution;
3931 throw Exception(
"Can't set angular resolution, please create a LaserRangeFinder of type Custom");
3942 return m_pType->GetValue();
3951 return m_NumberOfRangeReadings;
3958 if (
math::InRange(GetRangeThreshold(), GetMinimumRange(), GetMaximumRange()) ==
false)
3960 std::cout <<
"Please set range threshold to a value between ["
3961 << GetMinimumRange() <<
";" << GetMaximumRange() <<
"]" << std::endl;
3979 kt_bool ignoreThresholdPoints =
true,
4125 Pose2 defaultOffset;
4138 , m_NumberOfRangeReadings(0)
4169 / GetAngularResolution()) + 1);
4237 return value * m_Scale;
4248 kt_double gridX = (rWorld.
GetX() - m_Offset.GetX()) * m_Scale;
4253 gridY = (rWorld.
GetY() - m_Offset.GetY()) * m_Scale;
4257 gridY = (m_Size.GetHeight() / m_Scale - rWorld.
GetY() + m_Offset.GetY()) * m_Scale;
4276 worldY = m_Offset.GetY() + rGrid.
GetY() / m_Scale;
4280 worldY = m_Offset.GetY() + (m_Size.GetHeight() - rGrid.
GetY()) / m_Scale;
4346 return 1.0 / m_Scale;
4355 m_Scale = 1.0 / resolution;
4368 kt_double maxX = minX + GetSize().GetWidth() * GetResolution();
4369 kt_double maxY = minY + GetSize().GetHeight() * GetResolution();
4390 template<
typename T>
4403 Grid* pGrid =
new Grid(width, height);
4416 delete m_pCoordinateConverter;
4425 memset(m_pData, 0, GetDataSize() *
sizeof(T));
4434 Grid* pGrid = CreateGrid(GetWidth(), GetHeight(), GetResolution());
4437 memcpy(pGrid->
GetDataPointer(), GetDataPointer(), GetDataSize());
4451 m_WidthStep = math::AlignValue<kt_int32s>(width, 8);
4453 if (m_pData != NULL)
4461 m_pData =
new T[GetDataSize()];
4463 if (m_pCoordinateConverter == NULL)
4499 if (boundaryCheck ==
true)
4501 if (IsValidGridIndex(rGrid) ==
false)
4503 std::stringstream error;
4504 error <<
"Index " << rGrid <<
" out of range. Index must be between [0; "
4505 << m_Width <<
") and [0; " << m_Height <<
")";
4512 if (boundaryCheck ==
true)
4529 grid.
SetY(index / m_WidthStep);
4530 grid.
SetX(index - grid.
GetY() * m_WidthStep);
4543 return GetCoordinateConverter()->WorldToGrid(rWorld, flipY);
4554 return GetCoordinateConverter()->GridToWorld(rGrid, flipY);
4564 kt_int32s index = GridIndex(rGrid,
true);
4565 return m_pData + index;
4575 kt_int32s index = GridIndex(rGrid,
true);
4576 return m_pData + index;
4639 return m_WidthStep * m_Height;
4650 return m_pData[index];
4659 return m_pCoordinateConverter;
4668 return GetCoordinateConverter()->GetResolution();
4677 return GetCoordinateConverter()->GetBoundingBox();
4691 kt_bool steep = abs(y1 - y0) > abs(x1 - x0);
4735 if (2 * error >= deltaX)
4742 if (IsValidGridIndex(gridIndex))
4744 kt_int32s index = GridIndex(gridIndex,
false);
4745 T* pGridPointer = GetDataPointer();
4746 pGridPointer[index]++;
4764 , m_pCoordinateConverter(NULL)
4766 Resize(width, height);
4814 virtual const std::string Write()
const = 0;
4820 virtual void Read(
const std::string& rValue) = 0;
4868 m_StateId = stateId;
4886 m_UniqueId = uniqueId;
4913 return m_SensorName;
4922 m_CustomData.push_back(pCustomData);
4931 return m_CustomData;
5001 , m_pRangeReadings(NULL)
5002 , m_NumberOfRangeReadings(0)
5013 , m_pRangeReadings(NULL)
5014 , m_NumberOfRangeReadings(0)
5016 assert(rSensorName.
ToString() !=
"");
5018 SetRangeReadings(rRangeReadings);
5026 delete [] m_pRangeReadings;
5036 return m_pRangeReadings;
5059 if (!rRangeReadings.empty())
5061 if (rRangeReadings.size() != m_NumberOfRangeReadings)
5064 delete [] m_pRangeReadings;
5067 m_NumberOfRangeReadings =
static_cast<kt_int32u>(rRangeReadings.size());
5070 m_pRangeReadings =
new kt_double[m_NumberOfRangeReadings];
5077 m_pRangeReadings[index++] = *iter;
5082 delete [] m_pRangeReadings;
5083 m_pRangeReadings = NULL;
5093 return SensorManager::GetInstance()->GetSensorByName<
LaserRangeFinder>(GetSensorName());
5102 return m_NumberOfRangeReadings;
5152 return m_OdometricPose;
5161 m_OdometricPose = rPose;
5219 return m_OdometricPose;
5228 m_OdometricPose = rPose;
5241 return m_CorrectedPose;
5250 m_CorrectedPose = rPose;
5260 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5265 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5269 return m_BarycenterPose;
5279 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5284 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5288 return useBarycenter ? GetBarycenterPose() : GetSensorPose();
5297 return GetSensorAt(m_CorrectedPose);
5306 Pose2 deviceOffsetPose2 = GetLaserRangeFinder()->GetOffsetPose();
5309 kt_double angleoffset = atan2(deviceOffsetPose2.
GetY(), deviceOffsetPose2.
GetX());
5311 Pose2 worldSensorOffset =
Pose2(offsetLength * cos(correctedHeading + angleoffset - offsetHeading),
5312 offsetLength * sin(correctedHeading + angleoffset - offsetHeading),
5315 m_CorrectedPose = rScanPose - worldSensorOffset;
5336 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5341 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5345 return m_BoundingBox;
5353 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5358 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5362 if (wantFiltered ==
true)
5364 return m_PointReadings;
5368 return m_UnfilteredPointReadings;
5381 if (pLaserRangeFinder != NULL)
5383 m_PointReadings.clear();
5384 m_UnfilteredPointReadings.clear();
5389 Pose2 scanPose = GetSensorPose();
5396 kt_double rangeReading = GetRangeReadings()[i];
5402 point.
SetX(scanPose.
GetX() + (rangeReading * cos(angle)));
5403 point.
SetY(scanPose.
GetY() + (rangeReading * sin(angle)));
5405 m_UnfilteredPointReadings.push_back(point);
5412 point.
SetX(scanPose.
GetX() + (rangeReading * cos(angle)));
5413 point.
SetY(scanPose.
GetY() + (rangeReading * sin(angle)));
5415 m_PointReadings.push_back(point);
5416 m_UnfilteredPointReadings.push_back(point);
5418 rangePointsSum += point;
5426 m_BarycenterPose =
Pose2(averagePosition, 0.0);
5430 m_BarycenterPose = scanPose;
5438 m_BoundingBox.Add(*iter);
5531 m_PointReadings.clear();
5532 m_UnfilteredPointReadings.clear();
5534 Pose2 scanPose = GetSensorPose();
5535 Pose2 robotPose = GetCorrectedPose();
5539 for (
kt_int32u i = 0; i < m_Points.size(); i++)
5542 if (!std::isfinite(m_Points[i].GetX()) || !std::isfinite(m_Points[i].GetY()))
5545 m_UnfilteredPointReadings.push_back(point);
5551 Pose2 pointPose(m_Points[i].GetX(), m_Points[i].GetY(), 0);
5555 m_PointReadings.push_back(point);
5556 m_UnfilteredPointReadings.push_back(point);
5558 rangePointsSum += point;
5566 m_BarycenterPose =
Pose2(averagePosition, 0.0);
5570 m_BarycenterPose = scanPose;
5578 m_BoundingBox.Add(*iter);
5602 : m_pOccupancyGrid(pGrid)
5627 friend class IncrementalOccupancyGrid;
5639 , m_pCellPassCnt(
Grid<
kt_int32u>::CreateGrid(0, 0, resolution))
5640 , m_pCellHitsCnt(
Grid<
kt_int32u>::CreateGrid(0, 0, resolution))
5641 , m_pCellUpdater(NULL)
5647 throw Exception(
"Resolution cannot be 0");
5653 GetCoordinateConverter()->SetScale(1.0 / resolution);
5654 GetCoordinateConverter()->SetOffset(rOffset);
5662 delete m_pCellUpdater;
5664 delete m_pCellPassCnt;
5665 delete m_pCellHitsCnt;
5667 delete m_pMinPassThrough;
5668 delete m_pOccupancyThreshold;
5686 ComputeDimensions(rScans, resolution, width, height, offset);
5690 return pOccupancyGrid;
5701 GetCoordinateConverter()->GetOffset(),
5702 1.0 / GetCoordinateConverter()->GetScale());
5703 memcpy(pOccupancyGrid->
GetDataPointer(), GetDataPointer(), GetDataSize());
5709 return pOccupancyGrid;
5737 double scale = GetCoordinateConverter()->GetScale();
5746 kt_double xStop = x + maxRange * cosTheta;
5747 kt_double xSteps = 1 + fabs(xStop - x) * scale;
5749 kt_double yStop = y + maxRange * sinTheta;
5750 kt_double ySteps = 1 + fabs(yStop - y) * scale;
5762 if (IsValidGridIndex(gridIndex) && IsFree(gridIndex))
5764 distance = (i + 1) * delta;
5772 return (distance < maxRange)? distance : maxRange;
5782 m_pMinPassThrough->SetValue(count);
5791 m_pOccupancyThreshold->SetValue(thresh);
5801 return m_pCellHitsCnt;
5810 return m_pCellPassCnt;
5831 boundingBox.
Add((*iter)->GetBoundingBox());
5848 m_pCellPassCnt->Resize(GetWidth(), GetHeight());
5849 m_pCellPassCnt->GetCoordinateConverter()->SetOffset(GetCoordinateConverter()->GetOffset());
5851 m_pCellHitsCnt->Resize(GetWidth(), GetHeight());
5852 m_pCellHitsCnt->GetCoordinateConverter()->SetOffset(GetCoordinateConverter()->GetOffset());
5891 if (rangeReading <= minRange || rangeReading >= maxRange || std::isnan(rangeReading))
5897 else if (rangeReading >= rangeThreshold)
5900 kt_double ratio = rangeThreshold / rangeReading;
5903 point.
SetX(scanPosition.
GetX() + ratio * dx);
5904 point.
SetY(scanPosition.
GetY() + ratio * dy);
5907 kt_bool isInMap = RayTrace(scanPosition, point, isEndPointValid, doUpdate);
5933 assert(m_pCellPassCnt != NULL && m_pCellHitsCnt != NULL);
5938 CellUpdater* pCellUpdater = doUpdate ? m_pCellUpdater : NULL;
5939 m_pCellPassCnt->TraceLine(gridFrom.
GetX(), gridFrom.
GetY(), gridTo.
GetX(), gridTo.
GetY(), pCellUpdater);
5942 if (isEndPointValid)
5944 if (m_pCellPassCnt->IsValidGridIndex(gridTo))
5946 kt_int32s index = m_pCellPassCnt->GridIndex(gridTo,
false);
5948 kt_int32u* pCellPassCntPtr = m_pCellPassCnt->GetDataPointer();
5949 kt_int32u* pCellHitCntPtr = m_pCellHitsCnt->GetDataPointer();
5952 pCellPassCntPtr[index]++;
5953 pCellHitCntPtr[index]++;
5957 (*m_pCellUpdater)(index);
5962 return m_pCellPassCnt->IsValidGridIndex(gridTo);
5973 if (cellPassCnt > m_pMinPassThrough->GetValue())
5977 if (hitRatio > m_pOccupancyThreshold->GetValue())
5993 assert(m_pCellPassCnt != NULL && m_pCellHitsCnt != NULL);
5999 kt_int8u* pDataPtr = GetDataPointer();
6000 kt_int32u* pCellPassCntPtr = m_pCellPassCnt->GetDataPointer();
6001 kt_int32u* pCellHitCntPtr = m_pCellHitsCnt->GetDataPointer();
6004 for (
kt_int32u i = 0; i < nBytes; i++, pDataPtr++, pCellPassCntPtr++, pCellHitCntPtr++)
6006 UpdateCell(pDataPtr, *pCellPassCntPtr, *pCellHitCntPtr);
6018 m_pCellPassCnt->Resize(width, height);
6019 m_pCellHitsCnt->Resize(width, height);
6094 return m_pTitle->GetValue();
6102 return m_pAuthor->GetValue();
6110 return m_pDescription->GetValue();
6118 return m_pCopyright->GetValue();
6147 : m_pDatasetInfo(NULL)
6166 if (pObject != NULL)
6168 if (
dynamic_cast<Sensor*
>(pObject))
6171 if (pSensor != NULL)
6173 m_SensorNameLookup[pSensor->
GetName()] = pSensor;
6178 m_Objects.push_back(pObject);
6183 m_Objects.push_back(pSensorData);
6187 m_pDatasetInfo =
dynamic_cast<DatasetInfo*
>(pObject);
6191 m_Objects.push_back(pObject);
6211 return m_pDatasetInfo;
6219 for (std::map<Name, Sensor*>::iterator iter = m_SensorNameLookup.begin(); iter != m_SensorNameLookup.end(); ++iter)
6231 if (m_pDatasetInfo != NULL)
6233 delete m_pDatasetInfo;
6234 m_pDatasetInfo = NULL;
6270 assert(m_pArray != NULL);
6282 memset(m_pArray, 0,
sizeof(
kt_int32s) * m_Capacity);
6302 if (size > m_Capacity)
6304 if (m_pArray != NULL)
6322 assert(index < m_Size);
6324 return m_pArray[index];
6334 assert(index < m_Size);
6336 return m_pArray[index];
6380 template<
typename T>
6392 , m_ppLookupArray(NULL)
6414 return m_ppLookupArray[index];
6438 assert(angleOffset != 0.0);
6439 assert(angleResolution != 0.0);
6457 localPoints.push_back(vec);
6463 kt_double startAngle = angleCenter - angleOffset;
6464 for (
kt_int32u angleIndex = 0; angleIndex < nAngles; angleIndex++)
6466 angle = startAngle + angleIndex * angleResolution;
6467 ComputeOffsets(angleIndex, angle, localPoints, pScan);
6481 m_ppLookupArray[angleIndex]->SetSize(
static_cast<kt_int32u>(rLocalPoints.size()));
6482 m_Angles.at(angleIndex) = angle;
6487 const Vector2<kt_double>& rGridOffset = m_pGrid->GetCoordinateConverter()->GetOffset();
6494 kt_int32s* pAngleIndexPointer = m_ppLookupArray[angleIndex]->GetArrayPointer();
6512 offset.
SetX(cosine * rPosition.
GetX() - sine * rPosition.
GetY());
6513 offset.
SetY(sine * rPosition.
GetX() + cosine * rPosition.
GetY());
6519 kt_int32s lookupIndex = m_pGrid->Grid<T>::GridIndex(gridPoint,
false);
6521 pAngleIndexPointer[readingIndex] = lookupIndex;
6525 assert(readingIndex == rLocalPoints.size());
6536 if (size > m_Capacity)
6538 if (m_ppLookupArray != NULL)
6545 for (
kt_int32u i = 0; i < m_Capacity; i++)
6553 m_Angles.resize(size);
6561 for (
kt_int32u i = 0; i < m_Capacity; i++)
6563 delete m_ppLookupArray[i];
6566 delete[] m_ppLookupArray;
6567 m_ppLookupArray = NULL;
6587 : m_Position(rPose.GetPosition().GetX(), rPose.GetPosition().GetY())
6601 template<
typename T>
6605 if (pParameter != NULL)
6607 std::stringstream stream;
6613 throw Exception(
"Parameter does not exist: " + rName);
6621 if (pParameter != NULL)
6623 pParameter->SetValueFromString(value ?
"true" :
"false");
6627 throw Exception(
"Parameter does not exist: " + rName);
6636 #endif // OPEN_KARTO_KARTO_H
virtual kt_double RayCast(const Pose2 &rPose2, kt_double maxRange) const
Exception(const Exception &rException)
#define const_forEach(listtype, list)
kt_double Round(kt_double value)
friend std::ostream & operator<<(std::ostream &rStream, const Name &rName)
void operator+=(const Vector2 &rOther)
friend std::istream & operator>>(std::istream &rStream, const Vector2 &)
Size2< kt_int32s > m_Size
kt_double SquaredDistance(const Pose2 &rOther) const
kt_double GetMinimumRange() const
Parameter< kt_double > * m_pMaximumRange
const kt_double KT_TOLERANCE
Quaternion & operator=(const Quaternion &rQuaternion)
kt_bool operator!=(const Vector2 &rOther) const
void SetName(const std::string &rName)
const BoundingBox2 & GetBoundingBox() const
void RegisterSensor(Sensor *pSensor, kt_bool override=false)
kt_bool operator!=(const Size2 &rOther) const
const Vector2 operator-(const Vector2 &rOther) const
virtual void SetValueFromString(const std::string &rStringValue)
Pose2(kt_double x, kt_double y, kt_double heading)
virtual Parameter< kt_int32s > * Clone()
Parameter< kt_double > * m_pOccupancyThreshold
void ComputeOffsets(LocalizedRangeScan *pScan, kt_double angleCenter, kt_double angleOffset, kt_double angleResolution)
void SetMinimum(const Vector2< kt_double > &mMinimum)
std::vector< Pose2 > Pose2Vector
Pose2(const Vector2< kt_double > &rPosition, kt_double heading)
LaserRangeFinder * GetLaserRangeFinder() const
kt_double Distance(const Vector2 &rOther) const
void SetAngularResolution(kt_double angularResolution)
const Name & GetName() const
kt_bool operator==(const Vector3 &rOther) const
const kt_objecttype ObjectType_None
kt_int32s GetWidthStep() const
Rectangle2(const Rectangle2 &rOther)
Vector2< kt_int32s > WorldToGrid(const Vector2< kt_double > &rWorld, kt_bool flipY=false) const
const Pose2 & GetOdometricPose() const
Pose2 GetReferencePose(kt_bool useBarycenter) const
void SetSize(const Size2< kt_int32s > &rSize)
const PointVectorDouble m_Points
const Vector2< kt_double > & GetPosition() const
Sensor * GetSensorByName(const Name &rName)
Pose2 GetSensorPose() const
const ObjectVector & GetObjects() const
void SetPosition(const Vector2< kt_double > &rPosition)
virtual kt_bool AddScan(LocalizedRangeScan *pScan, kt_bool doUpdate=false)
void SetRangeReadings(const RangeReadingsVector &rRangeReadings)
virtual Grid< kt_int32u > * GetCellPassCounts()
kt_bool IsParameters(Object *pObject)
AbstractParameter(const std::string &rName, ParameterManager *pParameterManger=NULL)
const ParameterVector & GetParameters() const
void SetValue(const T &rValue)
virtual ~LaserRangeFinder()
kt_bool InverseFast(Matrix3 &rkInverse, kt_double fTolerance=KT_TOLERANCE) const
virtual AbstractParameter * Clone()=0
const ParameterVector & GetParameterVector() const
BoundingBox2 m_BoundingBox
kt_bool IsLocalizedRangeScanWithPoints(Object *pObject)
CellUpdater(OccupancyGrid *pGrid)
virtual Grid< kt_int32u > * GetCellHitsCounts()
friend std::ostream & operator<<(std::ostream &rStream, const Matrix3 &rMatrix)
friend std::ostream & operator<<(std::ostream &rStream, const Pose3 &rPose)
void FromEulerAngles(kt_double yaw, kt_double pitch, kt_double roll)
kt_bool IsLocalizedRangeScan(Object *pObject)
const std::string & GetErrorMessage() const
kt_double DegreesToRadians(kt_double degrees)
const std::string & GetTitle() const
kt_int32u m_NumberOfRangeReadings
void Add(const BoundingBox2 &rBoundingBox)
std::string ToString() const
virtual kt_objecttype GetObjectType() const =0
PointVectorDouble m_UnfilteredPointReadings
kt_bool IsValidFirst(char c)
Vector2< kt_double > m_Offset
virtual ~AbstractParameter()
std::map< Name, Sensor * > m_SensorNameLookup
const Vector3 operator-(const Vector3 &rOther) const
kt_double GetResolution() const
boost::shared_mutex m_Lock
Pose3(const Pose2 &rPose)
kt_int32u GetColumns() const
Pose2 operator-(const Pose2 &rOther) const
virtual kt_bool IsFree(const Vector2< kt_int32s > &rPose) const
LaserRangeScan(const Name &rSensorName)
void MakeFloor(const Vector3 &rOther)
OccupancyGrid(kt_int32s width, kt_int32s height, const Vector2< kt_double > &rOffset, kt_double resolution)
kt_double GetRangeThreshold() const
const Pose2 & GetBarycenterPose() const
T * GetSensorByName(const Name &rName)
void SetOdometricPose(const Pose2 &rPose)
kt_double GetMaximumAngle() const
Matrix3 Transpose() const
void SetScale(kt_double scale)
friend std::ostream & operator<<(std::ostream &rStream, const Pose2 &rPose)
kt_bool operator!=(const Pose2 &rOther) const
const kt_objecttype ObjectType_Camera
const Vector2 operator+(const Vector2 &rOther) const
const kt_objecttype ObjectType_SensorData
virtual void Resize(kt_int32s width, kt_int32s height)
Matrix(kt_int32u rows, kt_int32u columns)
const kt_objecttype ObjectType_Module
void MakeCeil(const Vector2 &rOther)
const CustomDataVector & GetCustomData() const
kt_double & operator()(kt_int32u row, kt_int32u column)
Parameter(const std::string &rName, const std::string &rDescription, T value, ParameterManager *pParameterManger=NULL)
std::string ToString() const
void SetOrientation(const Quaternion &rOrientation)
kt_int32s * GetArrayPointer()
AbstractParameter * Get(const std::string &rName)
Quaternion(const Quaternion &rQuaternion)
void FromAxisAngle(kt_double x, kt_double y, kt_double z, const kt_double radians)
void ToEulerAngles(kt_double &rYaw, kt_double &rPitch, kt_double &rRoll) const
@ LaserRangeFinder_Hokuyo_URG_04LX
Parameter(const std::string &rName, T value, ParameterManager *pParameterManger=NULL)
virtual const std::string GetValueAsString() const =0
friend std::ostream & operator<<(std::ostream &rStream, const Quaternion &rQuaternion)
const kt_objecttype ObjectType_LocalizedRangeScanWithPoints
const PointVectorDouble & GetPointReadings(kt_bool wantFiltered=false) const
kt_double operator()(kt_int32u row, kt_int32u column) const
@ LaserRangeFinder_Sick_LMS200
virtual kt_bool RayTrace(const Vector2< kt_double > &rWorldFrom, const Vector2< kt_double > &rWorldTo, kt_bool isEndPointValid, kt_bool doUpdate=false)
void TraceLine(kt_int32s x0, kt_int32s y0, kt_int32s x1, kt_int32s y1, Functor *f=NULL)
ParameterVector m_Parameters
#define KARTO_Object(name)
const kt_objecttype ObjectType_Drive
T * GetDataPointer(const Vector2< kt_int32s > &rGrid) const
Grid(kt_int32s width, kt_int32s height)
Parameter< std::string > * m_pCopyright
BoundingBox2 GetBoundingBox() const
const Vector2< T > GetCenter() const
virtual kt_int32s GridIndex(const Vector2< kt_int32s > &rGrid, kt_bool boundaryCheck=true) const
LocalizedRangeScanWithPoints(const Name &rSensorName, const RangeReadingsVector &rReadings, const PointVectorDouble &rPoints)
const T & Maximum(const T &value1, const T &value2)
void SetSensorPose(const Pose2 &rScanPose)
kt_double SquaredLength() const
std::vector< Sensor * > SensorVector
const Vector2< T > & GetPosition() const
const std::string & GetName() const
void Parse(const std::string &rName)
Parameter< std::string > * m_pDescription
const Object & operator=(const Object &)
kt_double Transform(kt_double value)
kt_double & operator()(kt_int32u row, kt_int32u column)
void SetUniqueId(kt_int32u uniqueId)
virtual const std::string GetValueAsString() const
kt_bool operator==(const Size2 &rOther) const
void SetResolution(kt_double resolution)
Grid< kt_int32u > * m_pCellHitsCnt
virtual void CreateFromScans(const LocalizedRangeScanVector &rScans)
void SetSize(kt_int32u size)
void RangeCheck(kt_int32u row, kt_int32u column) const
kt_bool operator!=(const Name &rOther) const
virtual ~LocalizedRangeScanWithPoints()
const kt_objecttype ObjectType_Misc
kt_bool IsLaserRangeFinder(Object *pObject)
void operator+=(const Matrix3 &rkMatrix)
Parameter< Pose2 > * m_pOffsetPose
Parameter< kt_int32u > * m_pMinPassThrough
void SetSize(kt_int32u size)
const Vector2 operator/(T scalar) const
Pose2 GetSensorAt(const Pose2 &rPose) const
const std::string & GetCopyright() const
const T & Clip(const T &n, const T &minValue, const T &maxValue)
@ LaserRangeFinder_Sick_LMS100
Vector3< kt_double > m_Position
const kt_objecttype ObjectType_LaserRangeFinder
Parameter< kt_double > * m_pMaximumAngle
virtual void operator()(kt_int32u)
Pose2(const Pose2 &rOther)
const kt_objecttype ObjectType_Parameters
CoordinateConverter * GetCoordinateConverter() const
static Grid * CreateGrid(kt_int32s width, kt_int32s height, kt_double resolution)
static void ComputeDimensions(const LocalizedRangeScanVector &rScans, kt_double resolution, kt_int32s &rWidth, kt_int32s &rHeight, Vector2< kt_double > &rOffset)
Matrix3 & operator=(const Matrix3 &rOther)
void SetMinimumRange(kt_double minimumRange)
const Singleton & operator=(const Singleton &)
Vector2< kt_double > m_Position
static OccupancyGrid * CreateFromScans(const LocalizedRangeScanVector &rScans, kt_double resolution)
Pose3(const Pose3 &rOther)
void SetOccupancyThreshold(kt_double thresh)
Pose2 & operator=(const Pose2 &rOther)
const kt_double & operator()(kt_int32u row, kt_int32u column) const
virtual void UpdateCell(kt_int8u *pCell, kt_int32u cellPassCnt, kt_int32u cellHitCnt)
kt_double GetScale() const
kt_double NormalizeAngle(kt_double angle)
kt_int32s GetStateId() const
void SetOffsetPose(const Pose2 &rPose)
Size2(const Size2 &rOther)
kt_bool operator==(const Pose2 &rOther) const
kt_bool operator==(const Quaternion &rOther) const
kt_double GetMinimumAngle() const
static SensorManager * GetInstance()
T * GetDataPointer(const Vector2< kt_int32s > &rGrid)
const T GetHeight() const
const Size2< kt_int32s > GetSize() const
@ LaserRangeFinder_Sick_LMS291
const kt_objecttype ObjectType_Sensor
std::vector< LocalizedRangeScan * > LocalizedRangeScanVector
Exception(const std::string &rMessage="Karto Exception", kt_int32s errorCode=0)
kt_int32u m_NumberOfRangeReadings
AbstractParameter(const std::string &rName, const std::string &rDescription, ParameterManager *pParameterManger=NULL)
CustomDataVector m_CustomData
virtual const std::string GetValueAsString() const
kt_double GetResolution() const
Size2< kt_double > GetSize() const
void SetPosition(const Vector3< kt_double > &rPosition)
std::map< Name, Sensor * > SensorManagerMap
kt_bool operator!=(const Rectangle2 &rOther) const
void SetRangeThreshold(kt_double rangeThreshold)
Vector3 & operator=(const Vector3 &rOther)
const Vector3 operator+(const Vector3 &rOther) const
kt_bool operator==(const Vector2 &rOther) const
void Add(const Vector2< kt_double > &rPoint)
DatasetInfo * GetDatasetInfo()
void SetStateId(kt_int32s stateId)
const Pose2 & GetOffsetPose() const
virtual kt_bool Validate()=0
kt_int32u GetNumberOfRangeReadings() const
void operator*=(T scalar)
void SetMaximumRange(kt_double maximumRange)
#define const_forEachAs(listtype, list, iter)
virtual void Resize(kt_int32s width, kt_int32s height)
void SetCorrectedPose(const Pose2 &rPose)
const LookupArray * GetLookupArray(kt_int32u index) const
kt_int32s GetWidth() const
void SetParameter(const std::string &rName, T value)
Parameter< kt_double > * m_pMinimumRange
const kt_objecttype ObjectType_LocalizedRangeScan
std::string m_Description
kt_bool IsValidGridIndex(const Vector2< kt_int32s > &rGrid) const
const Pose2 & GetCorrectedPose() const
friend std::istream & operator>>(std::istream &rStream, const Vector3 &)
const Sensor & operator=(const Sensor &)
kt_bool operator!=(const Vector3 &rOther) const
LaserRangeScan(const Name &rSensorName, const RangeReadingsVector &rRangeReadings)
std::vector< CustomData * > CustomDataVector
kt_bool operator==(const Pose3 &rOther) const
Vector2< kt_double > GridToWorld(const Vector2< kt_int32s > &rGrid, kt_bool flipY=false) const
@ LaserRangeFinder_Hokuyo_UTM_30LX
Name(const std::string &rName)
Parameter & operator=(const Parameter &rOther)
GridIndexLookup(Grid< T > *pGrid)
void Validate(const std::string &rName)
void SetMaximum(const Vector2< kt_double > &rMaximum)
void operator-=(const Vector2 &rOther)
const kt_objecttype ObjectType_DrivePose
const kt_objecttype ObjectType_CustomData
Parameter< kt_double > * m_pMinimumAngle
kt_double GetMaximumRange() const
const Size2< kt_int32s > & GetSize() const
virtual kt_bool Validate(SensorData *pSensorData)
virtual void SetValueFromString(const std::string &rStringValue)
void SetOffset(const Vector2< kt_double > &rOffset)
friend std::ostream & operator<<(std::ostream &rStream, const AbstractParameter &rParameter)
Matrix3(const Matrix3 &rOther)
Pose3(const Vector3< kt_double > &rPosition)
kt_bool operator!=(const Pose3 &rOther) const
kt_double * m_pRangeReadings
kt_double * GetRangeReadings() const
static void Validate(Sensor *pSensor)
kt_bool InRange(const T &value, const T &a, const T &b)
OccupancyGrid * m_pOccupancyGrid
std::vector< Vector2< kt_double > > PointVectorDouble
const std::string & GetScope() const
Vector2< kt_int32s > IndexToGrid(kt_int32s index) const
virtual kt_bool Validate()
const Vector3< kt_double > & GetPosition() const
kt_int32u GetSize() const
SensorManagerMap m_Sensors
kt_int32u GetNumberOfRangeReadings() const
Size2 & operator=(const Size2 &rOther)
const std::vector< kt_double > & GetAngles() const
const std::string & GetDescription() const
LaserRangeFinder(const Name &rName)
Rectangle2(T x, T y, T width, T height)
kt_bool DoubleEqual(kt_double a, kt_double b)
const Vector2< kt_double > & GetMinimum() const
virtual ~ParameterManager()
virtual Parameter * Clone()
T GetValue(const Vector2< kt_int32s > &rGrid) const
LookupArray ** m_ppLookupArray
virtual ParameterManager * GetParameterManager()
kt_int32s GetDataSize() const
void DefineEnumValue(kt_int32s value, const std::string &rName)
const std::string & GetName() const
void UnregisterSensor(Sensor *pSensor)
void SetMinPassThrough(kt_int32u count)
const Quaternion & GetOrientation() const
const Vector2< kt_double > & GetOffset() const
void SetScope(const std::string &rScope)
Drive(const std::string &rName)
kt_int32s GetUniqueId() const
void operator/=(T scalar)
CellUpdater * m_pCellUpdater
void ComputeOffsets(kt_int32u angleIndex, kt_double angle, const Pose2Vector &rLocalPoints, LocalizedRangeScan *pScan)
kt_bool operator==(const Name &rOther) const
kt_bool operator<(const Vector2 &rOther) const
void SetMaximumAngle(kt_double maximumAngle)
ParameterManager * m_pParameterManager
DrivePose(const Name &rSensorName)
const kt_objecttype ObjectType_DatasetInfo
ParameterEnum(const std::string &rName, kt_int32s value, ParameterManager *pParameterManger=NULL)
friend std::ostream & operator<<(std::ostream &rStream, const Size2 &rSize)
void SetPosition(const Vector2< T > &rPosition)
Vector3(const Vector3 &rOther)
std::string ToString() const
kt_bool IsDatasetInfo(Object *pObject)
const kt_objecttype ObjectType_CameraImage
std::vector< kt_double > m_Angles
Pose3(const Vector3< kt_double > &rPosition, const karto::Quaternion &rOrientation)
kt_bool IsInBounds(const Vector2< kt_double > &rPoint) const
void SetHeading(kt_double heading)
Parameter< kt_double > * m_pAngularResolution
PointVectorDouble m_PointReadings
std::map< std::string, kt_int32s > EnumMap
Name & operator=(const Name &rOther)
void Add(Object *pObject)
void SetPosition(const T &rX, const T &rY)
Matrix3 operator*(const Matrix3 &rOther) const
SensorVector GetAllSensors()
friend std::ostream & operator<<(std::ostream &rStream, const Vector3 &rVector)
virtual kt_bool Validate()
kt_double GetAngularResolution() const
friend std::istream & operator>>(std::istream &rStream, const Pose2 &)
@ LaserRangeFinder_Custom
Parameter< kt_double > * m_pRangeThreshold
OccupancyGrid * Clone() const
#define forEach(listtype, list)
const kt_objecttype ObjectType_Header
void SetTime(kt_double time)
static LaserRangeFinder * CreateLaserRangeFinder(LaserRangeFinderType type, const Name &rName)
void MakeCeil(const Vector3 &rOther)
const Size2< T > & GetSize() const
void MakeFloor(const Vector2 &rOther)
std::vector< AbstractParameter * > ParameterVector
kt_int32u GetRows() const
kt_bool operator!=(const Quaternion &rOther) const
const std::string & GetAuthor() const
kt_double SquaredLength() const
Quaternion(kt_double x, kt_double y, kt_double z, kt_double w)
virtual kt_bool Process(karto::Object *)
void SetOdometricPose(const Pose3 &rPose)
kt_bool IsUpTo(const T &value, const T &maximum)
kt_int32s * GetArrayPointer() const
Pose2 operator+(const Pose2 &rOther) const
DatasetInfo * m_pDatasetInfo
friend std::ostream & operator<<(std::ostream &rStream, const Vector2 &rVector)
Parameters(const std::string &rName)
kt_bool IsSensor(Object *pObject)
void AddCustomData(CustomData *pCustomData)
Rectangle2 & operator=(const Rectangle2 &rOther)
virtual ~LocalizedRangeScan()
kt_bool IsSensorData(Object *pObject)
const std::string & GetDescription() const
Vector2< kt_int32s > WorldToGrid(const Vector2< kt_double > &rWorld, kt_bool flipY=false) const
LocalizedRangeScan(const Name &rSensorName, const RangeReadingsVector &rReadings)
Pose3 & operator=(const Pose3 &rOther)
Parameter< std::string > * m_pTitle
kt_bool operator<(const Name &rOther) const
friend std::istream & operator>>(std::istream &rStream, const Pose3 &)
const Vector2< kt_double > & GetMaximum() const
Vector2< kt_double > GridToWorld(const Vector2< kt_int32s > &rGrid, kt_bool flipY=false) const
virtual ~GridIndexLookup()
const kt_int32s INVALID_SCAN
std::ostream & operator<<(std::ostream &rStream, Exception &rException)
virtual void SetValueFromString(const std::string &rStringValue)=0
std::vector< Object * > ObjectVector
Vector2< kt_double > m_Maximum
kt_double operator*(const Vector2 &rOther) const
const T & GetValue() const
void SetMinimumAngle(kt_double minimumAngle)
T * GetDataPointer() const
CoordinateConverter * m_pCoordinateConverter
BoundingBox2 GetBoundingBox() const
kt_double SquaredDistance(const Vector2 &rOther) const
std::vector< kt_double > RangeReadingsVector
std::map< std::string, AbstractParameter * > m_ParameterLookup
kt_double GetHeading() const
const kt_objecttype ObjectType_LaserRangeScan
RangeReadingsVector GetRangeReadingsVector() const
kt_bool operator==(const Rectangle2 &rOther) const
const Pose3 & GetOdometricPose() const
Grid< kt_int32u > * m_pCellPassCnt
AbstractParameter * GetParameter(const std::string &rName) const
kt_double GetTime() const
Vector2< kt_double > m_Minimum
void SetSize(const Size2< T > &rSize)
Parameter< std::string > * m_pAuthor
Rectangle2(const Vector2< T > &rPosition, const Size2< T > &rSize)
void operator+=(const Pose2 &rOther)
virtual ~LaserRangeScan()
const Vector3 operator*(T scalar) const
kt_int32s GetHeight() const
const Name & GetSensorName() const
open_karto
Author(s):
autogenerated on Tue Jul 23 2024 02:26:00