diff --git a/CHANGELOG.md b/CHANGELOG.md index e2f4c61680..50c59f2d60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Copy and pasting the git commit messages is __NOT__ enough. ### Changed ### Deprecated ### Fixed +- `Trip.actor` field is now effective. Previously `actor` had no effect. ### Removed ### Security diff --git a/smarts/sstudio/generators.py b/smarts/sstudio/generators.py index 2ef2055144..83e5c14ca2 100644 --- a/smarts/sstudio/generators.py +++ b/smarts/sstudio/generators.py @@ -221,8 +221,8 @@ def _writexml( if traffic.trips: actors_for_vtypes |= {trip.actor for trip in traffic.trips} vehicle_id_set = {trip.vehicle_name for trip in traffic.trips} - vehilce_ids_list = [trip.vehicle_name for trip in traffic.trips] - if len(vehicle_id_set) != len(vehilce_ids_list): + vehicle_ids_list = [trip.vehicle_name for trip in traffic.trips] + if len(vehicle_id_set) != len(vehicle_ids_list): raise ValueError("Repeated single vehicle names is not allowed.") for actor in actors_for_vtypes: diff --git a/smarts/sstudio/types.py b/smarts/sstudio/types.py index 57ae2be288..ee06b37efe 100644 --- a/smarts/sstudio/types.py +++ b/smarts/sstudio/types.py @@ -21,7 +21,7 @@ import logging import math import random -from dataclasses import dataclass, field +from dataclasses import dataclass, field, replace from enum import IntEnum from sys import maxsize from typing import ( @@ -518,7 +518,15 @@ def __post_init__(self): object.__setattr__( self, "actor", - TrafficActor(name=self.vehicle_name, vehicle_type=self.vehicle_type), + ( + replace( + self.actor, name=self.vehicle_name, vehicle_type=self.vehicle_type + ) + if self.actor is not None + else TrafficActor( + name=self.vehicle_name, vehicle_type=self.vehicle_type + ) + ), ) @property