Skip to content

Commit 1456eec

Browse files
feat(traffic_light): depend on is_simulation for scenario simulator (… (#1171)
feat(traffic_light): depend on is_simulation for scenario simulator (autowarefoundation#6498) * feat(traffic_light): depend on is_simulation for scenario simulator * fix comments * fix --------- Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> Co-authored-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 955c353 commit 1456eec

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

launch/tier4_planning_launch/launch/planning.launch.xml

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<arg name="velocity_smoother_type_param_path"/>
4848
<!-- planning validator -->
4949
<arg name="planning_validator_param_path"/>
50+
<arg name="is_simulation"/>
5051

5152
<group>
5253
<push-ros-namespace namespace="planning"/>
@@ -68,6 +69,7 @@
6869
<arg name="use_surround_obstacle_check" value="$(var use_surround_obstacle_check)"/>
6970
<arg name="cruise_planner_type" value="$(var cruise_planner_type)"/>
7071
<arg name="use_experimental_lane_change_function" value="$(var use_experimental_lane_change_function)"/>
72+
<arg name="is_simulation" value="$(var is_simulation)"/>
7173
</include>
7274
</group>
7375

launch/tier4_planning_launch/launch/scenario_planning/lane_driving.launch.xml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<launch>
2+
<arg name="is_simulation"/>
3+
24
<!-- lane_driving scenario -->
35
<group>
46
<push-ros-namespace namespace="lane_driving"/>
@@ -12,6 +14,7 @@
1214
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
1315
<arg name="container_name" value="$(var pointcloud_container_name)"/>
1416
<arg name="use_experimental_lane_change_function" value="$(var use_experimental_lane_change_function)"/>
17+
<arg name="is_simulation" value="$(var is_simulation)"/>
1518
</include>
1619
</group>
1720
<group>

launch/tier4_planning_launch/launch/scenario_planning/lane_driving/behavior_planning/behavior_planning.launch.py

+4
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def launch_setup(context, *args, **kwargs):
205205
common_param,
206206
motion_velocity_smoother_param,
207207
behavior_velocity_smoother_type_param,
208+
{"is_simulation": LaunchConfiguration("is_simulation")},
208209
],
209210
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
210211
)
@@ -301,6 +302,9 @@ def add_launch_arg(name: str, default_value=None, description=None):
301302
add_launch_arg("use_pointcloud_container", "true")
302303
add_launch_arg("container_name", "pointcloud_container")
303304

305+
# whether this is a simulation or not
306+
add_launch_arg("is_simulation", "false", "whether this is a simulation or not")
307+
304308
set_container_executable = SetLaunchConfiguration(
305309
"container_executable",
306310
"component_container",

launch/tier4_planning_launch/launch/scenario_planning/scenario_planning.launch.xml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<launch>
2+
<arg name="is_simulation"/>
23
<!-- scenario selector -->
34
<group>
45
<include file="$(find-pkg-share scenario_selector)/launch/scenario_selector.launch.xml">
@@ -58,6 +59,7 @@
5859
<arg name="use_surround_obstacle_check" value="$(var use_surround_obstacle_check)"/>
5960
<arg name="cruise_planner_type" value="$(var cruise_planner_type)"/>
6061
<arg name="use_experimental_lane_change_function" value="$(var use_experimental_lane_change_function)"/>
62+
<arg name="is_simulation" value="$(var is_simulation)"/>
6163
</include>
6264
</group>
6365
<!-- parking -->

planning/behavior_velocity_planner/src/node.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ BehaviorVelocityPlannerNode::BehaviorVelocityPlannerNode(const rclcpp::NodeOptio
141141
planner_data_.ego_nearest_yaw_threshold =
142142
this->declare_parameter<double>("ego_nearest_yaw_threshold");
143143

144+
// is simulation or not
145+
planner_data_.is_simulation = declare_parameter<bool>("is_simulation");
146+
144147
// Initialize PlannerManager
145148
for (const auto & name : declare_parameter<std::vector<std::string>>("launch_modules")) {
146149
planner_manager_.launchScenePlugin(*this, name);
@@ -298,8 +301,6 @@ void BehaviorVelocityPlannerNode::onTrafficSignals(
298301
{
299302
std::lock_guard<std::mutex> lock(mutex_);
300303

301-
planner_data_.has_received_signal_ = true;
302-
303304
for (const auto & signal : msg->signals) {
304305
TrafficSignalStamped traffic_signal;
305306
traffic_signal.stamp = msg->stamp;

planning/behavior_velocity_planner_common/include/behavior_velocity_planner_common/planner_data.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ struct PlannerData
8989
boost::optional<tier4_planning_msgs::msg::VelocityLimit> external_velocity_limit;
9090
tier4_v2x_msgs::msg::VirtualTrafficLightStateArray::ConstSharedPtr virtual_traffic_light_states;
9191

92-
// this value becomes true once the signal message is received
93-
bool has_received_signal_ = false;
92+
// This variable is used when the Autoware's behavior has to depend on whether it's simulation or
93+
// not.
94+
bool is_simulation = false;
9495

9596
// velocity smoother
9697
std::shared_ptr<motion_velocity_smoother::SmootherBase> velocity_smoother_;

planning/behavior_velocity_traffic_light_module/src/scene.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,15 @@ bool TrafficLightModule::isStopSignal()
302302
{
303303
updateTrafficSignal();
304304

305-
// Pass through if no traffic signal information has been received yet
306-
// This is to prevent stopping on the planning simulator
307-
if (!planner_data_->has_received_signal_) {
308-
return false;
309-
}
310-
311-
// Stop if there is no upcoming traffic signal information
312-
// This is to safely stop in cases such that traffic light recognition is not working properly or
313-
// the map is incorrect
305+
// If there is no upcoming traffic signal information,
306+
// SIMULATION: it will PASS to prevent stopping on the planning simulator
307+
// or scenario simulator.
308+
// REAL ENVIRONMENT: it will STOP for safety in cases such that traffic light
309+
// recognition is not working properly or the map is incorrect.
314310
if (!traffic_signal_stamp_) {
311+
if (planner_data_->is_simulation) {
312+
return false;
313+
}
315314
return true;
316315
}
317316

0 commit comments

Comments
 (0)