18 #ifndef karto_sdk_KARTO_H 19 #define karto_sdk_KARTO_H 37 #include <boost/thread.hpp> 39 #include <boost/serialization/base_object.hpp> 40 #include <boost/serialization/nvp.hpp> 41 #include <boost/serialization/utility.hpp> 42 #include <boost/serialization/export.hpp> 43 #include <boost/type_traits/is_abstract.hpp> 44 #include <boost/archive/binary_iarchive.hpp> 45 #include <boost/archive/binary_oarchive.hpp> 46 #include <boost/serialization/map.hpp> 47 #include <boost/serialization/vector.hpp> 48 #include <boost/serialization/string.hpp> 49 #include <boost/serialization/array.hpp> 50 #include <boost/version.hpp> 53 #include <Poco/Mutex.h> 59 #define KARTO_Object(name) \ 60 virtual const char* GetClassName() const { return #name; } \ 61 virtual kt_objecttype GetObjectType() const { return ObjectType_##name; } 106 : m_Message(rMessage)
107 , m_ErrorCode(errorCode)
115 : m_Message(rException.m_Message)
116 , m_ErrorCode(rException.m_ErrorCode)
194 friend class boost::serialization::access;
195 template<
class Archive>
235 Poco::FastMutex::ScopedLock lock(m_Mutex);
237 if (m_pPointer ==
NULL)
249 Poco::FastMutex m_Mutex;
319 if (m_ParameterLookup.find(rName) != m_ParameterLookup.end())
321 return m_ParameterLookup[rName];
324 std::cout <<
"Unknown parameter: " << rName << std::endl;
366 friend class boost::serialization::access;
367 template<
class Archive>
370 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
NonCopyable);
371 ar & BOOST_SERIALIZATION_NVP(m_Parameters);
372 ar & BOOST_SERIALIZATION_NVP(m_ParameterLookup);
409 : m_Scope(rOther.m_Scope), m_Name(rOther.m_Name)
436 std::string::size_type pos = rName.find_last_of(
'/');
437 if (pos != 0 && pos != std::string::npos)
439 throw Exception(
"Name can't contain a scope!");
477 name.append(m_Scope);
505 return (m_Name == rOther.
m_Name) && (m_Scope == rOther.
m_Scope);
513 return !(*
this == rOther);
521 return this->ToString() < rOther.
ToString();
540 void Parse(
const std::string& rName)
542 std::string::size_type pos = rName.find_last_of(
'/');
544 if (pos == std::string::npos)
550 m_Scope = rName.substr(0, pos);
551 m_Name = rName.substr(pos+1, rName.size());
554 if (m_Scope.size() > 0 && m_Scope[0] ==
'/')
556 m_Scope = m_Scope.substr(1, m_Scope.size());
575 for (
size_t i = 1; i < rName.size(); ++i)
580 throw Exception(
"Invalid character in name. Valid characters must be within the ranges A-Z, a-z, 0-9, '/', '_' and '-'.");
586 throw Exception(
"Invalid first character in name. Valid characters must be within the ranges A-Z, a-z, and '/'.");
597 return (isalpha(c) || c ==
'/');
607 return (isalnum(c) || c ==
'/' || c ==
'_' || c ==
'-');
616 friend class boost::serialization::access;
617 template<
class Archive>
620 ar & BOOST_SERIALIZATION_NVP(m_Name);
621 ar & BOOST_SERIALIZATION_NVP(m_Scope);
665 virtual const char* GetClassName()
const = 0;
679 return m_pParameterManager;
689 return m_pParameterManager->Get(rName);
698 inline void SetParameter(
const std::string& rName, T value);
706 return m_pParameterManager->GetParameterVector();
718 friend class boost::serialization::access;
719 template<
class Archive>
722 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
NonCopyable);
723 ar & BOOST_SERIALIZATION_NVP(m_pParameterManager);
724 ar & BOOST_SERIALIZATION_NVP(m_Name);
727 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
Object)
828 Module(
const std::string& rName);
839 virtual void Reset() = 0;
853 friend class boost::serialization::access;
854 template<
class Archive>
857 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Object);
860 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
Module)
898 : m_Width(rOther.m_Width)
899 , m_Height(rOther.m_Height)
981 friend class boost::serialization::access;
982 template<
class Archive>
985 ar & BOOST_SERIALIZATION_NVP(m_Width);
986 ar & BOOST_SERIALIZATION_NVP(m_Height);
1093 return sqrt(SquaredLength());
1102 return (*
this - rOther).SquaredLength();
1112 return sqrt(SquaredDistance(rOther));
1158 inline void operator /= (T scalar)
1160 m_Values[0] /= scalar;
1161 m_Values[1] /= scalar;
1171 return Vector2(m_Values[0] / scalar, m_Values[1] / scalar);
1181 return m_Values[0] * rOther.
m_Values[0] + m_Values[1] * rOther.
m_Values[1];
1190 return Vector2(m_Values[0] * scalar, m_Values[1] * scalar);
1199 return Vector2(m_Values[0] - scalar, m_Values[1] - scalar);
1206 inline void operator *= (T scalar)
1208 m_Values[0] *= scalar;
1209 m_Values[1] *= scalar;
1218 return (m_Values[0] == rOther.
m_Values[0] && m_Values[1] == rOther.
m_Values[1]);
1227 return (m_Values[0] != rOther.
m_Values[0] || m_Values[1] != rOther.
m_Values[1]);
1237 if (m_Values[0] < rOther.
m_Values[0])
1239 else if (m_Values[0] > rOther.
m_Values[0])
1242 return (m_Values[1] < rOther.
m_Values[1]);
1252 rStream << rVector.
GetX() <<
" " << rVector.
GetY();
1260 friend inline std::istream& operator >> (std::istream& rStream,
const Vector2& )
1266 friend class boost::serialization::access;
1267 template<
class Archive>
1270 ar & boost::serialization::make_nvp(
"m_Values_0", m_Values[0]);
1271 ar & boost::serialization::make_nvp(
"m_Values_1", m_Values[1]);
1290 template<
typename T>
1420 return sqrt(SquaredLength());
1429 std::stringstream converter;
1430 converter.precision(std::numeric_limits<double>::digits10);
1432 converter << GetX() <<
" " << GetY() <<
" " << GetZ();
1434 return converter.str();
1469 return Vector3(m_Values[0] + scalar,
1470 m_Values[1] + scalar,
1471 m_Values[2] + scalar);
1493 return Vector3(m_Values[0] - scalar, m_Values[1] - scalar, m_Values[2] - scalar);
1502 return Vector3(m_Values[0] * scalar, m_Values[1] * scalar, m_Values[2] * scalar);
1511 return (m_Values[0] == rOther.
m_Values[0] &&
1512 m_Values[1] == rOther.
m_Values[1] &&
1513 m_Values[2] == rOther.
m_Values[2]);
1522 return (m_Values[0] != rOther.
m_Values[0] ||
1523 m_Values[1] != rOther.
m_Values[1] ||
1524 m_Values[2] != rOther.
m_Values[2]);
1542 friend inline std::istream& operator >> (std::istream& rStream,
const Vector3& )
1611 m_Values[0] = rQuaternion.
m_Values[0];
1612 m_Values[1] = rQuaternion.
m_Values[1];
1613 m_Values[2] = rQuaternion.
m_Values[2];
1614 m_Values[3] = rQuaternion.
m_Values[3];
1699 kt_double test = m_Values[0] * m_Values[1] + m_Values[2] * m_Values[3];
1704 rYaw = 2 *
atan2(m_Values[0], m_Values[3]);;
1708 else if (test < -0.499)
1711 rYaw = -2 *
atan2(m_Values[0], m_Values[3]);
1717 kt_double sqx = m_Values[0] * m_Values[0];
1718 kt_double sqy = m_Values[1] * m_Values[1];
1719 kt_double sqz = m_Values[2] * m_Values[2];
1721 rYaw =
atan2(2 * m_Values[1] * m_Values[3] - 2 * m_Values[0] * m_Values[2], 1 - 2 * sqy - 2 * sqz);
1722 rPitch =
asin(2 * test);
1723 rRoll =
atan2(2 * m_Values[0] * m_Values[3] - 2 * m_Values[1] * m_Values[2], 1 - 2 * sqx - 2 * sqz);
1742 angle = pitch * 0.5;
1750 m_Values[0] = sYaw * sPitch * cRoll + cYaw * cPitch * sRoll;
1751 m_Values[1] = sYaw * cPitch * cRoll + cYaw * sPitch * sRoll;
1752 m_Values[2] = cYaw * sPitch * cRoll - sYaw * cPitch * sRoll;
1753 m_Values[3] = cYaw * cPitch * cRoll - sYaw * sPitch * sRoll;
1762 m_Values[0] = rQuaternion.
m_Values[0];
1763 m_Values[1] = rQuaternion.
m_Values[1];
1764 m_Values[2] = rQuaternion.
m_Values[2];
1765 m_Values[3] = rQuaternion.
m_Values[3];
1776 return (m_Values[0] == rOther.
m_Values[0] &&
1777 m_Values[1] == rOther.
m_Values[1] &&
1778 m_Values[2] == rOther.
m_Values[2] &&
1779 m_Values[3] == rOther.
m_Values[3]);
1788 return (m_Values[0] != rOther.
m_Values[0] ||
1789 m_Values[1] != rOther.
m_Values[1] ||
1790 m_Values[2] != rOther.
m_Values[2] ||
1791 m_Values[3] != rOther.
m_Values[3]);
1801 rStream << rQuaternion.
m_Values[0] <<
" " 1820 template<
typename T>
1840 , m_Size(width, height)
1850 : m_Position(rPosition)
1859 : m_Position(rOther.m_Position)
1860 , m_Size(rOther.m_Size)
1871 return m_Position.GetX();
1889 return m_Position.GetY();
1907 return m_Size.GetWidth();
1916 m_Size.SetWidth(width);
1925 return m_Size.GetHeight();
1934 m_Size.SetHeight(height);
1962 m_Position = rPosition;
1989 return Vector2<T>(m_Position.GetX() + m_Size.GetWidth() * 0.5, m_Position.GetY() + m_Size.GetHeight() * 0.5);
2026 friend class boost::serialization::access;
2027 template<
class Archive>
2030 ar & BOOST_SERIALIZATION_NVP(m_Position);
2031 ar & BOOST_SERIALIZATION_NVP(m_Size);
2061 : m_Position(rPosition)
2062 , m_Heading(heading)
2074 , m_Heading(heading)
2087 : m_Position(rOther.m_Position)
2088 , m_Heading(rOther.m_Heading)
2099 return m_Position.GetX();
2117 return m_Position.GetY();
2144 m_Position = rPosition;
2162 m_Heading = heading;
2171 return m_Position.SquaredDistance(rOther.
m_Position);
2205 inline void operator += (
const Pose2& rOther)
2235 friend inline std::istream& operator >> (std::istream& rStream,
const Pose2& )
2252 friend class boost::serialization::access;
2253 template<
class Archive>
2256 ar & BOOST_SERIALIZATION_NVP(m_Position);
2257 ar & BOOST_SERIALIZATION_NVP(m_Heading);
2297 : m_Position(rPosition)
2307 : m_Position(rPosition)
2308 , m_Orientation(rOrientation)
2316 : m_Position(rOther.m_Position)
2317 , m_Orientation(rOther.m_Orientation)
2327 m_Orientation.FromEulerAngles(rPose.
GetHeading(), 0.0, 0.0);
2346 m_Position = rPosition;
2355 return m_Orientation;
2364 m_Orientation = rOrientation;
2373 std::stringstream converter;
2374 converter.precision(std::numeric_limits<double>::digits10);
2376 converter << GetPosition() <<
" " << GetOrientation();
2378 return converter.str();
2424 friend inline std::istream& operator >> (std::istream& rStream,
const Pose3& )
2467 memset(m_Matrix, 0, 9*
sizeof(
kt_double));
2471 m_Matrix[i][i] = 1.0;
2480 memset(m_Matrix, 0, 9*
sizeof(
kt_double));
2494 kt_double oneMinusCos = 1.0 - cosRadians;
2508 m_Matrix[0][0] = xx * oneMinusCos + cosRadians;
2509 m_Matrix[0][1] = xyMCos - zSin;
2510 m_Matrix[0][2] = xzMCos + ySin;
2512 m_Matrix[1][0] = xyMCos + zSin;
2513 m_Matrix[1][1] = yy * oneMinusCos + cosRadians;
2514 m_Matrix[1][2] = yzMCos - xSin;
2516 m_Matrix[2][0] = xzMCos - ySin;
2517 m_Matrix[2][1] = yzMCos + xSin;
2518 m_Matrix[2][2] = zz * oneMinusCos + cosRadians;
2533 transpose.
m_Matrix[row][col] = m_Matrix[col][row];
2546 kt_bool haveInverse = InverseFast(kInverse, 1e-14);
2547 if (haveInverse ==
false)
2562 rkInverse.
m_Matrix[0][0] = m_Matrix[1][1]*m_Matrix[2][2] - m_Matrix[1][2]*m_Matrix[2][1];
2563 rkInverse.
m_Matrix[0][1] = m_Matrix[0][2]*m_Matrix[2][1] - m_Matrix[0][1]*m_Matrix[2][2];
2564 rkInverse.
m_Matrix[0][2] = m_Matrix[0][1]*m_Matrix[1][2] - m_Matrix[0][2]*m_Matrix[1][1];
2565 rkInverse.
m_Matrix[1][0] = m_Matrix[1][2]*m_Matrix[2][0] - m_Matrix[1][0]*m_Matrix[2][2];
2566 rkInverse.
m_Matrix[1][1] = m_Matrix[0][0]*m_Matrix[2][2] - m_Matrix[0][2]*m_Matrix[2][0];
2567 rkInverse.
m_Matrix[1][2] = m_Matrix[0][2]*m_Matrix[1][0] - m_Matrix[0][0]*m_Matrix[1][2];
2568 rkInverse.
m_Matrix[2][0] = m_Matrix[1][0]*m_Matrix[2][1] - m_Matrix[1][1]*m_Matrix[2][0];
2569 rkInverse.
m_Matrix[2][1] = m_Matrix[0][1]*m_Matrix[2][0] - m_Matrix[0][0]*m_Matrix[2][1];
2570 rkInverse.
m_Matrix[2][2] = m_Matrix[0][0]*m_Matrix[1][1] - m_Matrix[0][1]*m_Matrix[1][0];
2573 m_Matrix[0][1]*rkInverse.
m_Matrix[1][0] +
2574 m_Matrix[0][2]*rkInverse.
m_Matrix[2][0];
2576 if (fabs(fDet) <= fTolerance)
2582 for (
size_t row = 0; row < 3; row++)
2584 for (
size_t col = 0; col < 3; col++)
2586 rkInverse.
m_Matrix[row][col] *= fInvDet;
2599 std::stringstream converter;
2600 converter.precision(std::numeric_limits<double>::digits10);
2602 for (
int row = 0; row < 3; row++)
2604 for (
int col = 0; col < 3; col++)
2606 converter << m_Matrix[row][col] <<
" ";
2610 return converter.str();
2631 return m_Matrix[row][column];
2642 return m_Matrix[row][column];
2654 for (
size_t row = 0; row < 3; row++)
2656 for (
size_t col = 0; col < 3; col++)
2659 m_Matrix[row][1]*rOther.
m_Matrix[1][col] +
2660 m_Matrix[row][2]*rOther.
m_Matrix[2][col];
2676 pose2.
SetX(m_Matrix[0][0] * rPose2.
GetX() + m_Matrix[0][1] *
2678 pose2.
SetY(m_Matrix[1][0] * rPose2.
GetX() + m_Matrix[1][1] *
2680 pose2.
SetHeading(m_Matrix[2][0] * rPose2.
GetX() + m_Matrix[2][1] *
2696 m_Matrix[row][col] += rkMatrix.
m_Matrix[row][col];
2714 friend class boost::serialization::access;
2715 template<
class Archive>
2718 ar & BOOST_SERIALIZATION_NVP(m_Matrix);
2737 , m_Columns(columns)
2759 if (m_pData !=
NULL)
2761 memset(m_pData, 0,
sizeof(
kt_double) * m_Rows * m_Columns);
2791 RangeCheck(row, column);
2793 return m_pData[row + column * m_Rows];
2804 RangeCheck(row, column);
2806 return m_pData[row + column * m_Rows];
2817 if (m_pData !=
NULL)
2822 m_pData =
new kt_double[m_Rows * m_Columns];
2824 catch (
const std::bad_alloc& ex)
2826 throw Exception(
"Matrix allocation error");
2829 if (m_pData ==
NULL)
2831 throw Exception(
"Matrix allocation error");
2844 throw Exception(
"Matrix - RangeCheck ERROR!!!!");
2849 throw Exception(
"Matrix - RangeCheck ERROR!!!!");
2874 : m_Minimum(999999999999999999.99999, 999999999999999999.99999)
2875 , m_Maximum(-999999999999999999.99999, -999999999999999999.99999)
2893 m_Minimum = mMinimum;
2909 m_Maximum = rMaximum;
2927 m_Minimum.MakeFloor(rPoint);
2928 m_Maximum.MakeCeil(rPoint);
2954 friend class boost::serialization::access;
2955 template<
class Archive>
2958 ar & BOOST_SERIALIZATION_NVP(m_Minimum);
2959 ar & BOOST_SERIALIZATION_NVP(m_Maximum);
2983 SetTransform(
Pose2(), rPose);
2993 SetTransform(rPose1, rPose2);
3004 Pose2 newPosition = m_Transform + m_Rotation * rSourcePose;
3017 Pose2 newPosition = m_InverseRotation * (rSourcePose - m_Transform);
3032 if (rPose1 == rPose2)
3034 m_Rotation.SetToIdentity();
3035 m_InverseRotation.SetToIdentity();
3036 m_Transform =
Pose2();
3046 if (rPose1.
GetX() != 0.0 || rPose1.
GetY() != 0.0)
3048 newPosition = rPose2 - m_Rotation * rPose1;
3052 newPosition = rPose2;
3065 friend class boost::serialization::access;
3066 template<
class Archive>
3069 ar & BOOST_SERIALIZATION_NVP(m_Transform);
3070 ar & BOOST_SERIALIZATION_NVP(m_Rotation);
3071 ar & BOOST_SERIALIZATION_NVP(m_InverseRotation);
3117 if (pParameterManger !=
NULL)
3119 pParameterManger->Add(
this);
3130 const std::string& rDescription,
3133 , m_Description(rDescription)
3136 if (pParameterManger !=
NULL)
3138 pParameterManger->Add(
this);
3165 return m_Description;
3172 virtual const std::string GetValueAsString()
const = 0;
3178 virtual void SetValueFromString(
const std::string& rStringValue) = 0;
3194 rStream.precision(6);
3195 rStream.flags(std::ios::fixed);
3207 friend class boost::serialization::access;
3208 template<
class Archive>
3211 ar & BOOST_SERIALIZATION_NVP(m_Name);
3212 ar & BOOST_SERIALIZATION_NVP(m_Description);
3224 template<
typename T>
3251 const std::string& rDescription,
3291 std::stringstream converter;
3292 converter << m_Value;
3293 return converter.str();
3302 std::stringstream converter;
3303 converter.str(rStringValue);
3304 converter >> m_Value;
3313 return new Parameter(GetName(), GetDescription(), GetValue());
3330 T operator = (T value)
3340 friend class boost::serialization::access;
3341 template<
class Archive>
3345 ar & BOOST_SERIALIZATION_NVP(m_Value);
3354 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
Parameter)
3359 int precision = std::numeric_limits<double>::digits10;
3360 std::stringstream converter;
3361 converter.precision(precision);
3363 converter.str(rStringValue);
3366 converter >> m_Value;
3372 std::stringstream converter;
3373 converter.precision(std::numeric_limits<double>::digits10);
3374 converter << m_Value;
3375 return converter.str();
3381 if (rStringValue ==
"true" || rStringValue ==
"TRUE")
3394 if (m_Value ==
true)
3455 if (m_EnumDefines.find(rStringValue) != m_EnumDefines.end())
3457 m_Value = m_EnumDefines[rStringValue];
3461 std::string validValues;
3465 validValues += iter->first +
", ";
3468 throw Exception(
"Unable to set enum: " + rStringValue +
". Valid values are: " + validValues);
3480 if (iter->second == m_Value)
3486 throw Exception(
"Unable to lookup enum");
3496 if (m_EnumDefines.find(rName) == m_EnumDefines.end())
3498 m_EnumDefines[rName] = value;
3502 std::cerr <<
"Overriding enum value: " << m_EnumDefines[rName] <<
" with " << value << std::endl;
3504 m_EnumDefines[rName] = value;
3534 friend class boost::serialization::access;
3535 template<
class Archive>
3539 ar & BOOST_SERIALIZATION_NVP(m_EnumDefines);
3577 friend class boost::serialization::access;
3578 template<
class Archive>
3581 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Object);
3632 return m_pOffsetPose->GetValue();
3641 m_pOffsetPose->SetValue(rPose);
3648 virtual kt_bool Validate() = 0;
3673 friend class boost::serialization::access;
3674 template<
class Archive>
3677 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Object);
3678 ar & BOOST_SERIALIZATION_NVP(m_pOffsetPose);
3681 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
Sensor)
3734 if ((m_Sensors.find(pSensor->
GetName()) != m_Sensors.end()) && !
override)
3736 throw Exception(
"Cannot register sensor: already registered: [" +
3738 "] (Consider setting 'override' to true)");
3741 std::cout <<
"Registering sensor: [" << pSensor->
GetName().
ToString() <<
"]" << std::endl;
3743 m_Sensors[pSensor->
GetName()] = pSensor;
3754 if (m_Sensors.find(pSensor->
GetName()) != m_Sensors.end())
3756 std::cout <<
"Unregistering sensor: " << pSensor->
GetName().
ToString() << std::endl;
3758 m_Sensors.erase(pSensor->
GetName());
3773 if (m_Sensors.find(rName) != m_Sensors.end())
3775 return m_Sensors[rName];
3778 throw Exception(
"Sensor not registered: [" + rName.
ToString() +
"] (Did you add the sensor to the Dataset?)");
3789 Sensor* pSensor = GetSensorByName(rName);
3791 return dynamic_cast<T*
>(pSensor);
3804 sensors.push_back(iter->second);
3817 if (pSensor ==
NULL)
3819 throw Exception(
"Invalid sensor: NULL");
3823 throw Exception(
"Invalid sensor: nameless");
3833 friend class boost::serialization::access;
3834 template<
class Archive>
3837 ar & BOOST_SERIALIZATION_NVP(m_Sensors);
3881 if (pSensorData ==
NULL)
3892 friend class boost::serialization::access;
3893 template<
class Archive>
3896 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Sensor);
3900 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
Drive)
3945 return m_pMinimumRange->GetValue();
3954 m_pMinimumRange->SetValue(minimumRange);
3956 SetRangeThreshold(GetRangeThreshold());
3965 return m_pMaximumRange->GetValue();
3974 m_pMaximumRange->SetValue(maximumRange);
3976 SetRangeThreshold(GetRangeThreshold());
3985 return m_pRangeThreshold->GetValue();
3995 m_pRangeThreshold->SetValue(
math::Clip(rangeThreshold, GetMinimumRange(), GetMaximumRange()));
3999 std::cout <<
"Info: clipped range threshold to be within minimum and maximum range!" << std::endl;
4009 return m_pMinimumAngle->GetValue();
4018 m_pMinimumAngle->SetValue(minimumAngle);
4029 return m_pMaximumAngle->GetValue();
4038 m_pMaximumAngle->SetValue(maximumAngle);
4049 return m_pAngularResolution->GetValue();
4060 m_pAngularResolution->SetValue(angularResolution);
4074 std::stringstream stream;
4075 stream <<
"Invalid resolution for Sick LMS100: ";
4076 stream << angularResolution;
4097 std::stringstream stream;
4098 stream <<
"Invalid resolution for Sick LMS291: ";
4099 stream << angularResolution;
4105 throw Exception(
"Can't set angular resolution, please create a LaserRangeFinder of type Custom");
4116 return m_pType->GetValue();
4125 return m_NumberOfRangeReadings;
4135 return m_pIs360Laser->GetValue();
4144 m_pIs360Laser->SetValue(is_360_laser);
4154 if (
math::InRange(GetRangeThreshold(), GetMinimumRange(), GetMaximumRange()) ==
false)
4156 std::cout <<
"Please set range threshold to a value between [" 4157 << GetMinimumRange() <<
";" << GetMaximumRange() <<
"]" << std::endl;
4175 kt_bool ignoreThresholdPoints =
true,
4321 Pose2 defaultOffset;
4334 , m_NumberOfRangeReadings(0)
4344 GetParameterManager());
4348 m_pIs360Laser =
new Parameter<kt_bool>(
"Is360DegreeLaser",
false, GetParameterManager());
4366 if (GetIs360Laser())
4373 / GetAngularResolution()) + residual);
4399 friend class boost::serialization::access;
4400 template<
class Archive>
4403 if (Archive::is_loading::value)
4413 GetParameterManager());
4417 m_pIs360Laser =
new Parameter<kt_bool>(
"Is360DegreeLaser",
false, GetParameterManager());
4422 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Sensor);
4423 ar & BOOST_SERIALIZATION_NVP(m_pMinimumAngle);
4424 ar & BOOST_SERIALIZATION_NVP(m_pMaximumAngle);
4425 ar & BOOST_SERIALIZATION_NVP(m_pAngularResolution);
4426 ar & BOOST_SERIALIZATION_NVP(m_pMinimumRange);
4427 ar & BOOST_SERIALIZATION_NVP(m_pMaximumRange);
4428 ar & BOOST_SERIALIZATION_NVP(m_pRangeThreshold);
4429 ar & BOOST_SERIALIZATION_NVP(m_pIs360Laser);
4430 ar & BOOST_SERIALIZATION_NVP(m_pType);
4431 ar & BOOST_SERIALIZATION_NVP(m_NumberOfRangeReadings);
4477 return value * m_Scale;
4488 kt_double gridX = (rWorld.
GetX() - m_Offset.GetX()) * m_Scale;
4493 gridY = (rWorld.
GetY() - m_Offset.GetY()) * m_Scale;
4497 gridY = (m_Size.GetHeight() / m_Scale - rWorld.
GetY() + m_Offset.GetY()) * m_Scale;
4516 worldY = m_Offset.GetY() + rGrid.
GetY() / m_Scale;
4520 worldY = m_Offset.GetY() + (m_Size.GetHeight() - rGrid.
GetY()) / m_Scale;
4586 return 1.0 / m_Scale;
4595 m_Scale = 1.0 / resolution;
4608 kt_double maxX = minX + GetSize().GetWidth() * GetResolution();
4609 kt_double maxY = minY + GetSize().GetHeight() * GetResolution();
4621 friend class boost::serialization::access;
4622 template<
class Archive>
4625 ar & BOOST_SERIALIZATION_NVP(m_Size);
4626 ar & BOOST_SERIALIZATION_NVP(m_Scale);
4627 ar & BOOST_SERIALIZATION_NVP(m_Offset);
4639 template<
typename T>
4655 Grid* pGrid =
new Grid(width, height);
4671 if (m_pCoordinateConverter)
4673 delete m_pCoordinateConverter;
4683 memset(m_pData, 0, GetDataSize() *
sizeof(T));
4692 Grid* pGrid = CreateGrid(GetWidth(), GetHeight(), GetResolution());
4695 memcpy(pGrid->
GetDataPointer(), GetDataPointer(), GetDataSize());
4709 m_WidthStep = math::AlignValue<kt_int32s>(width, 8);
4711 if (m_pData !=
NULL)
4719 m_pData =
new T[GetDataSize()];
4721 if (m_pCoordinateConverter ==
NULL)
4757 if (boundaryCheck ==
true)
4759 if (IsValidGridIndex(rGrid) ==
false)
4761 std::stringstream error;
4762 error <<
"Index " << rGrid <<
" out of range. Index must be between [0; " 4763 << m_Width <<
") and [0; " << m_Height <<
")";
4770 if (boundaryCheck ==
true)
4787 grid.
SetY(index / m_WidthStep);
4788 grid.
SetX(index - grid.
GetY() * m_WidthStep);
4801 return GetCoordinateConverter()->WorldToGrid(rWorld, flipY);
4812 return GetCoordinateConverter()->GridToWorld(rGrid, flipY);
4822 kt_int32s index = GridIndex(rGrid,
true);
4823 return m_pData + index;
4833 kt_int32s index = GridIndex(rGrid,
true);
4834 return m_pData + index;
4897 return m_WidthStep * m_Height;
4908 return m_pData[index];
4917 return m_pCoordinateConverter;
4926 return GetCoordinateConverter()->GetResolution();
4935 return GetCoordinateConverter()->GetBoundingBox();
4993 if (2 * error >= deltaX)
5000 if (IsValidGridIndex(gridIndex))
5002 kt_int32s index = GridIndex(gridIndex,
false);
5003 T* pGridPointer = GetDataPointer();
5004 pGridPointer[index]++;
5022 , m_pCoordinateConverter(
NULL)
5024 Resize(width, height);
5035 friend class boost::serialization::access;
5036 template<
class Archive>
5039 ar & BOOST_SERIALIZATION_NVP(m_Width);
5040 ar & BOOST_SERIALIZATION_NVP(m_Height);
5041 ar & BOOST_SERIALIZATION_NVP(m_WidthStep);
5042 ar & BOOST_SERIALIZATION_NVP(m_pCoordinateConverter);
5045 if (Archive::is_loading::value)
5047 m_pData =
new T[m_WidthStep * m_Height];
5049 ar & boost::serialization::make_array<T>(m_pData, m_WidthStep * m_Height);
5053 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
Grid)
5090 virtual const std::string
Write()
const = 0;
5096 virtual void Read(
const std::string& rValue) = 0;
5102 friend class boost::serialization::access;
5103 template<
class Archive>
5106 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Object);
5109 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
CustomData)
5154 m_StateId = stateId;
5172 m_UniqueId = uniqueId;
5199 return m_SensorName;
5208 m_CustomData.push_back(pCustomData);
5217 return m_CustomData;
5260 friend class boost::serialization::access;
5261 template<
class Archive>
5264 ar & BOOST_SERIALIZATION_NVP(m_StateId);
5265 ar & BOOST_SERIALIZATION_NVP(m_UniqueId);
5266 ar & BOOST_SERIALIZATION_NVP(m_SensorName);
5267 ar & BOOST_SERIALIZATION_NVP(m_Time);
5268 ar & BOOST_SERIALIZATION_NVP(m_CustomData);
5269 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Object);
5300 , m_pRangeReadings(
NULL)
5301 , m_NumberOfRangeReadings(0)
5316 , m_pRangeReadings(
NULL)
5317 , m_NumberOfRangeReadings(0)
5319 assert(rSensorName.
ToString() !=
"");
5321 SetRangeReadings(rRangeReadings);
5329 delete [] m_pRangeReadings;
5330 m_pRangeReadings =
nullptr;
5340 return m_pRangeReadings;
5363 if (!rRangeReadings.empty())
5365 if (rRangeReadings.size() != m_NumberOfRangeReadings)
5368 delete [] m_pRangeReadings;
5371 m_NumberOfRangeReadings =
static_cast<kt_int32u>(rRangeReadings.size());
5374 m_pRangeReadings =
new kt_double[m_NumberOfRangeReadings];
5381 m_pRangeReadings[index++] = *iter;
5386 delete [] m_pRangeReadings;
5387 m_pRangeReadings =
NULL;
5406 return m_NumberOfRangeReadings;
5417 friend class boost::serialization::access;
5418 template<
class Archive>
5421 ar & BOOST_SERIALIZATION_NVP(m_NumberOfRangeReadings);
5422 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
SensorData);
5424 if (Archive::is_loading::value)
5426 m_pRangeReadings =
new kt_double[m_NumberOfRangeReadings];
5428 ar & boost::serialization::make_array<kt_double>(m_pRangeReadings, m_NumberOfRangeReadings);
5470 return m_OdometricPose;
5479 m_OdometricPose = rPose;
5540 return m_OdometricPose;
5549 m_OdometricPose = rPose;
5562 return m_CorrectedPose;
5571 m_CorrectedPose = rPose;
5582 SetCorrectedPose(rPose);
5592 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5597 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5601 return m_BarycenterPose;
5606 m_BarycenterPose = bcenter;
5616 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5621 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5625 return useBarycenter ? GetBarycenterPose() : GetSensorPose();
5634 return GetSensorAt(m_CorrectedPose);
5639 m_IsDirty = rIsDirty;
5648 m_CorrectedPose = GetCorrectedAt(rScanPose);
5670 Pose2 deviceOffsetPose2 = GetLaserRangeFinder()->GetOffsetPose();
5675 Pose2 worldSensorOffset =
Pose2(offsetLength *
cos(correctedHeading + angleoffset - offsetHeading),
5676 offsetLength *
sin(correctedHeading + angleoffset - offsetHeading),
5679 return sPose - worldSensorOffset;
5688 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5693 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5697 return m_BoundingBox;
5702 m_BoundingBox = bbox;
5710 boost::shared_lock<boost::shared_mutex> lock(m_Lock);
5715 boost::unique_lock<boost::shared_mutex> uniqueLock(m_Lock);
5719 if (wantFiltered ==
true)
5721 return m_PointReadings;
5725 return m_UnfilteredPointReadings;
5733 m_PointReadings = points;
5737 m_UnfilteredPointReadings = points;
5750 if (pLaserRangeFinder !=
NULL)
5752 m_PointReadings.clear();
5753 m_UnfilteredPointReadings.clear();
5758 Pose2 scanPose = GetSensorPose();
5765 kt_double rangeReading = GetRangeReadings()[i];
5771 point.
SetX(scanPose.
GetX() + (rangeReading *
cos(angle)));
5772 point.
SetY(scanPose.
GetY() + (rangeReading *
sin(angle)));
5774 m_UnfilteredPointReadings.push_back(point);
5781 point.
SetX(scanPose.
GetX() + (rangeReading *
cos(angle)));
5782 point.
SetY(scanPose.
GetY() + (rangeReading *
sin(angle)));
5784 m_PointReadings.push_back(point);
5785 m_UnfilteredPointReadings.push_back(point);
5787 rangePointsSum += point;
5795 m_BarycenterPose =
Pose2(averagePosition, 0.0);
5799 m_BarycenterPose = scanPose;
5807 m_BoundingBox.Add(*iter);
5817 friend class boost::serialization::access;
5818 template<
class Archive>
5821 ar & BOOST_SERIALIZATION_NVP(m_OdometricPose);
5822 ar & BOOST_SERIALIZATION_NVP(m_CorrectedPose);
5823 ar & BOOST_SERIALIZATION_NVP(m_BarycenterPose);
5824 ar & BOOST_SERIALIZATION_NVP(m_PointReadings);
5825 ar & BOOST_SERIALIZATION_NVP(m_UnfilteredPointReadings);
5826 ar & BOOST_SERIALIZATION_NVP(m_BoundingBox);
5827 ar & BOOST_SERIALIZATION_NVP(m_IsDirty);
5900 : m_Points(rPoints),
5918 m_PointReadings.clear();
5919 m_UnfilteredPointReadings.clear();
5921 Pose2 scanPose = GetSensorPose();
5922 Pose2 robotPose = GetCorrectedPose();
5926 for (
kt_int32u i = 0; i < m_Points.size(); i++)
5929 if (!std::isfinite(m_Points[i].GetX()) || !std::isfinite(m_Points[i].GetY()))
5932 m_UnfilteredPointReadings.push_back(point);
5938 Pose2 pointPose(m_Points[i].GetX(), m_Points[i].GetY(), 0);
5942 m_PointReadings.push_back(point);
5943 m_UnfilteredPointReadings.push_back(point);
5945 rangePointsSum += point;
5953 m_BarycenterPose =
Pose2(averagePosition, 0.0);
5957 m_BarycenterPose = scanPose;
5965 m_BoundingBox.Add(*iter);
5989 : m_pOccupancyGrid(pGrid)
5997 virtual void operator() (
kt_int32u index);
6009 friend class IncrementalOccupancyGrid;
6021 , m_pCellPassCnt(
Grid<
kt_int32u>::CreateGrid(0, 0, resolution))
6022 , m_pCellHitsCnt(
Grid<
kt_int32u>::CreateGrid(0, 0, resolution))
6023 , m_pCellUpdater(
NULL)
6029 throw Exception(
"Resolution cannot be 0");
6035 GetCoordinateConverter()->SetScale(1.0 / resolution);
6036 GetCoordinateConverter()->SetOffset(rOffset);
6044 delete m_pCellUpdater;
6046 delete m_pCellPassCnt;
6047 delete m_pCellHitsCnt;
6049 delete m_pMinPassThrough;
6050 delete m_pOccupancyThreshold;
6068 ComputeDimensions(rScans, resolution, width, height, offset);
6072 return pOccupancyGrid;
6083 GetCoordinateConverter()->GetOffset(),
6084 1.0 / GetCoordinateConverter()->GetScale());
6085 memcpy(pOccupancyGrid->
GetDataPointer(), GetDataPointer(), GetDataSize());
6091 return pOccupancyGrid;
6119 double scale = GetCoordinateConverter()->GetScale();
6128 kt_double xStop = x + maxRange * cosTheta;
6129 kt_double xSteps = 1 + fabs(xStop - x) * scale;
6131 kt_double yStop = y + maxRange * sinTheta;
6132 kt_double ySteps = 1 + fabs(yStop - y) * scale;
6144 if (IsValidGridIndex(gridIndex) && IsFree(gridIndex))
6146 distance = (i + 1) * delta;
6154 return (distance < maxRange)? distance : maxRange;
6164 m_pMinPassThrough->SetValue(count);
6173 m_pOccupancyThreshold->SetValue(thresh);
6183 return m_pCellHitsCnt;
6192 return m_pCellPassCnt;
6214 if (*iter ==
nullptr)
6219 boundingBox.
Add((*iter)->GetBoundingBox());
6236 m_pCellPassCnt->Resize(GetWidth(), GetHeight());
6237 m_pCellPassCnt->GetCoordinateConverter()->SetOffset(GetCoordinateConverter()->GetOffset());
6239 m_pCellHitsCnt->Resize(GetWidth(), GetHeight());
6240 m_pCellHitsCnt->GetCoordinateConverter()->SetOffset(GetCoordinateConverter()->GetOffset());
6244 if (*iter ==
nullptr)
6284 if (rangeReading <= minRange || rangeReading >= maxRange || std::isnan(rangeReading))
6290 else if (rangeReading >= rangeThreshold)
6293 kt_double ratio = rangeThreshold / rangeReading;
6296 point.
SetX(scanPosition.
GetX() + ratio * dx);
6297 point.
SetY(scanPosition.
GetY() + ratio * dy);
6300 kt_bool isInMap = RayTrace(scanPosition, point, isEndPointValid, doUpdate);
6326 assert(m_pCellPassCnt !=
NULL && m_pCellHitsCnt !=
NULL);
6332 m_pCellPassCnt->TraceLine(gridFrom.
GetX(), gridFrom.
GetY(), gridTo.
GetX(), gridTo.
GetY(), pCellUpdater);
6335 if (isEndPointValid)
6337 if (m_pCellPassCnt->IsValidGridIndex(gridTo))
6339 kt_int32s index = m_pCellPassCnt->GridIndex(gridTo,
false);
6341 kt_int32u* pCellPassCntPtr = m_pCellPassCnt->GetDataPointer();
6342 kt_int32u* pCellHitCntPtr = m_pCellHitsCnt->GetDataPointer();
6345 pCellPassCntPtr[index]++;
6346 pCellHitCntPtr[index]++;
6350 (*m_pCellUpdater)(index);
6355 return m_pCellPassCnt->IsValidGridIndex(gridTo);
6366 if (cellPassCnt > m_pMinPassThrough->GetValue())
6368 kt_double hitRatio =
static_cast<kt_double>(cellHitCnt) / static_cast<kt_double>(cellPassCnt);
6370 if (hitRatio > m_pOccupancyThreshold->GetValue())
6386 assert(m_pCellPassCnt !=
NULL && m_pCellHitsCnt !=
NULL);
6392 kt_int8u* pDataPtr = GetDataPointer();
6393 kt_int32u* pCellPassCntPtr = m_pCellPassCnt->GetDataPointer();
6394 kt_int32u* pCellHitCntPtr = m_pCellHitsCnt->GetDataPointer();
6397 for (
kt_int32u i = 0; i < nBytes; i++, pDataPtr++, pCellPassCntPtr++, pCellHitCntPtr++)
6399 UpdateCell(pDataPtr, *pCellPassCntPtr, *pCellHitCntPtr);
6411 m_pCellPassCnt->Resize(width, height);
6412 m_pCellHitsCnt->Resize(width, height);
6487 return m_pTitle->GetValue();
6495 return m_pAuthor->GetValue();
6503 return m_pDescription->GetValue();
6511 return m_pCopyright->GetValue();
6527 friend class boost::serialization::access;
6528 template<
class Archive>
6531 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Object);
6532 ar & BOOST_SERIALIZATION_NVP(*m_pTitle);
6533 ar & BOOST_SERIALIZATION_NVP(*m_pAuthor);
6534 ar & BOOST_SERIALIZATION_NVP(*m_pDescription);
6535 ar & BOOST_SERIALIZATION_NVP(*m_pCopyright);
6554 : m_pDatasetInfo(
NULL)
6572 printf(
"Save To File\n");
6573 std::ofstream ofs(filename.c_str());
6574 boost::archive::binary_oarchive oa(ofs, boost::archive::no_codecvt);
6575 oa << BOOST_SERIALIZATION_NVP(*
this);
6584 printf(
"Load From File\n");
6585 std::ifstream ifs(filename.c_str());
6586 boost::archive::binary_iarchive ia(ifs, boost::archive::no_codecvt);
6587 ia >> BOOST_SERIALIZATION_NVP(*
this);
6597 if (pObject !=
NULL)
6599 if (dynamic_cast<Sensor*>(pObject))
6602 if (pSensor !=
NULL)
6604 m_SensorNameLookup[pSensor->
GetName()] = pSensor;
6608 m_Lasers.push_back(pObject);
6610 else if (dynamic_cast<SensorData*>(pObject))
6613 m_Data.insert({pSensorData->
GetUniqueId(), pSensorData});
6615 else if (dynamic_cast<DatasetInfo*>(pObject))
6617 m_pDatasetInfo =
dynamic_cast<DatasetInfo*
>(pObject);
6621 std::cout <<
"Did not save object of non-data and non-sensor type" << std::endl;
6651 if (iterator != m_Data.end())
6653 delete iterator->second;
6654 iterator->second =
nullptr;
6655 m_Data.erase(iterator);
6659 std::cout <<
"Failed to remove data. Pointer to LocalizedRangeScan could not be found in dataset. " 6660 <<
"Most likely different pointer address but same object TODO STEVE." << std::endl;
6670 return m_pDatasetInfo;
6678 for (std::map<Name, Sensor*>::iterator iter = m_SensorNameLookup.begin(); iter != m_SensorNameLookup.end(); ++iter)
6692 for (
auto iter = m_Data.begin(); iter != m_Data.end(); ++iter)
6696 delete iter->second;
6697 iter->second =
NULL;
6704 if (m_pDatasetInfo !=
NULL)
6706 delete m_pDatasetInfo;
6707 m_pDatasetInfo =
NULL;
6719 friend class boost::serialization::access;
6720 template<
class Archive>
6723 std::cout<<
"**Serializing Dataset**\n";
6724 std::cout<<
"Dataset <- m_SensorNameLookup\n";
6725 ar & BOOST_SERIALIZATION_NVP(m_SensorNameLookup);
6726 std::cout<<
"Dataset <- m_Data\n";
6727 ar & BOOST_SERIALIZATION_NVP(m_Data);
6728 std::cout<<
"Dataset <- m_Lasers\n";
6729 ar & BOOST_SERIALIZATION_NVP(m_Lasers);
6730 std::cout<<
"Dataset <- m_pDatasetInfo\n";
6731 ar & BOOST_SERIALIZATION_NVP(m_pDatasetInfo);
6732 std::cout<<
"**Finished serializing Dataset**\n";
6736 BOOST_SERIALIZATION_ASSUME_ABSTRACT(
Dataset)
6763 assert(m_pArray !=
NULL);
6775 memset(m_pArray, 0,
sizeof(
kt_int32s) * m_Capacity);
6795 if (size > m_Capacity)
6797 if (m_pArray !=
NULL)
6815 assert(index < m_Size);
6817 return m_pArray[index];
6827 assert(index < m_Size);
6829 return m_pArray[index];
6854 friend class boost::serialization::access;
6855 template<
class Archive>
6858 ar & BOOST_SERIALIZATION_NVP(m_Capacity);
6859 ar & BOOST_SERIALIZATION_NVP(m_Size);
6860 if (Archive::is_loading::value)
6864 ar & boost::serialization::make_array<kt_int32s >(m_pArray, m_Capacity);
6887 template<
typename T>
6902 , m_ppLookupArray(
NULL)
6924 return m_ppLookupArray[index];
6948 assert(angleOffset != 0.0);
6949 assert(angleResolution != 0.0);
6966 Pose2 vec = transform.InverseTransformPose(
Pose2(*iter, 0.0));
6967 localPoints.push_back(vec);
6973 kt_double startAngle = angleCenter - angleOffset;
6974 for (
kt_int32u angleIndex = 0; angleIndex < nAngles; angleIndex++)
6976 angle = startAngle + angleIndex * angleResolution;
6977 ComputeOffsets(angleIndex, angle, localPoints, pScan);
6991 m_ppLookupArray[angleIndex]->SetSize(static_cast<kt_int32u>(rLocalPoints.size()));
6992 m_Angles.at(angleIndex) = angle;
6997 const Vector2<kt_double>& rGridOffset = m_pGrid->GetCoordinateConverter()->GetOffset();
7004 kt_int32s* pAngleIndexPointer = m_ppLookupArray[angleIndex]->GetArrayPointer();
7022 offset.
SetX(cosine * rPosition.
GetX() - sine * rPosition.
GetY());
7023 offset.
SetY(sine * rPosition.
GetX() + cosine * rPosition.
GetY());
7029 kt_int32s lookupIndex = m_pGrid->Grid<T>::GridIndex(gridPoint,
false);
7031 pAngleIndexPointer[readingIndex] = lookupIndex;
7035 assert(readingIndex == rLocalPoints.size());
7046 if (size > m_Capacity)
7048 if (m_ppLookupArray !=
NULL)
7055 for (
kt_int32u i = 0; i < m_Capacity; i++)
7063 m_Angles.resize(size);
7071 if (m_ppLookupArray)
7073 for (
kt_int32u i = 0; i < m_Capacity; i++)
7075 delete m_ppLookupArray[i];
7078 if (m_ppLookupArray)
7080 delete[] m_ppLookupArray;
7081 m_ppLookupArray =
NULL;
7095 friend class boost::serialization::access;
7096 template<
class Archive>
7099 ar & BOOST_SERIALIZATION_NVP(m_pGrid);
7100 ar & BOOST_SERIALIZATION_NVP(m_Capacity);
7101 ar & BOOST_SERIALIZATION_NVP(m_Size);
7102 ar & BOOST_SERIALIZATION_NVP(m_Angles);
7103 if (Archive::is_loading::value)
7106 for (
kt_int32u i = 0; i < m_Capacity; i++)
7111 ar & boost::serialization::make_array<LookupArray*>(m_ppLookupArray, m_Capacity);
7120 : m_Position(rPose.GetPosition().GetX(), rPose.GetPosition().GetY())
7134 template<
typename T>
7138 if (pParameter !=
NULL)
7140 std::stringstream stream;
7146 throw Exception(
"Parameter does not exist: " + rName);
7154 if (pParameter !=
NULL)
7160 throw Exception(
"Parameter does not exist: " + rName);
7197 #endif // karto_sdk_KARTO_H void Add(const BoundingBox2 &rBoundingBox)
BoundingBox2 m_BoundingBox
const Vector3< kt_double > & GetPosition() const
std::vector< kt_double > m_Angles
Parameters(const std::string &rName)
const kt_objecttype ObjectType_Misc
AbstractParameter * GetParameter(const std::string &rName) const
std::string ToString() const
const kt_objecttype ObjectType_CustomData
LaserRangeFinder * GetLaserRangeFinder() const
std::string m_Description
kt_double * GetRangeReadings() const
void serialize(Archive &ar, const unsigned int version)
void SetSize(const Size2< kt_int32s > &rSize)
kt_double operator()(kt_int32u row, kt_int32u column) const
const Pose2 & GetBarycenterPose() const
DrivePose(const Name &rSensorName)
AbstractParameter(const std::string &rName, const std::string &rDescription, ParameterManager *pParameterManger=NULL)
std::string ToString() const
PointVectorDouble m_UnfilteredPointReadings
Matrix3(const Matrix3 &rOther)
virtual kt_bool Validate()
Size2< kt_int32s > m_Size
kt_int32s GetWidthStep() const
kt_int32u GetNumberOfRangeReadings() const
void SetSize(const Size2< T > &rSize)
const kt_objecttype ObjectType_LocalizedRangeScan
kt_double SquaredDistance(const Pose2 &rOther) const
std::vector< Sensor * > SensorVector
virtual kt_objecttype GetObjectType() const =0
Exception(const std::string &rMessage="Karto Exception", kt_int32s errorCode=0)
CellUpdater * m_pCellUpdater
Parameter< kt_double > * m_pOccupancyThreshold
kt_bool IsSensorData(Object *pObject)
Pose3(const Vector3< kt_double > &rPosition)
kt_int32s GetDataSize() const
Pose2(kt_double x, kt_double y, kt_double heading)
virtual ~ParameterManager()
LaserRangeScan(const Name &rSensorName)
const kt_int32s INVALID_SCAN
void serialize(Archive &ar, const unsigned int version)
void SetMinimum(const Vector2< kt_double > &mMinimum)
Name(const std::string &rName)
kt_double Round(kt_double value)
void MakeCeil(const Vector2 &rOther)
kt_double & operator()(kt_int32u row, kt_int32u column)
void SetUniqueId(kt_int32u uniqueId)
Pose2 GetSensorPose() const
const Vector2< kt_double > & GetOffset() const
static void Validate(Sensor *pSensor)
kt_int32s GetStateId() const
const Pose2 & GetOdometricPose() const
void SaveToFile(const std::string &filename)
kt_double GetScale() const
void SetBarycenterPose(Pose2 &bcenter)
std::vector< Vector2< kt_double > > PointVectorDouble
const kt_objecttype ObjectType_DatasetInfo
void SetValue(const T &rValue)
const kt_objecttype ObjectType_CameraImage
Pose2(const Vector2< kt_double > &rPosition, kt_double heading)
Matrix3 Transpose() const
void serialize(Archive &ar, const unsigned int version)
kt_int32s GetWidth() const
void FromEulerAngles(kt_double yaw, kt_double pitch, kt_double roll)
void DefineEnumValue(kt_int32s value, const std::string &rName)
void SetPosition(const T &rX, const T &rY)
kt_double GetResolution() const
kt_bool IsValidFirst(char c)
void SetRangeThreshold(kt_double rangeThreshold)
const kt_objecttype ObjectType_Module
std::vector< Object * > ObjectVector
kt_int32s * GetArrayPointer()
kt_int32u m_NumberOfRangeReadings
const Pose2 & GetCorrectedPose() const
kt_int32u GetNumberOfRangeReadings() const
Vector2< kt_int32s > WorldToGrid(const Vector2< kt_double > &rWorld, kt_bool flipY=false) const
const Vector2< kt_double > & GetPosition() const
void serialize(Archive &ar, const unsigned int version)
Vector2< kt_double > m_Maximum
kt_bool IsLocalizedRangeScanWithPoints(Object *pObject)
const T & Maximum(const T &value1, const T &value2)
Vector2< kt_int32s > WorldToGrid(const Vector2< kt_double > &rWorld, kt_bool flipY=false) const
kt_double DegreesToRadians(kt_double degrees)
void SetScope(const std::string &rScope)
const kt_objecttype ObjectType_None
AbstractParameter(const std::string &rName, ParameterManager *pParameterManger=NULL)
const kt_objecttype ObjectType_Header
Parameter< kt_double > * m_pMinimumAngle
virtual ~LaserRangeFinder()
void serialize(Archive &ar, const unsigned int version)
kt_int32u GetSize() const
void LoadFromFile(const std::string &filename)
void serialize(Archive &ar, const unsigned int version)
LaserRangeFinder(const Name &rName)
void serialize(Archive &ar, const unsigned int version)
LocalizedRangeScanWithPoints(const Name &rSensorName, const RangeReadingsVector &rReadings, const PointVectorDouble &rPoints)
const PointVectorDouble & GetPointReadings(kt_bool wantFiltered=false) const
Size2(const Size2 &rOther)
const T GetHeight() const
void serialize(Archive &ar, const unsigned int version)
void serialize(Archive &ar, const unsigned int version)
Vector3(const Vector3 &rOther)
Parameter(const std::string &rName, T value, ParameterManager *pParameterManger=NULL)
void SetParameter(const std::string &rName, T value)
AbstractParameter * Get(const std::string &rName)
void SetStateId(kt_int32s stateId)
std::map< kt_int32s, Object * > DataMap
void SetBoundingBox(BoundingBox2 &bbox)
LaserRangeScan(const Name &rSensorName, const RangeReadingsVector &rRangeReadings)
void serialize(Archive &ar, const unsigned int version)
Parameter< Pose2 > * m_pOffsetPose
Parameter(const std::string &rName, const std::string &rDescription, T value, ParameterManager *pParameterManger=NULL)
virtual void UpdateCell(kt_int8u *pCell, kt_int32u cellPassCnt, kt_int32u cellHitCnt)
#define forEach(listtype, list)
const kt_objecttype ObjectType_LaserRangeFinder
boost::shared_mutex m_Lock
kt_double GetResolution() const
static void ComputeDimensions(const LocalizedRangeScanVector &rScans, kt_double resolution, kt_int32s &rWidth, kt_int32s &rHeight, Vector2< kt_double > &rOffset)
virtual Grid< kt_int32u > * GetCellPassCounts()
kt_double GetAngularResolution() const
const PointVectorDouble m_Points
Parameter< std::string > * m_pAuthor
void SetSensorPose(const Pose2 &rScanPose)
virtual kt_double RayCast(const Pose2 &rPose2, kt_double maxRange) const
void SetMinimumAngle(kt_double minimumAngle)
Pose2 GetSensorAt(const Pose2 &rPose) const
const std::string & GetName() const
void Add(const Vector2< kt_double > &rPoint)
kt_int32u GetColumns() const
void serialize(Archive &ar, const unsigned int version)
kt_int32s GetUniqueId() const
void SetMaximumRange(kt_double maximumRange)
Drive(const std::string &rName)
void SetOffsetPose(const Pose2 &rPose)
Sensor * GetSensorByName(const Name &rName)
void Add(const JntArray &src1, const JntArray &src2, JntArray &dest)
Parameter< std::string > * m_pDescription
virtual const std::string GetValueAsString() const
Rectangle2(const Rectangle2 &rOther)
kt_int32s * GetArrayPointer() const
Parameter< kt_double > * m_pAngularResolution
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
Pose3(const Vector3< kt_double > &rPosition, const karto::Quaternion &rOrientation)
const Pose3 & GetOdometricPose() const
const Size2< kt_int32s > & GetSize() const
Vector2< kt_int32s > IndexToGrid(kt_int32s index) const
const kt_objecttype ObjectType_Sensor
void ComputeOffsets(kt_int32u angleIndex, kt_double angle, const Pose2Vector &rLocalPoints, LocalizedRangeScan *pScan)
void SetPosition(const Vector2< T > &rPosition)
Pose2(const Pose2 &rOther)
const Size2< kt_int32s > GetSize() const
kt_double SquaredLength() const
const std::vector< kt_double > & GetAngles() const
kt_double SquaredLength() const
void serialize(Archive &ar, const unsigned int version)
void SetResolution(kt_double resolution)
kt_double & operator()(kt_int32u row, kt_int32u column)
kt_int32s GetHeight() const
virtual kt_bool AddScan(LocalizedRangeScan *pScan, kt_bool doUpdate=false)
std::vector< kt_double > RangeReadingsVector
void SetAngularResolution(kt_double angularResolution)
const kt_objecttype ObjectType_Camera
const kt_objecttype ObjectType_SensorData
Parameter< std::string > * m_pTitle
Pose3(const Pose3 &rOther)
void ComputeOffsets(LocalizedRangeScan *pScan, kt_double angleCenter, kt_double angleOffset, kt_double angleResolution)
const Quaternion & GetOrientation() const
virtual ~LaserRangeScan()
Parameter< kt_int32u > * m_pMinPassThrough
void SetScale(kt_double scale)
kt_double SquaredDistance(const Vector2 &rOther) const
void serialize(Archive &ar, const unsigned int version)
void serialize(Archive &ar, const unsigned int version)
const Size2< T > & GetSize() const
const std::string & GetDescription() const
kt_double GetRangeThreshold() const
Quaternion(const Quaternion &rQuaternion)
kt_double GetMaximumRange() const
kt_bool IsValidGridIndex(const Vector2< kt_int32s > &rGrid) const
void TraceLine(kt_int32s x0, kt_int32s y0, kt_int32s x1, kt_int32s y1, Functor *f=NULL)
virtual kt_int32s GridIndex(const Vector2< kt_int32s > &rGrid, kt_bool boundaryCheck=true) const
const Vector2< T > & GetPosition() const
virtual kt_bool Validate()
Quaternion(kt_double x, kt_double y, kt_double z, kt_double w)
Vector2< kt_double > m_Position
virtual ParameterManager * GetParameterManager()
const Name & GetSensorName() const
void SetMaximumAngle(kt_double maximumAngle)
std::vector< CustomData * > CustomDataVector
const T & Clip(const T &n, const T &minValue, const T &maxValue)
kt_bool IsLaserRangeFinder(Object *pObject)
const DataMap & GetData() const
void serialize(Archive &ar, const unsigned int version)
const ParameterVector & GetParameters() const
kt_double GetMinimumAngle() const
void SetIs360Laser(bool is_360_laser)
virtual void Resize(kt_int32s width, kt_int32s height)
SensorVector GetAllSensors()
ParameterManager * m_pParameterManager
#define KARTO_Object(name)
void SetOccupancyThreshold(kt_double thresh)
virtual ~AbstractParameter()
RangeReadingsVector GetRangeReadingsVector() const
virtual void Resize(kt_int32s width, kt_int32s height)
T * GetSensorByName(const Name &rName)
void serialize(Archive &ar, const unsigned int version)
void MakeFloor(const Vector2 &rOther)
kt_bool IsDatasetInfo(Object *pObject)
INLINE Rall1d< T, V, S > asin(const Rall1d< T, V, S > &x)
static Grid * CreateGrid(kt_int32s width, kt_int32s height, kt_double resolution)
void UnregisterSensor(Sensor *pSensor)
std::map< std::string, kt_int32s > EnumMap
void serialize(Archive &ar, const unsigned int version)
kt_bool GetIs360Laser() const
BOOST_CLASS_EXPORT_KEY(karto::NonCopyable)
Parameter< kt_double > * m_pRangeThreshold
virtual kt_bool RayTrace(const Vector2< kt_double > &rWorldFrom, const Vector2< kt_double > &rWorldTo, kt_bool isEndPointValid, kt_bool doUpdate=false)
void SetPosition(const Vector3< kt_double > &rPosition)
Grid< kt_int32u > * m_pCellPassCnt
virtual ~LocalizedRangeScanWithPoints()
void serialize(Archive &ar, const unsigned int version)
Parameter< kt_double > * m_pMinimumRange
std::vector< Pose2 > Pose2Vector
kt_bool IsInBounds(const Vector2< kt_double > &rPoint) const
virtual const std::string GetValueAsString() const =0
void SetOffset(const Vector2< kt_double > &rOffset)
void serialize(Archive &ar, const unsigned int version)
const Vector2< T > GetCenter() const
DatasetInfo * GetDatasetInfo()
const T & GetValue() const
virtual Parameter * Clone()
const std::string & GetAuthor() const
void ToEulerAngles(kt_double &rYaw, kt_double &rPitch, kt_double &rRoll) const
Rectangle2(const Vector2< T > &rPosition, const Size2< T > &rSize)
T * GetDataPointer(const Vector2< kt_int32s > &rGrid)
kt_double * m_pRangeReadings
T * GetDataPointer(const Vector2< kt_int32s > &rGrid) const
std::map< std::string, AbstractParameter * > m_ParameterLookup
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
virtual kt_bool IsFree(const Vector2< kt_int32s > &rPose) const
kt_bool InRange(const T &value, const T &a, const T &b)
kt_int32u GetRows() const
const kt_double KT_TOLERANCE
kt_double NormalizeAngle(kt_double angle)
void serialize(Archive &ar, const unsigned int version)
kt_int32u m_NumberOfRangeReadings
static SensorManager * GetInstance()
#define const_forEach(listtype, list)
Matrix(kt_int32u rows, kt_int32u columns)
ParameterVector m_Parameters
virtual const std::string GetValueAsString() const
static OccupancyGrid * CreateFromScans(const LocalizedRangeScanVector &rScans, kt_double resolution)
kt_bool InverseFast(Matrix3 &rkInverse, kt_double fTolerance=KT_TOLERANCE) const
CoordinateConverter * GetCoordinateConverter() const
Parameter< kt_double > * m_pMaximumRange
void SetSize(kt_int32u size)
GridIndexLookup(Grid< T > *pGrid)
kt_bool IsParameters(Object *pObject)
Vector2< kt_double > m_Offset
virtual void SetValueFromString(const std::string &rStringValue)=0
Pose2 GetReferencePose(kt_bool useBarycenter) const
BoundingBox2 GetBoundingBox() const
void SetOdometricPose(const Pose2 &rPose)
virtual void CreateFromScans(const LocalizedRangeScanVector &rScans)
void Validate(const std::string &rName)
Parameter< kt_bool > * m_pIs360Laser
kt_double GetMaximumAngle() const
void serialize(Archive &ar, const unsigned int version)
static LaserRangeFinder * CreateLaserRangeFinder(LaserRangeFinderType type, const Name &rName)
Vector2< kt_double > m_Minimum
kt_double Distance(const Vector2 &rOther) const
const kt_objecttype ObjectType_DrivePose
DatasetInfo * m_pDatasetInfo
kt_double GetTime() const
const std::string & GetTitle() const
Vector2< kt_double > GridToWorld(const Vector2< kt_int32s > &rGrid, kt_bool flipY=false) const
void SetName(const std::string &rName)
Size2< kt_double > GetSize() const
virtual ~GridIndexLookup()
Pose2 GetCorrectedAt(const Pose2 &sPose) const
Computes the pose of the robot if the sensor were at the given pose.
Vector2< kt_double > GridToWorld(const Vector2< kt_int32s > &rGrid, kt_bool flipY=false) const
T GetValue(const Vector2< kt_int32s > &rGrid) const
virtual void SetValueFromString(const std::string &rStringValue)
virtual ~LocalizedRangeScan()
LookupArray ** m_ppLookupArray
void serialize(Archive &ar, const unsigned int version)
void SetPosition(const Vector2< kt_double > &rPosition)
INLINE Rall1d< T, V, S > abs(const Rall1d< T, V, S > &x)
void SetCorrectedPoseAndUpdate(const Pose2 &rPose)
void Parse(const std::string &rName)
void SetSize(kt_int32u size)
void SetMinimumRange(kt_double minimumRange)
const Name & GetName() const
CustomDataVector m_CustomData
void SetRangeReadings(const RangeReadingsVector &rRangeReadings)
BoundingBox2 GetBoundingBox() const
const std::string & GetName() const
virtual Parameter< kt_int32s > * Clone()
void SetCorrectedPose(const Pose2 &rPose)
Parameter< std::string > * m_pCopyright
virtual kt_bool Process(karto::Object *)
Parameter< kt_double > * m_pMaximumAngle
INLINE Rall1d< T, V, S > atan2(const Rall1d< T, V, S > &y, const Rall1d< T, V, S > &x)
Rectangle2(T x, T y, T width, T height)
void MakeFloor(const Vector3 &rOther)
OccupancyGrid * Clone() const
void SetOdometricPose(const Pose3 &rPose)
const std::string & GetScope() const
kt_bool IsSensor(Object *pObject)
const Pose2 & GetOffsetPose() const
const kt_double & operator()(kt_int32u row, kt_int32u column) const
PointVectorDouble m_PointReadings
void SetTime(kt_double time)
OccupancyGrid * m_pOccupancyGrid
void serialize(Archive &ar, const unsigned int version)
kt_bool DoubleEqual(kt_double a, kt_double b)
Pose3(const Pose2 &rPose)
void SetHeading(kt_double heading)
CoordinateConverter * m_pCoordinateConverter
const std::string & GetCopyright() const
void serialize(Archive &ar, const unsigned int version)
void Add(Object *pObject, kt_bool overrideSensorName=false)
const BoundingBox2 & GetBoundingBox() const
SensorManagerMap m_Sensors
void RegisterSensor(Sensor *pSensor, kt_bool override=false)
const ParameterVector & GetParameterVector() const
T * GetDataPointer() const
const kt_objecttype ObjectType_Parameters
void SetIsDirty(kt_bool &rIsDirty)
OccupancyGrid(kt_int32s width, kt_int32s height, const Vector2< kt_double > &rOffset, kt_double resolution)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
const std::string & GetDescription() const
const Vector2< kt_double > & GetMinimum() const
const LookupArray * GetLookupArray(kt_int32u index) const
kt_double GetMinimumRange() const
void RemoveData(LocalizedRangeScan *scan)
void SetMaximum(const Vector2< kt_double > &rMaximum)
void serialize(Archive &ar, const unsigned int version)
const ObjectVector & GetLasers() const
std::ostream & operator<<(std::ostream &rStream, Exception &rException)
void SetOrientation(const Quaternion &rOrientation)
Grid< kt_int32u > * m_pCellHitsCnt
const Vector2< kt_double > & GetMaximum() const
virtual Grid< kt_int32u > * GetCellHitsCounts()
const std::string & GetErrorMessage() const
const kt_objecttype ObjectType_LaserRangeScan
LocalizedRangeScan(const Name &rSensorName, const RangeReadingsVector &rReadings)
std::vector< AbstractParameter * > ParameterVector
void RangeCheck(kt_int32u row, kt_int32u column) const
ParameterEnum(const std::string &rName, kt_int32s value, ParameterManager *pParameterManger=NULL)
std::map< Name, Sensor * > m_SensorNameLookup
#define const_forEachAs(listtype, list, iter)
void serialize(Archive &ar, const unsigned int version)
const kt_objecttype ObjectType_LocalizedRangeScanWithPoints
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
virtual kt_bool Validate(SensorData *pSensorData)
void serialize(Archive &ar, const unsigned int version)
const CustomDataVector & GetCustomData() const
CellUpdater(OccupancyGrid *pGrid)
kt_bool IsUpTo(const T &value, const T &maximum)
std::string ToString() const
Exception(const Exception &rException)
std::map< Name, Sensor * > SensorManagerMap
void SetPointReadings(PointVectorDouble &points, kt_bool setFiltered=false)
kt_bool IsLocalizedRangeScan(Object *pObject)
virtual void SetValueFromString(const std::string &rStringValue)
const kt_objecttype ObjectType_Drive
Grid(kt_int32s width, kt_int32s height)
std::vector< LocalizedRangeScan * > LocalizedRangeScanVector
void AddCustomData(CustomData *pCustomData)
void serialize(Archive &ar, const unsigned int version)
void SetMinPassThrough(kt_int32u count)
Vector3< kt_double > m_Position
kt_double Transform(kt_double value)
std::map< int, LocalizedRangeScan * > LocalizedRangeScanMap
void serialize(Archive &ar, const unsigned int version)
kt_double GetHeading() const
void FromAxisAngle(kt_double x, kt_double y, kt_double z, const kt_double radians)
void MakeCeil(const Vector3 &rOther)