Skip to content

Commit 705223b

Browse files
committed
enable set route lanelet in DoNothingPlugin
Signed-off-by: Masaya Kataoka <[email protected]>
1 parent 281c44f commit 705223b

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

simulation/do_nothing_plugin/include/do_nothing_plugin/plugin.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public: \
5353
DEFINE_GETTER_SETTER(OtherEntityStatus, EntityStatusDict)
5454
DEFINE_GETTER_SETTER(PedestrianParameters, traffic_simulator_msgs::msg::PedestrianParameters)
5555
DEFINE_GETTER_SETTER(ReferenceTrajectory, std::shared_ptr<math::geometry::CatmullRomSpline>)
56-
DEFINE_GETTER_SETTER(RouteLanelets, lanelet::Ids)
5756
DEFINE_GETTER_SETTER(TargetSpeed, std::optional<double>)
5857
DEFINE_GETTER_SETTER(TrafficLights, std::shared_ptr<traffic_simulator::TrafficLightsBase>)
5958
DEFINE_GETTER_SETTER(VehicleParameters, traffic_simulator_msgs::msg::VehicleParameters)
@@ -77,6 +76,7 @@ private: \
7776
DEFINE_GETTER_SETTER(HdMapUtils, std::shared_ptr<hdmap_utils::HdMapUtils>, hdmap_utils_)
7877
DEFINE_GETTER_SETTER(PolylineTrajectory, std::shared_ptr<traffic_simulator_msgs::msg::PolylineTrajectory>, polyline_trajectory)
7978
DEFINE_GETTER_SETTER(Request, traffic_simulator::behavior::Request, request)
79+
DEFINE_GETTER_SETTER(RouteLanelets, lanelet::Ids, route_lanelets_)
8080
DEFINE_GETTER_SETTER(StepTime, double, step_time_)
8181
// clang-format on
8282
#undef DEFINE_GETTER_SETTER

simulation/traffic_simulator/src/entity/pedestrian_entity.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ auto PedestrianEntity::getRouteLanelets(double horizon) -> lanelet::Ids
129129
if (const auto canonicalized_lanelet_pose = status_->getCanonicalizedLaneletPose()) {
130130
return route_planner_.getRouteLanelets(canonicalized_lanelet_pose.value(), horizon);
131131
} else {
132+
if (
133+
const auto canonicalized_lanelet_pose = pose::toCanonicalizedLaneletPose(
134+
status_->getMapPose(), getBoundingBox(), route_planner_.getWholeRouteLanelets(), true,
135+
getDefaultMatchingDistanceForLaneletPoseCalculation())) {
136+
return route_planner_.getRouteLanelets(canonicalized_lanelet_pose.value(), horizon);
137+
}
132138
return {};
133139
}
134140
}
@@ -288,15 +294,6 @@ auto PedestrianEntity::onUpdate(const double current_time, const double step_tim
288294
/// @note CanonicalizedEntityStatus is updated here, it is not skipped even if isAtEndOfLanelets return true
289295
behavior_plugin_ptr_->update(current_time, step_time);
290296

291-
/// Try lane matching if the output of behavior plugin is not on lane.
292-
if (
293-
const auto canonicalized_lanelet_pose = pose::toCanonicalizedLaneletPose(
294-
status_->getMapPose(), getBoundingBox(), route_planner_.getWholeRouteLanelets(), true,
295-
getDefaultMatchingDistanceForLaneletPoseCalculation())) {
296-
status_->set(
297-
CanonicalizedEntityStatus(static_cast<EntityStatus>(*status_), canonicalized_lanelet_pose));
298-
}
299-
300297
if (const auto canonicalized_lanelet_pose = status_->getCanonicalizedLaneletPose()) {
301298
if (pose::isAtEndOfLanelets(canonicalized_lanelet_pose.value(), hdmap_utils_ptr_)) {
302299
stopAtCurrentPosition();

simulation/traffic_simulator/src/entity/vehicle_entity.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ auto VehicleEntity::getRouteLanelets(double horizon) -> lanelet::Ids
116116
if (const auto canonicalized_lanelet_pose = status_->getCanonicalizedLaneletPose()) {
117117
return route_planner_.getRouteLanelets(canonicalized_lanelet_pose.value(), horizon);
118118
} else {
119+
if (
120+
const auto canonicalized_lanelet_pose = pose::toCanonicalizedLaneletPose(
121+
status_->getMapPose(), getBoundingBox(), route_planner_.getWholeRouteLanelets(), true,
122+
getDefaultMatchingDistanceForLaneletPoseCalculation())) {
123+
return route_planner_.getRouteLanelets(canonicalized_lanelet_pose.value(), horizon);
124+
}
119125
return {};
120126
}
121127
}
@@ -161,15 +167,6 @@ auto VehicleEntity::onUpdate(const double current_time, const double step_time)
161167
/// @note CanonicalizedEntityStatus is updated here, it is not skipped even if isAtEndOfLanelets return true
162168
behavior_plugin_ptr_->update(current_time, step_time);
163169

164-
/// Try lane matching if the output of behavior plugin is not on lane.
165-
if (
166-
const auto canonicalized_lanelet_pose = pose::toCanonicalizedLaneletPose(
167-
status_->getMapPose(), getBoundingBox(), route_planner_.getWholeRouteLanelets(), true,
168-
getDefaultMatchingDistanceForLaneletPoseCalculation())) {
169-
status_->set(
170-
CanonicalizedEntityStatus(static_cast<EntityStatus>(*status_), canonicalized_lanelet_pose));
171-
}
172-
173170
if (const auto canonicalized_lanelet_pose = status_->getCanonicalizedLaneletPose()) {
174171
if (pose::isAtEndOfLanelets(canonicalized_lanelet_pose.value(), hdmap_utils_ptr_)) {
175172
stopAtCurrentPosition();

0 commit comments

Comments
 (0)