From 2d78c5eabd1c6056205769247152401c95cfde3f Mon Sep 17 00:00:00 2001 From: Aarav Pandya Date: Wed, 22 May 2024 20:49:23 -0400 Subject: [PATCH 1/4] Dont init agents if not valid on first timestep --- src/level_gen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/level_gen.cpp b/src/level_gen.cpp index a41fcc70..dc949187 100755 --- a/src/level_gen.cpp +++ b/src/level_gen.cpp @@ -335,6 +335,10 @@ void createPersistentEntities(Engine &ctx, Map *map) { } } const auto &agentInit = map->objects[agentCtr]; + if (agentInit.valid[0] == false) + { + continue; + } auto agent = createAgent( ctx, agentInit); ctx.data().agents[agentIdx++] = agent; From 3df8ae59eebf81fb877782ff2d944321c43feb24 Mon Sep 17 00:00:00 2001 From: Aarav Pandya Date: Wed, 22 May 2024 20:52:59 -0400 Subject: [PATCH 2/4] Add param --- src/bindings.cpp | 3 ++- src/init.hpp | 1 + src/level_gen.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bindings.cpp b/src/bindings.cpp index 183afbd8..9f98f1fb 100644 --- a/src/bindings.cpp +++ b/src/bindings.cpp @@ -51,7 +51,8 @@ namespace gpudrive .def_rw("collisionBehaviour", &Parameters::collisionBehaviour) .def_rw("maxNumControlledVehicles", &Parameters::maxNumControlledVehicles) .def_rw("IgnoreNonVehicles", &Parameters::IgnoreNonVehicles) - .def_rw("roadObservationAlgorithm", &Parameters::roadObservationAlgorithm); + .def_rw("roadObservationAlgorithm", &Parameters::roadObservationAlgorithm) + .def_rw("initInvalidAgentsAtFirstStep", &Parameters::initInvalidAgentsAtFirstStep); // Define CollisionBehaviour enum nb::enum_(m, "CollisionBehaviour") diff --git a/src/init.hpp b/src/init.hpp index 043c5e35..744d06e5 100755 --- a/src/init.hpp +++ b/src/init.hpp @@ -111,6 +111,7 @@ namespace gpudrive bool IgnoreNonVehicles = false; // Default: false FindRoadObservationsWith roadObservationAlgorithm{ FindRoadObservationsWith::KNearestEntitiesWithRadiusFiltering}; + bool initInvalidAgentsAtFirstStep = false; // Default: false }; struct WorldInit diff --git a/src/level_gen.cpp b/src/level_gen.cpp index dc949187..43d518e5 100755 --- a/src/level_gen.cpp +++ b/src/level_gen.cpp @@ -335,7 +335,7 @@ void createPersistentEntities(Engine &ctx, Map *map) { } } const auto &agentInit = map->objects[agentCtr]; - if (agentInit.valid[0] == false) + if (!ctx.data().params.initInvalidAgentsAtFirstStep && agentInit.valid[0] == false) { continue; } From 932ab7183e85d6648ac01f001219e6c4b47b12a1 Mon Sep 17 00:00:00 2001 From: Aarav Pandya Date: Wed, 22 May 2024 21:05:00 -0400 Subject: [PATCH 3/4] Change name and fix test --- src/bindings.cpp | 2 +- src/init.hpp | 2 +- src/level_gen.cpp | 2 +- tests/bicyclemodel.cpp | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bindings.cpp b/src/bindings.cpp index 9f98f1fb..afedba7e 100644 --- a/src/bindings.cpp +++ b/src/bindings.cpp @@ -52,7 +52,7 @@ namespace gpudrive .def_rw("maxNumControlledVehicles", &Parameters::maxNumControlledVehicles) .def_rw("IgnoreNonVehicles", &Parameters::IgnoreNonVehicles) .def_rw("roadObservationAlgorithm", &Parameters::roadObservationAlgorithm) - .def_rw("initInvalidAgentsAtFirstStep", &Parameters::initInvalidAgentsAtFirstStep); + .def_rw("initOnlyValidAgentsAtFirstStep ", &Parameters::initOnlyValidAgentsAtFirstStep); // Define CollisionBehaviour enum nb::enum_(m, "CollisionBehaviour") diff --git a/src/init.hpp b/src/init.hpp index 744d06e5..db640205 100755 --- a/src/init.hpp +++ b/src/init.hpp @@ -111,7 +111,7 @@ namespace gpudrive bool IgnoreNonVehicles = false; // Default: false FindRoadObservationsWith roadObservationAlgorithm{ FindRoadObservationsWith::KNearestEntitiesWithRadiusFiltering}; - bool initInvalidAgentsAtFirstStep = false; // Default: false + bool initOnlyValidAgentsAtFirstStep = true; // Default: false }; struct WorldInit diff --git a/src/level_gen.cpp b/src/level_gen.cpp index 43d518e5..3cd2f3b6 100755 --- a/src/level_gen.cpp +++ b/src/level_gen.cpp @@ -335,7 +335,7 @@ void createPersistentEntities(Engine &ctx, Map *map) { } } const auto &agentInit = map->objects[agentCtr]; - if (!ctx.data().params.initInvalidAgentsAtFirstStep && agentInit.valid[0] == false) + if (ctx.data().params.initOnlyValidAgentsAtFirstStep && agentInit.valid[0] == false) { continue; } diff --git a/tests/bicyclemodel.cpp b/tests/bicyclemodel.cpp index 6050e188..cd2e9559 100644 --- a/tests/bicyclemodel.cpp +++ b/tests/bicyclemodel.cpp @@ -27,6 +27,7 @@ class BicycleKinematicModelTest : public ::testing::Test { .polylineReductionThreshold = 0.0, .observationRadius = 100.0, .collisionBehaviour = gpudrive::CollisionBehaviour::Ignore, + .initOnlyValidAgentsAtFirstStep = false } }); From 7db00ac5a12229dca88f70a9ca2dacb73364cb39 Mon Sep 17 00:00:00 2001 From: Aarav Pandya Date: Wed, 22 May 2024 21:08:46 -0400 Subject: [PATCH 4/4] Change comment --- src/init.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.hpp b/src/init.hpp index db640205..ce95622f 100755 --- a/src/init.hpp +++ b/src/init.hpp @@ -111,7 +111,7 @@ namespace gpudrive bool IgnoreNonVehicles = false; // Default: false FindRoadObservationsWith roadObservationAlgorithm{ FindRoadObservationsWith::KNearestEntitiesWithRadiusFiltering}; - bool initOnlyValidAgentsAtFirstStep = true; // Default: false + bool initOnlyValidAgentsAtFirstStep = true; // Default: true }; struct WorldInit