Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont init invalid agents at first time step. #130

Merged
merged 4 commits into from
May 23, 2024
Merged
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
3 changes: 2 additions & 1 deletion src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("initOnlyValidAgentsAtFirstStep ", &Parameters::initOnlyValidAgentsAtFirstStep);

// Define CollisionBehaviour enum
nb::enum_<CollisionBehaviour>(m, "CollisionBehaviour")
Expand Down
1 change: 1 addition & 0 deletions src/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace gpudrive
bool IgnoreNonVehicles = false; // Default: false
FindRoadObservationsWith roadObservationAlgorithm{
FindRoadObservationsWith::KNearestEntitiesWithRadiusFiltering};
bool initOnlyValidAgentsAtFirstStep = true; // Default: true
};

struct WorldInit
Expand Down
4 changes: 4 additions & 0 deletions src/level_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ void createPersistentEntities(Engine &ctx, Map *map) {
}
}
const auto &agentInit = map->objects[agentCtr];
if (ctx.data().params.initOnlyValidAgentsAtFirstStep && agentInit.valid[0] == false)
{
continue;
}
auto agent = createAgent(
ctx, agentInit);
ctx.data().agents[agentIdx++] = agent;
Expand Down
1 change: 1 addition & 0 deletions tests/bicyclemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class BicycleKinematicModelTest : public ::testing::Test {
.polylineReductionThreshold = 0.0,
.observationRadius = 100.0,
.collisionBehaviour = gpudrive::CollisionBehaviour::Ignore,
.initOnlyValidAgentsAtFirstStep = false
}
});

Expand Down
Loading