Skip to content

Commit 2a38077

Browse files
takayuki5168TomohitoAndo
authored andcommitted
feat(traffic_light): depend on is_simulation for scenario simulator (autowarefoundation#6498)
* feat(traffic_light): depend on is_simulation for scenario simulator Signed-off-by: Takayuki Murooka <[email protected]> * fix comments Signed-off-by: Takayuki Murooka <[email protected]> * fix Signed-off-by: Takayuki Murooka <[email protected]> --------- Signed-off-by: Takayuki Murooka <[email protected]> Signed-off-by: Tomohito Ando <[email protected]>
1 parent c5a5436 commit 2a38077

File tree

8 files changed

+24
-13
lines changed

8 files changed

+24
-13
lines changed

launch/tier4_planning_launch/launch/planning.launch.xml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<arg name="planning_validator_param_path"/>
1010
<!-- Auto mode setting-->
1111
<arg name="enable_all_modules_auto_mode"/>
12+
<arg name="is_simulation"/>
1213

1314
<group>
1415
<push-ros-namespace namespace="planning"/>
@@ -25,6 +26,7 @@
2526
<push-ros-namespace namespace="scenario_planning"/>
2627
<include file="$(find-pkg-share tier4_planning_launch)/launch/scenario_planning/scenario_planning.launch.xml">
2728
<arg name="enable_all_modules_auto_mode" value="$(var enable_all_modules_auto_mode)"/>
29+
<arg name="is_simulation" value="$(var is_simulation)"/>
2830
</include>
2931
</group>
3032

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<launch>
22
<arg name="enable_all_modules_auto_mode"/>
3+
<arg name="is_simulation"/>
34

45
<!-- lane_driving scenario -->
56
<group>
@@ -11,6 +12,7 @@
1112
<include file="$(find-pkg-share tier4_planning_launch)/launch/scenario_planning/lane_driving/behavior_planning/behavior_planning.launch.xml">
1213
<arg name="container_type" value="component_container_mt"/>
1314
<arg name="enable_all_modules_auto_mode" value="$(var enable_all_modules_auto_mode)"/>
15+
<arg name="is_simulation" value="$(var is_simulation)"/>
1416
<!-- This condition should be true if run_out module is enabled and its detection method is Points -->
1517
<arg name="launch_compare_map_pipeline" value="false"/>
1618
</include>

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

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<arg name="input_vector_map_topic_name" default="/map/vector_map"/>
66
<arg name="input_pointcloud_map_topic_name" default="/map/pointcloud_map"/>
77
<arg name="enable_all_modules_auto_mode"/>
8+
<arg name="is_simulation"/>
89

910
<arg name="launch_avoidance_module" default="true"/>
1011
<arg name="launch_avoidance_by_lane_change_module" default="true"/>
@@ -202,6 +203,7 @@
202203
<param from="$(var nearest_search_param_path)"/>
203204
<param name="launch_modules" value="$(var behavior_path_planner_launch_modules)"/>
204205
<param name="enable_all_modules_auto_mode" value="$(var enable_all_modules_auto_mode)"/>
206+
<param name="is_simulation" value="$(var is_simulation)"/>
205207
<param from="$(var behavior_path_planner_side_shift_module_param_path)"/>
206208
<param from="$(var behavior_path_planner_avoidance_module_param_path)"/>
207209
<param from="$(var behavior_path_planner_avoidance_by_lc_module_param_path)"/>
@@ -243,6 +245,7 @@
243245
<param from="$(var behavior_velocity_smoother_type_param_path)"/>
244246
<param from="$(var behavior_velocity_planner_common_param_path)"/>
245247
<param name="launch_modules" value="$(var behavior_velocity_planner_launch_modules)"/>
248+
<param name="is_simulation" value="$(var is_simulation)"/>
246249
<!-- <param from="$(var template_param_path)"/> -->
247250
<param from="$(var behavior_velocity_planner_blind_spot_module_param_path)"/>
248251
<param from="$(var behavior_velocity_planner_crosswalk_module_param_path)"/>

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<launch>
22
<arg name="enable_all_modules_auto_mode"/>
3+
<arg name="is_simulation"/>
34
<!-- scenario selector -->
45
<group>
56
<include file="$(find-pkg-share scenario_selector)/launch/scenario_selector.launch.xml">
@@ -53,6 +54,7 @@
5354
<group>
5455
<include file="$(find-pkg-share tier4_planning_launch)/launch/scenario_planning/lane_driving.launch.xml">
5556
<arg name="enable_all_modules_auto_mode" value="$(var enable_all_modules_auto_mode)"/>
57+
<arg name="is_simulation" value="$(var is_simulation)"/>
5658
</include>
5759
</group>
5860
<!-- parking -->

planning/behavior_velocity_planner/src/node.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ BehaviorVelocityPlannerNode::BehaviorVelocityPlannerNode(const rclcpp::NodeOptio
150150
declare_parameter<double>("ego_nearest_dist_threshold");
151151
planner_data_.ego_nearest_yaw_threshold = declare_parameter<double>("ego_nearest_yaw_threshold");
152152

153+
// is simulation or not
154+
planner_data_.is_simulation = declare_parameter<bool>("is_simulation");
155+
153156
// Initialize PlannerManager
154157
for (const auto & name : declare_parameter<std::vector<std::string>>("launch_modules")) {
155158
// workaround: Since ROS 2 can't get empty list, launcher set [''] on the parameter.
@@ -327,8 +330,6 @@ void BehaviorVelocityPlannerNode::onTrafficSignals(
327330
{
328331
std::lock_guard<std::mutex> lock(mutex_);
329332

330-
planner_data_.has_received_signal_ = true;
331-
332333
for (const auto & signal : msg->signals) {
333334
TrafficSignalStamped traffic_signal;
334335
traffic_signal.stamp = msg->stamp;

planning/behavior_velocity_planner/test/src/test_node_interface.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ std::shared_ptr<BehaviorVelocityPlannerNode> generateNode()
7878

7979
std::vector<rclcpp::Parameter> params;
8080
params.emplace_back("launch_modules", module_names);
81+
params.emplace_back("is_simulation", false);
8182
node_options.parameter_overrides(params);
8283

8384
test_utils::updateNodeOptions(

planning/behavior_velocity_planner_common/include/behavior_velocity_planner_common/planner_data.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ struct PlannerData
8282
std::map<int, TrafficSignalTimeToRedStamped> traffic_light_time_to_red_id_map;
8383
tier4_v2x_msgs::msg::VirtualTrafficLightStateArray::ConstSharedPtr virtual_traffic_light_states;
8484

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

8889
// velocity smoother
8990
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
@@ -303,16 +303,15 @@ bool TrafficLightModule::isStopSignal()
303303
{
304304
updateTrafficSignal();
305305

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

0 commit comments

Comments
 (0)