Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten vehicle ids. #1960

Merged
merged 2 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
- The trap manager, `TrapManager`, is now a subclass of `ActorCaptureManager`.
- Considering lane-change time ranges between 3s and 6s, assuming a speed of 13.89m/s, the via sensor lane acquisition range was increased from 40m to 80m, for better driving ability.
- Modified naming of benchmark used in NeurIPS 2022 from driving-smarts-competition-env to driving-smarts-v2022.
- Sstudio generated scenario vehicle traffic ids are now shortened.
### Deprecated
### Fixed
- Fixed an issue where Argoverse scenarios with a `Mission` would not run properly.
Expand Down
6 changes: 3 additions & 3 deletions envision/tests/test_data_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ def sim_data():
[],
[4],
{
0: "car-flow-route-west_0_0-east_0_max-7845114534199723832--7266489842092764092--0-0.0",
0: "car-west_0_0-east_0_max-784511-552438-0-0.0",
1: None,
2: "car-flow-route-west_1_0-east_1_max--852708111940723884--7266489842092764092--1-0.0",
3: "car-flow-route-west_2_0-east_2_max--6324729949279915259--7266489842092764092--2-0.0",
2: "car-west_1_0-east_1_max--85270-291315-1-0.0",
3: "car-west_2_0-east_2_max--63247--53682-2-0.0",
4: "AGENT_1",
},
[],
Expand Down
4 changes: 2 additions & 2 deletions smarts/core/tests/test_trap_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ def smarts_two_agents():
def test_capture_vehicle(smarts: SMARTS, scenarios, traffic_sim):
smarts.reset(next(scenarios))
if traffic_sim == "SMARTS":
vehicle_prefix = "actor-car"
vehicle_prefix = "car"
vehicle_id = list(smarts.vehicle_index.agent_vehicle_ids())[0]
assert vehicle_id.startswith(vehicle_prefix)
else:
vehicle_prefix = "car-flow-route-west_1_0-east_1_max"
vehicle_prefix = "car-west_1_0-east_1_max"
vehicle_id = list(smarts.vehicle_index.agent_vehicle_ids())[0]
assert vehicle_id.startswith(vehicle_prefix)
assert smarts.elapsed_sim_time < 1
Expand Down
4 changes: 2 additions & 2 deletions smarts/core/utils/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def large_observation():
under_this_agent_control=True,
neighborhood_vehicle_states=[
VehicleObservation(
id="car-flow-route-west_0_0-east_0_max-7845114534199723832--7266489842092764092--0-0.0",
id="car-west_0_0-east_0_max-784511-726648-0-0.0",
position=(-1.33354215, -3.2, 0.0),
bounding_box=Dimensions(length=3.68, width=1.47, height=1.4),
heading=Heading(-1.5707963267948966),
Expand All @@ -112,7 +112,7 @@ def large_observation():
lane_position=RefLinePoint(-1.33354215, 0.0, 0.0),
),
VehicleObservation(
id="car-flow-route-west_1_0-east_1_max--852708111940723884--7266489842092764092--1-0.0",
id="car-west_1_0-east_1_max--85270-726648-1-0.0",
position=(-1.47159011, 0.0, 0.0),
bounding_box=Dimensions(length=3.68, width=1.47, height=1.4),
heading=Heading(-1.5707963267948966),
Expand Down
21 changes: 10 additions & 11 deletions smarts/sstudio/tests/baseline.rou.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- generated on 2021-12-15 02:51:13 by Eclipse SUMO duarouter Version 1.11.0
<!-- generated on 2023-04-14 23:17:43 by Eclipse SUMO duarouter Version 1.16.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/duarouterConfiguration.xsd">

<input>
<net-file value="scenarios/sumo/intersections/4lane_t/map.net.xml"/>
<route-files value="/tmp/tmp6925s2db/trips.trips.xml"/>
<route-files value="/tmp/tmpiy_i5cen/trips.trips.xml"/>
</input>

<output>
<output-file value="smarts/sstudio/tests/build/traffic/generated.rou.xml"/>
<alternatives-output value="smarts/sstudio/tests/build/traffic/generated.rou.alt.xml"/>
<output-file value="smarts/sstudio/tests/traffic/generated.rou.xml"/>
</output>

<processing>
Expand All @@ -19,7 +18,7 @@
</processing>

<report>
<error-log value="/tmp/smarts/_duarouter_routing/build/traffic/generated.log"/>
<error-log value="/home/dev/.smarts/_duarouter_routing/traffic/generated.log"/>
<no-step-log value="true"/>
</report>

Expand All @@ -31,18 +30,18 @@
-->

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<vType id="actor-car--6154633892093701017" minGap="2.50" maxSpeed="55.50" speedFactor="normc(1.00,0.20,0.20,2.00)" vClass="passenger" accel="2.6" decel="4.5" sigma="0.5"/>
<vehicle id="car-flow-route-edge-east-EW_0_30-edge-west-EW_0_-30-4549815329406996597---1272272649408374293--1-0.0" type="actor-car--6154633892093701017" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<vType id="car--61546" minGap="2.50" maxSpeed="55.50" speedFactor="normc(1.00,0.20,0.20,2.00)" vClass="passenger" accel="2.6" decel="4.5" sigma="0.5"/>
<vehicle id="car-edge-east-EW_0_30-edge-west-EW_0_-30-454981-765358-1-0.0" type="car--61546" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<route edges="edge-east-EW edge-west-EW"/>
</vehicle>
<vType id="actor-car--3764963214027188709" minGap="2.50" maxSpeed="55.50" speedFactor="normc(0.80,0.20,0.20,2.00)" vClass="passenger" impatience="0.50" lcCooperative="0.25" lcImpatience="1" jmDriveAfterYellowTime="1.0" accel="2.6" decel="4.5" sigma="0.5"/>
<vehicle id="car-flow-route-edge-east-EW_0_30-edge-west-EW_0_-30-4549815329406996597---1272272649408374293--1-1.0" type="actor-car--3764963214027188709" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<vType id="car--37649" minGap="2.50" maxSpeed="55.50" speedFactor="normc(0.80,0.20,0.20,2.00)" vClass="passenger" impatience="0.50" lcCooperative="0.25" lcImpatience="1" jmDriveAfterYellowTime="1.0" accel="2.6" decel="4.5" sigma="0.5"/>
<vehicle id="car-edge-east-EW_0_30-edge-west-EW_0_-30-454981-765358-1-1.0" type="car--37649" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<route edges="edge-east-EW edge-west-EW"/>
</vehicle>
<vehicle id="car-flow-route-edge-west-WE_0_30-edge-east-WE_0_-30-8228644098954649173---1272272649408374293--0-0.0" type="actor-car--6154633892093701017" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<vehicle id="car-edge-west-WE_0_30-edge-east-WE_0_-30-822864-585157-0-0.0" type="car--61546" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<route edges="edge-west-WE edge-east-WE"/>
</vehicle>
<vehicle id="car-flow-route-edge-west-WE_0_30-edge-east-WE_0_-30-8228644098954649173---1272272649408374293--0-1.0" type="actor-car--3764963214027188709" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<vehicle id="car-edge-west-WE_0_30-edge-east-WE_0_-30-822864-585157-0-1.0" type="car--37649" depart="0.00" departLane="0" departPos="30.00" departSpeed="max" arrivalLane="0" arrivalPos="-30.00">
<route edges="edge-west-WE edge-east-WE"/>
</vehicle>
</routes>
10 changes: 5 additions & 5 deletions smarts/sstudio/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def __hash__(self) -> int:
@property
def id(self) -> str:
"""The identifier tag of the traffic actor."""
return "actor-{}-{}".format(self.name, hash(self))
return "{}-{}".format(self.name, str(hash(self))[:6])


@dataclass(frozen=True)
Expand Down Expand Up @@ -420,10 +420,10 @@ class Route:
@property
def id(self) -> str:
"""The unique id of this route."""
return "route-{}-{}-{}-".format(
return "{}-{}-{}".format(
"_".join(map(str, self.begin)),
"_".join(map(str, self.end)),
pickle_hash_int(self),
str(hash(self))[:6],
)

@property
Expand Down Expand Up @@ -485,9 +485,9 @@ class Flow:
@property
def id(self) -> str:
"""The unique id of this flow."""
return "flow-{}-{}-".format(
return "{}-{}".format(
self.route.id,
str(pickle_hash_int(sorted(self.actors.items(), key=lambda a: a[0].name))),
str(hash(self))[:6],
)

def __hash__(self):
Expand Down