-
Notifications
You must be signed in to change notification settings - Fork 21
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
Export render and depth tensors #78
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7bb1945
Update mgr.cpp
aaravpandya 2d4ad38
Fix viewer
aaravpandya 88ccb10
Merge branch 'main' into FixViewer
aaravpandya 09ed737
Fix padding agent values on reset
aaravpandya 60db2c3
Render padding agents too
aaravpandya 7f3ab55
Merge branch 'FixValues' into FixViewer
aaravpandya b225ae8
Export valid state
SamanKazemkhani 25171ae
Fix mean calculations (#84)
aaravpandya a3bbae0
Local rendering (#79)
SamanKazemkhani ba6ac85
Add scale to road observations (#83)
aaravpandya 06ad38c
merge main
aaravpandya 61f42fb
Fix scale road issue
aaravpandya 27cfb56
save progress
aaravpandya 145794d
Looking good
aaravpandya cde55c4
Merge branch 'main' into FixViewer
aaravpandya 2388548
Add json for viewer
aaravpandya 9296cd8
Remove M_PI sub
aaravpandya af4ebcd
Reintroduce means
aaravpandya 7689d24
Remove floor plane
aaravpandya 70dbc0d
Merge branch 'main' into FixViewer
aaravpandya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,48 @@ | |
#include <fstream> | ||
#include <optional> | ||
|
||
#include <iostream> | ||
// #include "json_serialization.hpp" | ||
#include <nlohmann/json.hpp> | ||
|
||
using namespace madrona; | ||
using namespace madrona::viz; | ||
|
||
std::pair<float, float> calc_mean(const nlohmann::json &j) | ||
{ | ||
std::pair<float, float> 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<float> readReplayLog(const char *path) { | ||
std::ifstream replay_log(path, std::ios::binary); | ||
replay_log.seekg(0, std::ios::end); | ||
|
@@ -65,18 +104,19 @@ int main(int argc, char *argv[]) | |
#endif | ||
|
||
WindowManager wm {}; | ||
WindowHandle window = wm.makeWindow("Escape Room", 2730, 1536); | ||
WindowHandle window = wm.makeWindow("Escape Room", 640, 480); | ||
render::GPUHandle render_gpu = wm.initGPU(0, { window.get() }); | ||
|
||
Manager mgr({ | ||
.execMode = exec_mode, | ||
.gpuID = 0, | ||
.numWorlds = num_worlds, | ||
.autoReset = replay_log.has_value(), | ||
.jsonPath = "../maps", | ||
.jsonPath = "/home/aarav/gpudrive/nocturne_data", | ||
.params = { | ||
.polylineReductionThreshold = 1.0, | ||
.observationRadius = 100.0, | ||
.maxNumControlledVehicles = 0 | ||
}, | ||
.enableBatchRenderer = enable_batch_renderer, | ||
.extRenderAPI = wm.gpuAPIManager().backend(), | ||
|
@@ -88,11 +128,27 @@ 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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid hardcoding if possible. Maybe we can assume a relative path? |
||
std::string mapPath; | ||
for (auto const &mapFile : std::filesystem::directory_iterator(path)) | ||
{ | ||
if (mapFile.path().extension() == ".json") | ||
{ | ||
mapPath = mapFile.path().string(); | ||
break; | ||
} | ||
} | ||
std::cout<<mapPath<<std::endl; | ||
std::ifstream in(mapPath); | ||
nlohmann::json rawJson; | ||
in >> rawJson; | ||
auto mean = calc_mean(rawJson); | ||
|
||
Viewer viewer(mgr.getRenderManager(), window.get(), { | ||
.numWorlds = num_worlds, | ||
.simTickRate = 20, | ||
.cameraMoveSpeed = 20.f, | ||
.cameraPosition = 20.f * math::up, | ||
.cameraPosition = mean.first * math::right + mean.second*math::fwd + 100.f * math::up, | ||
.cameraRotation = initial_camera_rotation, | ||
}); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SamanKazemkhani I vaguely remember a comment about this elsewhere too?