Skip to content

Commit

Permalink
feat(traffic_light): depend on is_simulation for scenario simulator (… (
Browse files Browse the repository at this point in the history
#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 <[email protected]>
Signed-off-by: Tomohito Ando <[email protected]>
Co-authored-by: Takayuki Murooka <[email protected]>
  • Loading branch information
TomohitoAndo and takayuki5168 committed Apr 11, 2024
1 parent 955c353 commit 1456eec
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions launch/tier4_planning_launch/launch/planning.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<arg name="velocity_smoother_type_param_path"/>
<!-- planning validator -->
<arg name="planning_validator_param_path"/>
<arg name="is_simulation"/>

<group>
<push-ros-namespace namespace="planning"/>
Expand All @@ -68,6 +69,7 @@
<arg name="use_surround_obstacle_check" value="$(var use_surround_obstacle_check)"/>
<arg name="cruise_planner_type" value="$(var cruise_planner_type)"/>
<arg name="use_experimental_lane_change_function" value="$(var use_experimental_lane_change_function)"/>
<arg name="is_simulation" value="$(var is_simulation)"/>
</include>
</group>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<launch>
<arg name="is_simulation"/>

<!-- lane_driving scenario -->
<group>
<push-ros-namespace namespace="lane_driving"/>
Expand All @@ -12,6 +14,7 @@
<arg name="use_pointcloud_container" value="$(var use_pointcloud_container)"/>
<arg name="container_name" value="$(var pointcloud_container_name)"/>
<arg name="use_experimental_lane_change_function" value="$(var use_experimental_lane_change_function)"/>
<arg name="is_simulation" value="$(var is_simulation)"/>
</include>
</group>
<group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def launch_setup(context, *args, **kwargs):
common_param,
motion_velocity_smoother_param,
behavior_velocity_smoother_type_param,
{"is_simulation": LaunchConfiguration("is_simulation")},
],
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)
Expand Down Expand Up @@ -301,6 +302,9 @@ def add_launch_arg(name: str, default_value=None, description=None):
add_launch_arg("use_pointcloud_container", "true")
add_launch_arg("container_name", "pointcloud_container")

# whether this is a simulation or not
add_launch_arg("is_simulation", "false", "whether this is a simulation or not")

set_container_executable = SetLaunchConfiguration(
"container_executable",
"component_container",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<launch>
<arg name="is_simulation"/>
<!-- scenario selector -->
<group>
<include file="$(find-pkg-share scenario_selector)/launch/scenario_selector.launch.xml">
Expand Down Expand Up @@ -58,6 +59,7 @@
<arg name="use_surround_obstacle_check" value="$(var use_surround_obstacle_check)"/>
<arg name="cruise_planner_type" value="$(var cruise_planner_type)"/>
<arg name="use_experimental_lane_change_function" value="$(var use_experimental_lane_change_function)"/>
<arg name="is_simulation" value="$(var is_simulation)"/>
</include>
</group>
<!-- parking -->
Expand Down
5 changes: 3 additions & 2 deletions planning/behavior_velocity_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ BehaviorVelocityPlannerNode::BehaviorVelocityPlannerNode(const rclcpp::NodeOptio
planner_data_.ego_nearest_yaw_threshold =
this->declare_parameter<double>("ego_nearest_yaw_threshold");

// is simulation or not
planner_data_.is_simulation = declare_parameter<bool>("is_simulation");

// Initialize PlannerManager
for (const auto & name : declare_parameter<std::vector<std::string>>("launch_modules")) {
planner_manager_.launchScenePlugin(*this, name);
Expand Down Expand Up @@ -298,8 +301,6 @@ void BehaviorVelocityPlannerNode::onTrafficSignals(
{
std::lock_guard<std::mutex> lock(mutex_);

planner_data_.has_received_signal_ = true;

for (const auto & signal : msg->signals) {
TrafficSignalStamped traffic_signal;
traffic_signal.stamp = msg->stamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ struct PlannerData
boost::optional<tier4_planning_msgs::msg::VelocityLimit> external_velocity_limit;
tier4_v2x_msgs::msg::VirtualTrafficLightStateArray::ConstSharedPtr virtual_traffic_light_states;

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

// velocity smoother
std::shared_ptr<motion_velocity_smoother::SmootherBase> velocity_smoother_;
Expand Down
17 changes: 8 additions & 9 deletions planning/behavior_velocity_traffic_light_module/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,15 @@ bool TrafficLightModule::isStopSignal()
{
updateTrafficSignal();

// Pass through if no traffic signal information has been received yet
// This is to prevent stopping on the planning simulator
if (!planner_data_->has_received_signal_) {
return false;
}

// Stop if there is no upcoming traffic signal information
// This is to safely stop in cases such that traffic light recognition is not working properly or
// the map is incorrect
// If there is no upcoming traffic signal information,
// SIMULATION: it will PASS to prevent stopping on the planning simulator
// or scenario simulator.
// REAL ENVIRONMENT: it will STOP for safety in cases such that traffic light
// recognition is not working properly or the map is incorrect.
if (!traffic_signal_stamp_) {
if (planner_data_->is_simulation) {
return false;
}
return true;
}

Expand Down

0 comments on commit 1456eec

Please sign in to comment.