Skip to content

Commit

Permalink
Remove padding agents using interface entities (#103)
Browse files Browse the repository at this point in the history
* Init remove padding agents

* Testing

* Refactor out the controlled state

* Fix the tests

* Use by reference

* Temp fix for map export

* cleanup

* Fix merge issues

* Fix merge issues

* make consts 6000 to pass tests

* Use init counts for BVH

* Remove unused function

* Pass all tests

* Set controlledstate

* Zero out things

* Zero padded agents out

* Add a test.py for easy debugging

* Better check for map drawing.

* Set agents to 128

* Cycle through files in test.py

* Rename InterfaceEntity to AgentInterfaceEntity

* Only print dones

* Remove debug checks

* Separete out the observation systems

* Sort interfaces

* remove debug script

* Remove debug statements

* Minor improvements

* Info tensor interface matches main

* Correctly export response type and trajectory
  • Loading branch information
aaravpandya committed Oct 23, 2024
1 parent e3efd03 commit cdba83e
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 271 deletions.
2 changes: 1 addition & 1 deletion pygpudrive/env/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def draw_map(self, surf, map_info, world_render_idx=0):
"""Draw static map elements."""
for idx, map_obj in enumerate(map_info):

if map_obj[-1] == float(gpudrive.EntityType.Padding):
if map_obj[-1] == float(gpudrive.EntityType.Padding) or map_obj[-1] == float(gpudrive.EntityType._None):
continue

elif map_obj[-1] <= float(gpudrive.EntityType.RoadLane):
Expand Down
2 changes: 1 addition & 1 deletion src/consts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <limits>
#include <madrona/math.hpp>
#include <madrona/types.hpp>

namespace gpudrive {

namespace consts {
Expand Down
2 changes: 1 addition & 1 deletion src/dynamics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace madrona::math;
namespace gpudrive
{

inline void forwardKinematics(Action &action, VehicleSize &size, Rotation &rotation, Position &position, Velocity &velocity)
inline void forwardKinematics(const Action &action, VehicleSize &size, Rotation &rotation, Position &position, Velocity &velocity)
{
const float maxSpeed{std::numeric_limits<float>::max()};
const float dt{0.1};
Expand Down
13 changes: 7 additions & 6 deletions src/headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ int main(int argc, char *argv[])
// printf("Reward\n");
// rewardPrinter.print();

// printf("Done\n");
// donePrinter.print();
printf("Done\n");
donePrinter.print();

// printf("Controlled State\n");
// controlledStatePrinter.print();

printf("Agent Map Obs\n");
agent_map_obs_printer.print();
// printf("Agent Map Obs\n");
// agent_map_obs_printer.print();

printf("Info\n");
info_printer.print();
// printf("Info\n");
// info_printer.print();
};

auto worldToShape =
Expand All @@ -133,6 +133,7 @@ int main(int argc, char *argv[])
}
const auto end = std::chrono::steady_clock::now();
const std::chrono::duration<double> elapsed = end - start;
printObs();

float fps = (double)num_steps * (double)num_worlds / elapsed.count();
printf("FPS %f\n", fps);
Expand Down
3 changes: 2 additions & 1 deletion src/knn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ bool isObservationsValid(gpudrive::Engine &ctx,
sortedObservations.reserve(roadCount);

for (madrona::CountT roadIdx = 0; roadIdx < roadCount; ++roadIdx) {
auto &road_iface = ctx.get<gpudrive::RoadInterfaceEntity>(ctx.data().roads[roadIdx]).e;
const auto &currentObservation =
ctx.get<gpudrive::MapObservation>(ctx.data().roads[roadIdx]);
ctx.get<gpudrive::MapObservation>(road_iface);
sortedObservations.emplace_back(relativeObservation(
currentObservation, referenceRotation, referencePosition));
}
Expand Down
186 changes: 79 additions & 107 deletions src/level_gen.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ Tensor Manager::agentMapObservationsTensor() const
TensorElementType::Float32,
{
impl_->numWorlds,
consts::kMaxAgentCount,
consts::kMaxAgentCount,
consts::kMaxAgentMapObservationsCount,
AgentMapObservationExportSize,
});
Expand Down
Loading

0 comments on commit cdba83e

Please sign in to comment.