11 std::string exampleMapPath = std::string(PKG_DIR) +
"/../lanelet2_maps/res/mapping_example.osm";
13 template <
typename NumberT>
14 void assertNear(NumberT number1, NumberT number2, NumberT maxDifference) {
15 assert(std::abs(number1 - number2) < maxDifference);
18 template <
typename MatchVectorT>
19 std::string toString(
const MatchVectorT& matchVector) {
21 for (
auto& match : matchVector) {
22 out += std::to_string(match.lanelet.id());
23 if (match.lanelet.inverted()) {
34 hullPoints.reserve(relativeHull.size());
35 for (
const auto& hullPt : relativeHull) {
36 hullPoints.push_back(pose * hullPt);
46 MapAndObject getSampleMapAndObject() {
53 obj.
pose.translation() = map->pointLayer.get(41656).basicPoint2d();
54 obj.
pose.linear() = Eigen::Rotation2D<double>(150. / 180. * M_PI).matrix();
61 return MapAndObject{map, obj};
81 MapAndObject mao = getSampleMapAndObject();
84 assert(map->laneletLayer.exists(42440));
90 MapAndObject mao = getSampleMapAndObject();
98 for (
size_t i = 1; i < matches.size(); i++) {
99 assert(matches.at(i).distance >= matches.at(i - 1).distance);
103 assert(14ul == matches.size());
104 assertNear(0.69, matches.at(8).distance, 0.1);
105 assert(45330 == matches.at(8).lanelet.id());
106 assertNear(0.69, matches.at(9).distance, 0.1);
107 assert(45330 == matches.at(9).lanelet.id());
113 assert(8ul == compliantMatches.size());
119 MapAndObject mao = getSampleMapAndObject();
128 for (
size_t i = 1; i < matches.size(); i++) {
129 assert(matches.at(i).mahalanobisDistSq >= matches.at(i - 1).mahalanobisDistSq);
133 assertNear(0.288177, matches.at(0).mahalanobisDistSq, 0.001);
134 assert(45334 == matches.at(0).lanelet.id());
135 assert(!matches.at(0).lanelet.inverted());
136 assert(14ul == matches.size());
138 assert(14ul == matches.size());
139 assert(
"45334 45356inv 45358inv 45328inv 45332 45344 45330 45344inv 45330inv 45332inv 45328 45356 45358 45334inv " ==
149 assert(
"45334 45356inv 45358inv 45332 45330 45328 45356 45358 " == toString(compliantMatches));
156 MapAndObject mao = getSampleMapAndObject();
163 assert(
isCloseTo(map->laneletLayer, obj, 4.));
167 assert(
isWithin(map->laneletLayer, obj));
172 objWithEmptyHull.
pose.translation() = map->pointLayer.get(41656).basicPoint2d();
static constexpr char Germany[]
std::vector< LaneletMatchProbabilistic > getProbabilisticMatches(LaneletMap &map, const ObjectWithCovariance2d &obj, double maxDist)
static constexpr const char Vehicle[]
void part2deterministicMatching()
std::shared_ptr< LaneletMap > LaneletMapPtr
Eigen::Transform< double, 2, Eigen::Isometry, Eigen::DontAlign > Pose2d
MatchVectorT removeNonRuleCompliantMatches(const MatchVectorT &matches, const lanelet::traffic_rules::TrafficRulesPtr &trafficRulesPtr)
static TrafficRulesUPtr create(const std::string &location, const std::string &participant, TrafficRules::Configuration configuration=TrafficRules::Configuration())
void part4matchingUtils()
std::unique_ptr< LaneletMap > load(const std::string &filename, const Origin &origin=Origin::defaultOrigin(), ErrorMessages *errors=nullptr, const io::Configuration ¶ms=io::Configuration())
std::vector< LaneletMatch > getDeterministicMatches(LaneletMap &map, const Object2d &obj, double maxDist)
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > BasicPoint2d
void part3probabilisticMatching()
PositionCovariance2d positionCovariance
bool isCloseTo(const LayerT &map, const Object2d &obj, double maxDist)
bool isWithin(const LayerT &map, const Object2d &obj)
std::shared_ptr< TrafficRules > TrafficRulesPtr