Skip to content

Should spawner modify the list of all vehicles directly? #4

@CarlinLiao

Description

@CarlinLiao

https://github.com/spartalab/aimsim/blob/56e9beaeb158b0c045f117e3b44f2c7421879659/aimsim/simulator.py#L317-L327

Per discussion here: #2 (comment)

@ribsthakkar

I'd let the spawner directly add the new vehicle to the self.vehicles set when step_vehicles is called. It makes this a bit unclear and will let you expect uniform return value rather than this None or some variable mixture.

also you didn't specify the type annotation here getting me to think that we just want this function never return anything in the first place

@CarlinLiao

The type annotation is on the definition of step_vehicles.

step_vehicles returns nothing unless u is a spawner and it spawns a vehicle this timestep. If so, it gives the vehicle to both the downstream road (for kinematics) and back to the parent simulator here so the simulator has a pointer to all vehicles currently in the system.

I don't follow how the spawner would have access to the self.vehicles list?

simulator owns spawner
simulator owns self.vehicles
would i pass self.vehicles to spawner so it can add to it itself?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions