Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Include steps per second as beamng simulation conf parameter #119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 18 additions & 4 deletions self_driving/beamng_brewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ def __init__(self, beamng_home=None, beamng_user=None, reuse_beamng=True, road_n
self.camera: BeamNGCamera = None
if road_nodes:
self.setup_road_nodes(road_nodes)
steps = 5
self.params = SimulationParams(beamng_steps=steps, delay_msec=int(steps * 0.05 * 1000))

# TODO Make this configurable
# Configure the simulator to monitor at 20Hz frequency, i.e., every 60/3 steps in a second
steps_per_second = 60
steps = 3
#
self.params = SimulationParams(beamng_steps=steps, beamng_steps_per_second=steps_per_second, delay_msec=int(steps * 0.05 * 1000))
self.vehicle_start_pose = BeamNGPose()

def setup_road_nodes(self, road_nodes):
Expand Down Expand Up @@ -91,15 +96,24 @@ def bring_up(self):

self.scenario.make(self.beamng)

self.beamng.set_deterministic()

self.beamng.load_scenario(self.scenario)

# Ensure the simulation runs deterministically at the given frequency
self.beamng.set_deterministic()
self.beamng.set_steps_per_second(self.params.beamng_steps_per_second)

# Start the simulation but pause it rightaway
self.beamng.start_scenario()

# Pause the simulator only after loading and starting the scenario
self.beamng.pause()

frequency = self.params.beamng_steps_per_second / self.params.beamng_steps
log.info("Starting a new simulation with params: Step %s, Step/Second %s (Freq %s Hz)", self.params.beamng_steps, self.params.beamng_steps_per_second, frequency)




def __del__(self):
if self.beamng:
try:
Expand Down
2 changes: 1 addition & 1 deletion self_driving/simulation_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
SimulationDataRecord = namedtuple('SimulationDataRecord', SimulationDataRecordProperties)
SimulationDataRecords = List[SimulationDataRecord]

SimulationParams = namedtuple('SimulationParameters', ['beamng_steps', 'delay_msec'])
SimulationParams = namedtuple('SimulationParameters', ['beamng_steps', 'beamng_steps_per_second', 'delay_msec'])

def delete_folder_recursively(path: Union[str, Path], exception_if_fail: bool = True):
path = str(path)
Expand Down