@@ -1324,98 +1324,6 @@ lanelet::ConstLanelet RouteHandler::getMostLeftLanelet(
1324
1324
return lanelet;
1325
1325
}
1326
1326
1327
- lanelet::ConstLineString3d RouteHandler::getRightMostSameDirectionLinestring (
1328
- const lanelet::ConstLanelet & lanelet, const bool enable_same_root) const noexcept
1329
- {
1330
- // recursively compute the width of the lanes
1331
- const auto & same = getRightLanelet (lanelet, enable_same_root);
1332
-
1333
- if (same) {
1334
- return getRightMostSameDirectionLinestring (same.value (), enable_same_root);
1335
- }
1336
-
1337
- return lanelet.rightBound ();
1338
- }
1339
-
1340
- lanelet::ConstLineString3d RouteHandler::getRightMostLinestring (
1341
- const lanelet::ConstLanelet & lanelet, const bool enable_same_root) const noexcept
1342
- {
1343
- const auto & same = getRightLanelet (lanelet, enable_same_root);
1344
- const auto & opposite = getRightOppositeLanelets (lanelet);
1345
- if (!same && opposite.empty ()) {
1346
- return lanelet.rightBound ();
1347
- }
1348
-
1349
- if (same) {
1350
- return getRightMostLinestring (same.value (), enable_same_root);
1351
- }
1352
-
1353
- if (!opposite.empty ()) {
1354
- return getLeftMostLinestring (lanelet::ConstLanelet (opposite.front ()), false );
1355
- }
1356
-
1357
- return lanelet.rightBound ();
1358
- }
1359
-
1360
- lanelet::ConstLineString3d RouteHandler::getLeftMostSameDirectionLinestring (
1361
- const lanelet::ConstLanelet & lanelet, const bool enable_same_root) const noexcept
1362
- {
1363
- // recursively compute the width of the lanes
1364
- const auto & same = getLeftLanelet (lanelet, enable_same_root);
1365
-
1366
- if (same) {
1367
- return getLeftMostSameDirectionLinestring (same.value (), enable_same_root);
1368
- }
1369
-
1370
- return lanelet.leftBound ();
1371
- }
1372
-
1373
- lanelet::ConstLineString3d RouteHandler::getLeftMostLinestring (
1374
- const lanelet::ConstLanelet & lanelet, const bool enable_same_root) const noexcept
1375
- {
1376
- // recursively compute the width of the lanes
1377
- const auto & same = getLeftLanelet (lanelet, enable_same_root);
1378
- const auto & opposite = getLeftOppositeLanelets (lanelet);
1379
- if (!same && opposite.empty ()) {
1380
- return lanelet.leftBound ();
1381
- }
1382
-
1383
- if (same) {
1384
- return getLeftMostLinestring (same.value (), enable_same_root);
1385
- }
1386
-
1387
- if (!opposite.empty ()) {
1388
- return getRightMostLinestring (lanelet::ConstLanelet (opposite.front ()), false );
1389
- }
1390
-
1391
- return lanelet.leftBound ();
1392
- }
1393
-
1394
- lanelet::ConstLineStrings3d RouteHandler::getFurthestLinestring (
1395
- const lanelet::ConstLanelet & lanelet, bool is_right, bool is_left, bool is_opposite,
1396
- bool enable_same_root) const noexcept
1397
- {
1398
- lanelet::ConstLineStrings3d linestrings;
1399
- linestrings.reserve (2 );
1400
-
1401
- if (is_right && is_opposite) {
1402
- linestrings.emplace_back (getRightMostLinestring (lanelet, enable_same_root));
1403
- } else if (is_right && !is_opposite) {
1404
- linestrings.emplace_back (getRightMostSameDirectionLinestring (lanelet, enable_same_root));
1405
- } else {
1406
- linestrings.emplace_back (lanelet.rightBound ());
1407
- }
1408
-
1409
- if (is_left && is_opposite) {
1410
- linestrings.emplace_back (getLeftMostLinestring (lanelet, enable_same_root));
1411
- } else if (is_left && !is_opposite) {
1412
- linestrings.emplace_back (getLeftMostSameDirectionLinestring (lanelet, enable_same_root));
1413
- } else {
1414
- linestrings.emplace_back (lanelet.leftBound ());
1415
- }
1416
- return linestrings;
1417
- }
1418
-
1419
1327
std::vector<lanelet::ConstLanelets> RouteHandler::getPrecedingLaneletSequence (
1420
1328
const lanelet::ConstLanelet & lanelet, const double length,
1421
1329
const lanelet::ConstLanelets & exclude_lanelets) const
@@ -1486,46 +1394,6 @@ std::optional<lanelet::ConstLanelet> RouteHandler::getLaneChangeTargetExceptPref
1486
1394
return std::nullopt;
1487
1395
}
1488
1396
1489
- bool RouteHandler::getRightLaneChangeTargetExceptPreferredLane (
1490
- const lanelet::ConstLanelets & lanelets, lanelet::ConstLanelet * target_lanelet) const
1491
- {
1492
- for (const auto & lanelet : lanelets) {
1493
- const int num = getNumLaneToPreferredLane (lanelet);
1494
-
1495
- // Get right lanelet if preferred lane is on the left
1496
- if (num >= 0 ) {
1497
- if (!!routing_graph_ptr_->right (lanelet)) {
1498
- const auto right_lanelet = routing_graph_ptr_->right (lanelet);
1499
- *target_lanelet = right_lanelet.value ();
1500
- return true ;
1501
- }
1502
- }
1503
- }
1504
-
1505
- *target_lanelet = lanelets.front ();
1506
- return false ;
1507
- }
1508
-
1509
- bool RouteHandler::getLeftLaneChangeTargetExceptPreferredLane (
1510
- const lanelet::ConstLanelets & lanelets, lanelet::ConstLanelet * target_lanelet) const
1511
- {
1512
- for (const auto & lanelet : lanelets) {
1513
- const int num = getNumLaneToPreferredLane (lanelet);
1514
-
1515
- // Get left lanelet if preferred lane is on the right
1516
- if (num <= 0 ) {
1517
- if (!!routing_graph_ptr_->left (lanelet)) {
1518
- const auto left_lanelet = routing_graph_ptr_->left (lanelet);
1519
- *target_lanelet = left_lanelet.value ();
1520
- return true ;
1521
- }
1522
- }
1523
- }
1524
-
1525
- *target_lanelet = lanelets.front ();
1526
- return false ;
1527
- }
1528
-
1529
1397
std::optional<lanelet::ConstLanelet> RouteHandler::getPullOverTarget (const Pose & goal_pose) const
1530
1398
{
1531
1399
const lanelet::BasicPoint2d p (goal_pose.position .x , goal_pose.position .y );
@@ -1589,13 +1457,6 @@ int RouteHandler::getNumLaneToPreferredLane(
1589
1457
return 0 ; // TODO(Horibe) check if return 0 is appropriate.
1590
1458
}
1591
1459
1592
- double RouteHandler::getTotalLateralDistanceToPreferredLane (
1593
- const lanelet::ConstLanelet & lanelet, const Direction direction) const
1594
- {
1595
- const auto intervals = getLateralIntervalsToPreferredLane (lanelet, direction);
1596
- return std::accumulate (intervals.begin (), intervals.end (), 0 );
1597
- }
1598
-
1599
1460
std::vector<double > RouteHandler::getLateralIntervalsToPreferredLane (
1600
1461
const lanelet::ConstLanelet & lanelet, const Direction direction) const
1601
1462
{
@@ -1650,30 +1511,6 @@ std::vector<double> RouteHandler::getLateralIntervalsToPreferredLane(
1650
1511
return {};
1651
1512
}
1652
1513
1653
- bool RouteHandler::isPreferredLane (const lanelet::ConstLanelet & lanelet) const
1654
- {
1655
- return exists (preferred_lanelets_, lanelet);
1656
- }
1657
-
1658
- bool RouteHandler::isInPreferredLane (const PoseStamped & pose) const
1659
- {
1660
- lanelet::ConstLanelet lanelet;
1661
- if (!getClosestLaneletWithinRoute (pose.pose , &lanelet)) {
1662
- return false ;
1663
- }
1664
- return exists (preferred_lanelets_, lanelet);
1665
- }
1666
-
1667
- bool RouteHandler::isInTargetLane (
1668
- const PoseStamped & pose, const lanelet::ConstLanelets & target) const
1669
- {
1670
- lanelet::ConstLanelet lanelet;
1671
- if (!getClosestLaneletWithinRoute (pose.pose , &lanelet)) {
1672
- return false ;
1673
- }
1674
- return exists (target, lanelet);
1675
- }
1676
-
1677
1514
PathWithLaneId RouteHandler::getCenterLinePath (
1678
1515
const lanelet::ConstLanelets & lanelet_sequence, const double s_start, const double s_end,
1679
1516
bool use_exact) const
@@ -1749,139 +1586,6 @@ PathWithLaneId RouteHandler::getCenterLinePath(
1749
1586
return reference_path;
1750
1587
}
1751
1588
1752
- PathWithLaneId RouteHandler::updatePathTwist (const PathWithLaneId & path) const
1753
- {
1754
- PathWithLaneId updated_path = path;
1755
- for (auto & point : updated_path.points ) {
1756
- const auto id = point.lane_ids .at (0 );
1757
- const auto llt = lanelet_map_ptr_->laneletLayer .get (id);
1758
- const auto limit = traffic_rules_ptr_->speedLimit (llt);
1759
- point.point .longitudinal_velocity_mps = static_cast <float >(limit.speedLimit .value ());
1760
- }
1761
- return updated_path;
1762
- }
1763
-
1764
- lanelet::ConstLanelets RouteHandler::getLaneChangeTargetLanes (const Pose & pose) const
1765
- {
1766
- lanelet::ConstLanelet lanelet;
1767
- lanelet::ConstLanelets target_lanelets;
1768
- if (!getClosestLaneletWithinRoute (pose, &lanelet)) {
1769
- return target_lanelets;
1770
- }
1771
-
1772
- const int num = getNumLaneToPreferredLane (lanelet);
1773
- if (num < 0 ) {
1774
- const auto right_lanelet = (!!routing_graph_ptr_->right (lanelet))
1775
- ? routing_graph_ptr_->right (lanelet)
1776
- : routing_graph_ptr_->adjacentRight (lanelet);
1777
- target_lanelets = getLaneletSequence (right_lanelet.value ());
1778
- }
1779
- if (num > 0 ) {
1780
- const auto left_lanelet = (!!routing_graph_ptr_->left (lanelet))
1781
- ? routing_graph_ptr_->left (lanelet)
1782
- : routing_graph_ptr_->adjacentLeft (lanelet);
1783
- target_lanelets = getLaneletSequence (left_lanelet.value ());
1784
- }
1785
- return target_lanelets;
1786
- }
1787
-
1788
- double RouteHandler::getLaneChangeableDistance (
1789
- const Pose & current_pose, const Direction & direction) const
1790
- {
1791
- lanelet::ConstLanelet current_lane;
1792
- if (!getClosestLaneletWithinRoute (current_pose, ¤t_lane)) {
1793
- return 0 ;
1794
- }
1795
-
1796
- // get lanelets after current lane
1797
- auto lanelet_sequence = getLaneletSequenceAfter (current_lane);
1798
- lanelet_sequence.insert (lanelet_sequence.begin (), current_lane);
1799
-
1800
- double accumulated_distance = 0 ;
1801
- for (const auto & lane : lanelet_sequence) {
1802
- lanelet::ConstLanelet target_lane;
1803
- if (direction == Direction::RIGHT) {
1804
- if (!getRightLaneletWithinRoute (lane, &target_lane)) {
1805
- break ;
1806
- }
1807
- }
1808
- if (direction == Direction::LEFT) {
1809
- if (!getLeftLaneletWithinRoute (lane, &target_lane)) {
1810
- break ;
1811
- }
1812
- }
1813
- double lane_length = lanelet::utils::getLaneletLength3d (lane);
1814
-
1815
- // overwrite goal because lane change must be finished before reaching goal
1816
- if (isInGoalRouteSection (lane)) {
1817
- const auto goal_position = lanelet::utils::conversion::toLaneletPoint (getGoalPose ().position );
1818
- const auto goal_arc_coordinates = lanelet::geometry::toArcCoordinates (
1819
- lanelet::utils::to2D (lane.centerline ()), lanelet::utils::to2D (goal_position).basicPoint ());
1820
- lane_length = std::min (goal_arc_coordinates.length , lane_length);
1821
- }
1822
-
1823
- // subtract distance up to current position for first lane
1824
- if (lane == current_lane) {
1825
- const auto current_position =
1826
- lanelet::utils::conversion::toLaneletPoint (current_pose.position );
1827
- const auto arc_coordinate = lanelet::geometry::toArcCoordinates (
1828
- lanelet::utils::to2D (lane.centerline ()),
1829
- lanelet::utils::to2D (current_position).basicPoint ());
1830
- lane_length = std::max (lane_length - arc_coordinate.length , 0.0 );
1831
- }
1832
- accumulated_distance += lane_length;
1833
- }
1834
- return accumulated_distance;
1835
- }
1836
-
1837
- lanelet::ConstLanelets RouteHandler::getCheckTargetLanesFromPath (
1838
- const PathWithLaneId & path, const lanelet::ConstLanelets & target_lanes,
1839
- const double check_length) const
1840
- {
1841
- std::vector<int64_t > target_lane_ids;
1842
- target_lane_ids.reserve (target_lanes.size ());
1843
- for (const auto & llt : target_lanes) {
1844
- target_lane_ids.push_back (llt.id ());
1845
- }
1846
-
1847
- // find first lanelet in target lanes along path
1848
- int64_t root_lane_id = lanelet::InvalId;
1849
- for (const auto & point : path.points ) {
1850
- for (const auto & lane_id : point.lane_ids ) {
1851
- if (exists (target_lane_ids, lane_id)) {
1852
- root_lane_id = lane_id;
1853
- }
1854
- }
1855
- }
1856
- // return emtpy lane if failed to find root lane_id
1857
- if (root_lane_id == lanelet::InvalId) {
1858
- return target_lanes;
1859
- }
1860
- lanelet::ConstLanelet root_lanelet;
1861
- for (const auto & llt : target_lanes) {
1862
- if (llt.id () == root_lane_id) {
1863
- root_lanelet = llt;
1864
- }
1865
- }
1866
-
1867
- const auto sequences = lanelet::utils::query::getPrecedingLaneletSequences (
1868
- routing_graph_ptr_, root_lanelet, check_length);
1869
- lanelet::ConstLanelets check_lanelets;
1870
- for (const auto & sequence : sequences) {
1871
- for (const auto & llt : sequence) {
1872
- if (!lanelet::utils::contains (check_lanelets, llt)) {
1873
- check_lanelets.push_back (llt);
1874
- }
1875
- }
1876
- }
1877
- for (const auto & llt : target_lanes) {
1878
- if (!lanelet::utils::contains (check_lanelets, llt)) {
1879
- check_lanelets.push_back (llt);
1880
- }
1881
- }
1882
- return check_lanelets;
1883
- }
1884
-
1885
1589
bool RouteHandler::isMapMsgReady () const
1886
1590
{
1887
1591
return is_map_msg_ready_;
@@ -1908,41 +1612,6 @@ lanelet::LaneletMapPtr RouteHandler::getLaneletMapPtr() const
1908
1612
return lanelet_map_ptr_;
1909
1613
}
1910
1614
1911
- lanelet::routing::RelationType RouteHandler::getRelation (
1912
- const lanelet::ConstLanelet & prev_lane, const lanelet::ConstLanelet & next_lane) const
1913
- {
1914
- if (prev_lane == next_lane) {
1915
- return lanelet::routing::RelationType::None;
1916
- }
1917
- const auto & relation = routing_graph_ptr_->routingRelation (prev_lane, next_lane);
1918
- if (relation ) {
1919
- return relation .value ();
1920
- }
1921
-
1922
- // check if lane change extends across multiple lanes
1923
- const auto shortest_path = routing_graph_ptr_->shortestPath (prev_lane, next_lane);
1924
- if (shortest_path) {
1925
- auto prev_llt = shortest_path->front ();
1926
- for (const auto & llt : shortest_path.value ()) {
1927
- if (prev_llt == llt) {
1928
- continue ;
1929
- }
1930
- const auto & relation = routing_graph_ptr_->routingRelation (prev_llt, llt);
1931
- if (!relation ) {
1932
- continue ;
1933
- }
1934
- if (
1935
- relation .value () == lanelet::routing::RelationType::Left ||
1936
- relation .value () == lanelet::routing::RelationType::Right) {
1937
- return relation .value ();
1938
- }
1939
- prev_llt = llt;
1940
- }
1941
- }
1942
-
1943
- return lanelet::routing::RelationType::None;
1944
- }
1945
-
1946
1615
bool RouteHandler::isShoulderLanelet (const lanelet::ConstLanelet & lanelet) const
1947
1616
{
1948
1617
return lanelet.hasAttribute (lanelet::AttributeName::Subtype) &&
@@ -2100,33 +1769,6 @@ lanelet::ConstLanelets RouteHandler::getNeighborsWithinRoute(
2100
1769
return neighbors_within_route;
2101
1770
}
2102
1771
2103
- std::vector<lanelet::ConstLanelets> RouteHandler::getLaneSection (
2104
- const lanelet::ConstLanelet & lanelet) const
2105
- {
2106
- const lanelet::ConstLanelets neighbors = getNeighborsWithinRoute (lanelet);
2107
- std::vector<lanelet::ConstLanelets> lane_section;
2108
- lane_section.reserve (neighbors.size ());
2109
- for (const auto & llt : neighbors) {
2110
- lane_section.push_back (getLaneSequence (llt));
2111
- }
2112
- return lane_section;
2113
- }
2114
-
2115
- lanelet::ConstLanelets RouteHandler::getNextLaneSequence (
2116
- const lanelet::ConstLanelets & lane_sequence) const
2117
- {
2118
- lanelet::ConstLanelets next_lane_sequence;
2119
- if (lane_sequence.empty ()) {
2120
- return next_lane_sequence;
2121
- }
2122
- const auto & final_lanelet = lane_sequence.back ();
2123
- lanelet::ConstLanelet next_lanelet;
2124
- if (!getNextLaneletWithinRoute (final_lanelet, &next_lanelet)) {
2125
- return next_lane_sequence;
2126
- }
2127
- return getLaneSequence (next_lanelet);
2128
- }
2129
-
2130
1772
bool RouteHandler::planPathLaneletsBetweenCheckpoints (
2131
1773
const Pose & start_checkpoint, const Pose & goal_checkpoint,
2132
1774
lanelet::ConstLanelets * path_lanelets, const bool consider_no_drivable_lanes) const
0 commit comments