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

traffic history issues #769

Merged
merged 2 commits into from
Apr 17, 2021
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
2 changes: 1 addition & 1 deletion smarts/core/traffic_history_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def step(self, provider_actions, dt, elapsed_sim_time) -> ProviderState:
default_dims = VEHICLE_CONFIGS[vehicle_type].dimensions
vehicles.append(
VehicleState(
vehicle_id=v_id,
vehicle_id=f"social-agent-history-{v_id}",
vehicle_type=vehicle_type,
pose=Pose.from_center(
[
Expand Down
13 changes: 9 additions & 4 deletions smarts/sstudio/genhistories.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@


METERS_PER_FOOT = 0.3048
DEFAULT_LANE_WIDTH = 3.7 # a typical US highway lane is 12ft ~= 3.7m wide


class _TrajectoryDataset:
Expand All @@ -41,7 +42,7 @@ def __init__(self, dataset_spec, output):
self.check_dataset_spec(dataset_spec)
self._output = output
self._path = dataset_spec["input_path"]
real_lane_width_m = dataset_spec.get("real_lane_width_m", 3.7)
real_lane_width_m = dataset_spec.get("real_lane_width_m", DEFAULT_LANE_WIDTH)
lane_width = dataset_spec.get("map_net", {}).get(
"lane_width", real_lane_width_m
)
Expand Down Expand Up @@ -114,7 +115,8 @@ def _create_tables(self, dbconxn):
dbconxn.commit()
ccur.close()

def create_output(self):
def create_output(self, time_precision=3):
""" time_precision is limit for digits after decimal for sim_time (3 is milisecond precision) """
dbconxn = sqlite3.connect(self._output)

self._log.debug("creating tables...")
Expand Down Expand Up @@ -150,7 +152,10 @@ def create_output(self):
traj_args = (
vid,
# time units are in milliseconds for both NGSIM and Interaction datasets, convert to secs
round(float(self.column_val_in_row(row, "sim_time")) / 1000, 3),
round(
float(self.column_val_in_row(row, "sim_time")) / 1000,
time_precision,
),
float(self.column_val_in_row(row, "position_x")) * self.scale,
float(self.column_val_in_row(row, "position_y")) * self.scale,
float(self.column_val_in_row(row, "heading_rad")),
Expand All @@ -168,7 +173,7 @@ def create_output(self):
self._log.debug("shifting sim_times..")
mcur = dbconxn.cursor()
mcur.execute(
"UPDATE Trajectory SET sim_time = sim_time - (SELECT min(sim_time) FROM Trajectory)"
f"UPDATE Trajectory SET sim_time = round(sim_time - (SELECT min(sim_time) FROM Trajectory), {time_precision})"
)
mcur.close()
dbconxn.commit()
Expand Down