Skip to content

Commit

Permalink
Add some randomness in map
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhenghao committed May 16, 2024
1 parent 8d3527b commit 09cb385
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions metadrive/envs/multigoal_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from metadrive.utils.math import clip, norm
from metadrive import MetaDriveEnv
from metadrive.component.navigation_module.node_network_navigation import NodeNetworkNavigation
from metadrive.component.pg_space import ParameterSpace, Parameter, ConstantSpace, DiscreteSpace
from metadrive.component.pg_space import ParameterSpace, Parameter, ConstantSpace, DiscreteSpace, BoxSpace
from metadrive.component.pgblock.first_block import FirstPGBlock
from metadrive.component.pgblock.intersection import InterSectionWithUTurn
from metadrive.component.road_network import Road
Expand Down Expand Up @@ -170,12 +170,8 @@ def destroy(self):
class CustomizedIntersection(InterSectionWithUTurn):
PARAMETER_SPACE = ParameterSpace(
{

# TODO(PZH): The radius might be too large.
Parameter.radius: ConstantSpace(12),

# unchanged:
Parameter.change_lane_num: DiscreteSpace(min=0, max=0),
Parameter.radius: BoxSpace(min=9, max=20.0),
Parameter.change_lane_num: DiscreteSpace(min=0, max=2),
Parameter.decrease_increase: DiscreteSpace(min=0, max=0)
}
)
Expand Down Expand Up @@ -268,28 +264,29 @@ def default_config(cls):
"map_config": dict(
type="block_sequence", config=[
CustomizedIntersection,
], lane_num=1, lane_width=3.5
],
lane_num=2,
lane_width=3.5
),
"agent_observation": CustomizedObservation,

# Even though the map will not change, the traffic flow will change.
"num_scenarios": 1000,

# Remove all traffic vehicles for now.
"traffic_density": 0.1,
"traffic_density": 0.2,

# If the vehicle does not reach the default destination, it will receive a penalty.
"wrong_way_penalty": 10.0,
"crash_sidewalk_penalty": 0.5,
"crash_sidewalk_penalty": 10.0,
"crash_vehicle_penalty": 10.0,
"crash_object_penalty": 10.0,
"out_of_road_penalty": 0.5,
"out_of_route_penalty": 2.0,
"out_of_road_penalty": 10.0,
"out_of_route_penalty": 0.5,
"success_reward": 10.0,
"driving_reward": 1.0,
"on_continuous_line_done": False,
"out_of_road_done": False,

"out_of_road_done": True,

"vehicle_config": {

Expand Down Expand Up @@ -477,6 +474,12 @@ def done_function(self, vehicle_id: str):
show_side_detector=True,
show_lane_line_detector=True,
),
# **{
# "map_config": dict(
# lane_num=5,
# lane_width=3.5
# ),
# }
)
env = MultiGoalIntersectionEnv(config)
episode_rewards = defaultdict(float)
Expand Down

0 comments on commit 09cb385

Please sign in to comment.