-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1456 from tier4/feature/shoulder_routing_graph
Add new routing graph for road shoulder
- Loading branch information
Showing
7 changed files
with
161 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
simulation/traffic_simulator/include/traffic_simulator/hdmap_utils/traffic_rules.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2015 TIER IV, Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef TRAFFIC_SIMULATOR__HDMAP_UTILS__TRAFFIC_RULES_HPP_ | ||
#define TRAFFIC_SIMULATOR__HDMAP_UTILS__TRAFFIC_RULES_HPP_ | ||
|
||
#include <lanelet2_traffic_rules/GermanTrafficRules.h> | ||
|
||
namespace hdmap_utils | ||
{ | ||
struct Locations | ||
{ | ||
/// @note DIRTY HACK!! Originally, a location code should be an ISO country code. | ||
/// @sa https://github.com/fzi-forschungszentrum-informatik/Lanelet2/blob/507033b82d9915f086f2539d56c3b62e71802438/lanelet2_traffic_rules/include/lanelet2_traffic_rules/TrafficRules.h#L97 | ||
static constexpr char RoadShoulderPassableGermany[] = "de_road_shoulder_passable"; | ||
}; | ||
|
||
class GermanRoadShoulderPassableVehicle : public lanelet::traffic_rules::GermanVehicle | ||
{ | ||
public: | ||
using lanelet::traffic_rules::GermanVehicle::GermanVehicle; | ||
|
||
protected: | ||
/// @note this function overrides and adds road shoulder handling to GenericTrafficRules::canPass | ||
lanelet::Optional<bool> canPass( | ||
const std::string & type, const std::string & /*location*/) const override | ||
{ | ||
using lanelet::AttributeValueString; | ||
using lanelet::Participants; | ||
const static std::map<std::string, std::vector<std::string>> participants_map{ | ||
// clang-format off | ||
{"", {Participants::Vehicle}}, | ||
{AttributeValueString::Road, {Participants::Vehicle, Participants::Bicycle}}, | ||
{"road_shoulder", {Participants::Vehicle, Participants::Bicycle}}, // add road_shoulder | ||
{AttributeValueString::Highway, {Participants::Vehicle}}, | ||
{AttributeValueString::BicycleLane, {Participants::Bicycle}}, | ||
{AttributeValueString::PlayStreet, {Participants::Pedestrian, Participants::Bicycle, Participants::Vehicle}}, | ||
{AttributeValueString::EmergencyLane, {Participants::VehicleEmergency}}, | ||
{AttributeValueString::Exit, {Participants::Pedestrian, Participants::Bicycle, Participants::Vehicle}}, | ||
{AttributeValueString::Walkway, {Participants::Pedestrian}}, | ||
{AttributeValueString::Crosswalk, {Participants::Pedestrian}}, | ||
{AttributeValueString::Stairs, {Participants::Pedestrian}}, | ||
{AttributeValueString::SharedWalkway, {Participants::Pedestrian, Participants::Bicycle}} | ||
// clang-format on | ||
}; | ||
auto participants = participants_map.find(type); | ||
if (participants == participants_map.end()) { | ||
return {}; | ||
} | ||
|
||
auto startsWith = [](const std::string & str, const std::string & substr) { | ||
return str.compare(0, substr.size(), substr) == 0; | ||
}; | ||
return lanelet::utils::anyOf(participants->second, [this, startsWith](auto & participant) { | ||
return startsWith(this->participant(), participant); | ||
}); | ||
} | ||
}; | ||
} // namespace hdmap_utils | ||
#endif // TRAFFIC_SIMULATOR__HDMAP_UTILS__TRAFFIC_RULES_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
simulation/traffic_simulator/src/hdmap_utils/traffic_rules.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2015 TIER IV, Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <lanelet2_traffic_rules/TrafficRulesFactory.h> | ||
|
||
#include <traffic_simulator/hdmap_utils/traffic_rules.hpp> | ||
|
||
lanelet::traffic_rules::RegisterTrafficRules<hdmap_utils::GermanRoadShoulderPassableVehicle> | ||
germanRoadShoulderPassableVehicleRules( | ||
hdmap_utils::Locations::RoadShoulderPassableGermany, lanelet::Participants::Vehicle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters