diff --git a/robot_sf/sim/sim_config.py b/robot_sf/sim/sim_config.py index 0421cf9..ffc3edd 100644 --- a/robot_sf/sim/sim_config.py +++ b/robot_sf/sim/sim_config.py @@ -7,33 +7,71 @@ @dataclass class SimulationSettings: + """ + Class to hold the settings for a simulation. + + This class contains various settings that control the behavior of the simulation, + such as the simulation time, the time per step, the pedestrian speed multiplier, the + difficulty level, the maximum number of pedestrians per group, the pedestrian radius, + the goal radius, the number of steps to stack in observations, whether to use the next + goal in the path as the current goal, the pedestrian-robot force configuration, and the + pedestrian density by difficulty level. + + After initialization, the `__post_init__` method is called to validate the settings. + """ + + # Simulation time in seconds sim_time_in_secs: float = 200.0 + # Time per step in seconds time_per_step_in_secs: float = 0.1 + # Pedestrian speed multiplier peds_speed_mult: float = 1.3 + # Difficulty level difficulty: int = 0 + # Maximum number of pedestrians per group max_peds_per_group: int = 6 + # Pedestrian radius ped_radius: float = 0.4 + # Goal radius goal_radius: float = 1.0 + # Number of steps to stack in observations stack_steps: int = 3 + # Whether to use the next goal in the path as the current goal use_next_goal: bool = True + # Pedestrian-robot force configuration prf_config: PedRobotForceConfig = PedRobotForceConfig(is_active=True) + # Pedestrian density by difficulty level ped_density_by_difficulty: List[float] = field(default_factory=lambda: [0.01, 0.02, 0.04, 0.08]) def __post_init__(self): + """ + Validate the simulation settings. + + This method is called after the object is initialized. It checks that all the + settings are valid and raises a ValueError if any of them are not. + """ + # Check that the simulation time is positive if self.sim_time_in_secs <= 0: raise ValueError("Simulation length for episodes mustn't be negative or zero!") + # Check that the time per step is positive if self.time_per_step_in_secs <= 0: raise ValueError("Step time mustn't be negative or zero!") + # Check that the pedestrian speed multiplier is positive if self.peds_speed_mult <= 0: raise ValueError("Pedestrian speed mustn't be negative or zero!") + # Check that the maximum number of pedestrians per group is positive if self.max_peds_per_group <= 0: raise ValueError("Maximum pedestrians per group mustn't be negative or zero!") + # Check that the pedestrian radius is positive if self.ped_radius <= 0: raise ValueError("Pedestrian radius mustn't be negative or zero!") + # Check that the goal radius is positive if self.goal_radius <= 0: raise ValueError("Goal radius mustn't be negative or zero!") + # Check that the difficulty level is within the valid range if not 0 <= self.difficulty < len(self.ped_density_by_difficulty): raise ValueError("No pedestrian density registered for selected difficulty level!") + # Check that the pedestrian-robot force configuration is specified if not self.prf_config: raise ValueError("Pedestrian-Robot-Force settings need to be specified!")