From b79988e6b507db331a56bc02f61f73cb15d77038 Mon Sep 17 00:00:00 2001 From: Aarav Pandya Date: Sun, 5 May 2024 16:34:51 -0400 Subject: [PATCH] Remove means from viewer --- src/CMakeLists.txt | 2 +- src/viewer.cpp | 59 +++------------------------------------------- 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 072809c3e..b119ce878 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,7 +70,7 @@ target_link_libraries(gpudrive PRIVATE if (TARGET madrona_viz) add_executable(viewer viewer.cpp) target_link_libraries(viewer PRIVATE - madrona_mw_core gpudrive_mgr madrona_viz nlohmann_json::nlohmann_json) + madrona_mw_core gpudrive_mgr madrona_viz) target_compile_definitions(viewer PRIVATE -DDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../data/" diff --git a/src/viewer.cpp b/src/viewer.cpp index 2ed199fac..03de84651 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp @@ -9,47 +9,10 @@ #include #include -// #include "json_serialization.hpp" -#include using namespace madrona; using namespace madrona::viz; -std::pair calc_mean(const nlohmann::json &j) -{ - std::pair mean = {0, 0}; - int64_t numEntities = 0; - for (const auto &obj : j["objects"]) - { - int i = 0; - for (const auto &pos : obj["position"]) - { - if (obj["valid"][i++] == false) - continue; - numEntities++; - float newX = pos["x"]; - float newY = pos["y"]; - // Update mean incrementally - mean.first += (newX - mean.first) / numEntities; - mean.second += (newY - mean.second) / numEntities; - } - } - for (const auto &obj : j["roads"]) - { - for (const auto &point : obj["geometry"]) - { - numEntities++; - float newX = point["x"]; - float newY = point["y"]; - - // Update mean incrementally - mean.first += (newX - mean.first) / numEntities; - mean.second += (newY - mean.second) / numEntities; - } - } - return mean; -} - static HeapArray readReplayLog(const char *path) { std::ifstream replay_log(path, std::ios::binary); replay_log.seekg(0, std::ios::end); @@ -112,7 +75,7 @@ int main(int argc, char *argv[]) .gpuID = 0, .numWorlds = num_worlds, .autoReset = replay_log.has_value(), - .jsonPath = "/home/aarav/gpudrive/nocturne_data", + .jsonPath = "tests/testJsons", .params = { .polylineReductionThreshold = 1.0, .observationRadius = 100.0, @@ -128,27 +91,11 @@ int main(int argc, char *argv[]) (math::Quat::angleAxis(0, math::up) * math::Quat::angleAxis(-math::pi / 2.f, math::right)).normalize(); - std::string path = "/home/aarav/gpudrive/nocturne_data"; - std::string mapPath; - for (auto const &mapFile : std::filesystem::directory_iterator(path)) - { - if (mapFile.path().extension() == ".json") - { - mapPath = mapFile.path().string(); - break; - } - } - std::cout<> rawJson; - auto mean = calc_mean(rawJson); - - Viewer viewer(mgr.getRenderManager(), window.get(), { + Viewer viewer(mgr.getRenderManager(), window.get(), { .numWorlds = num_worlds, .simTickRate = 20, .cameraMoveSpeed = 20.f, - .cameraPosition = mean.first * math::right + mean.second*math::fwd + 100.f * math::up, + .cameraPosition = 100.f * math::up, .cameraRotation = initial_camera_rotation, });