| #pragma once |
|
|
| #include <madrona/taskgraph_builder.hpp> |
| #include <madrona/custom_context.hpp> |
|
|
| #include "consts.hpp" |
| #include "types.hpp" |
| #include "init.hpp" |
| #include "rng.hpp" |
|
|
| namespace madrona_gpudrive { |
|
|
| class Engine; |
|
|
| |
| |
| enum class ExportID : uint32_t { |
| Reset, |
| Action, |
| Reward, |
| Done, |
| SelfObservation, |
| PartnerObservations, |
| AgentMapObservations, |
| Lidar, |
| BevObservations, |
| StepsRemaining, |
| BicycleModel, |
| MapObservation, |
| Shape, |
| ControlledState, |
| AbsoluteSelfObservation, |
| ValidState, |
| Info, |
| ResponseType, |
| Trajectory, |
| Map, |
| ResetMap, |
| WorldMeans, |
| MetaData, |
| DeletedAgents, |
| MapName, |
| ScenarioId, |
| NumExports |
| }; |
|
|
| |
| |
| enum class SimObject : uint32_t { |
| Cube, |
| Agent, |
| StopSign, |
| SpeedBump, |
| Plane, |
| NumObjects, |
| }; |
|
|
| enum class TaskGraphID : uint32_t { |
| Step, |
| Reset, |
| NumTaskGraphs, |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| struct Sim : public madrona::WorldBase { |
| struct Config { |
| const madrona::render::RenderECSBridge *renderBridge; |
| bool enableLidar = false; |
| }; |
|
|
| |
| |
| static void registerTypes(madrona::ECSRegistry ®istry, |
| const Config &cfg); |
|
|
| |
| |
| |
| static void setupTasks(madrona::TaskGraphManager &taskgraph_mgr, |
| const Config &cfg); |
|
|
| const std::pair<EntityType,EntityType> collisionPairs[20] = { |
| {EntityType::Pedestrian, EntityType::RoadEdge}, |
| {EntityType::Pedestrian, EntityType::RoadLine}, |
| {EntityType::Pedestrian, EntityType::RoadLane}, |
| {EntityType::Pedestrian, EntityType::CrossWalk}, |
| {EntityType::Pedestrian, EntityType::SpeedBump}, |
| {EntityType::Cyclist, EntityType::RoadEdge}, |
| {EntityType::Cyclist, EntityType::RoadLine}, |
| {EntityType::Cyclist, EntityType::RoadLane}, |
| {EntityType::Cyclist, EntityType::CrossWalk}, |
| {EntityType::Cyclist, EntityType::SpeedBump}, |
| {EntityType::Vehicle, EntityType::CrossWalk}, |
| {EntityType::Vehicle, EntityType::SpeedBump}, |
| {EntityType::Vehicle, EntityType::RoadLine}, |
| {EntityType::Vehicle, EntityType::RoadLane}}; |
|
|
| |
| |
| |
| Sim(Engine &ctx, |
| const Config &cfg, |
| const WorldInit &init); |
|
|
| |
| |
| EpisodeManager *episodeMgr; |
|
|
| |
| RNG rng; |
|
|
| |
| Entity floorPlane; |
|
|
| |
| |
| Entity borders[3]; |
|
|
| |
| |
| madrona::CountT numAgents; |
| Entity agents[consts::kMaxAgentCount]; |
| madrona::CountT numRoads; |
| Entity roads[consts::kMaxRoadEntityCount]; |
|
|
| Entity agent_ifaces[consts::kMaxAgentCount]; |
| Entity road_ifaces[consts::kMaxRoadEntityCount]; |
|
|
| Entity camera_agent; |
|
|
| madrona::CountT numControlledAgents; |
|
|
| Parameters params; |
|
|
| |
| int32_t curEpisodeIdx; |
|
|
| |
| bool enableRender; |
| }; |
|
|
| class Engine : public ::madrona::CustomContext<Engine, Sim> { |
| public: |
| using CustomContext::CustomContext; |
|
|
| |
| |
| template <typename ArchetypeT> |
| inline madrona::Entity makeRenderableEntity(); |
| inline void destroyRenderableEntity(Entity e); |
| }; |
|
|
| } |
|
|
| #include "sim.inl" |
|
|