Improve studio 2D plots
PiperOrigin-RevId: 842260702 Change-Id: I4644b69da92b9d015eb2d140b98f68c05d31a222
This commit is contained in:
committed by
Copybara-Service
parent
5b1fa666fb
commit
32d7b87ba7
@@ -737,7 +737,9 @@ void ControlsGui(const mjModel* model, const mjData* data,
|
||||
|
||||
|
||||
void ConvergenceGui(const mjModel* model, mjData* data) {
|
||||
if (ImPlot::BeginPlot("Convergence (log 10)", ImVec2(-1, 0))) {
|
||||
if (ImPlot::BeginPlot("Convergence (log 10)", ImVec2(-1, 0),
|
||||
ImPlotFlags_NoMouseText)) {
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 2.0f);
|
||||
ImPlot::SetupAxis(ImAxis_X1, "iteration", ImPlotAxisFlags_AutoFit);
|
||||
ImPlot::SetupAxisLimits(ImAxis_X1, 0, 20, ImPlotCond_Always);
|
||||
ImPlot::SetupAxisFormat(ImAxis_Y1, "%.1f");
|
||||
@@ -751,7 +753,6 @@ void ConvergenceGui(const mjModel* model, mjData* data) {
|
||||
const int npoints =
|
||||
mjMIN(mjMIN(data->solver_niter[k], mjNSOLVER), mjMAXLINEPNT);
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("improvement", +[](int i, void* user_data) {
|
||||
const mjSolverStat* stats = static_cast<const mjSolverStat*>(user_data);
|
||||
const float x = static_cast<float>(i);
|
||||
@@ -763,7 +764,6 @@ void ConvergenceGui(const mjModel* model, mjData* data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("gradient", +[](int i, void* user_data) {
|
||||
const mjSolverStat* stats = static_cast<const mjSolverStat*>(user_data);
|
||||
const float x = static_cast<float>(i);
|
||||
@@ -771,7 +771,6 @@ void ConvergenceGui(const mjModel* model, mjData* data) {
|
||||
return ImPlotPoint{x, y};
|
||||
}, stats, npoints);
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("lineslope", +[](int i, void* user_data) {
|
||||
const mjSolverStat* stats = static_cast<const mjSolverStat*>(user_data);
|
||||
const float x = static_cast<float>(i);
|
||||
@@ -780,12 +779,14 @@ void ConvergenceGui(const mjModel* model, mjData* data) {
|
||||
}, stats, npoints);
|
||||
}
|
||||
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
|
||||
void CountsGui(const mjModel* model, mjData* data) {
|
||||
if (ImPlot::BeginPlot("Counts", ImVec2(-1, 0))) {
|
||||
if (ImPlot::BeginPlot("Counts", ImVec2(-1, 0), ImPlotFlags_NoMouseText)) {
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 2.0f);
|
||||
ImPlot::SetupAxis(ImAxis_X1, "iteration", ImPlotAxisFlags_AutoFit);
|
||||
ImPlot::SetupAxisLimits(ImAxis_X1, 0, 20, ImPlotCond_Always);
|
||||
ImPlot::SetupAxisFormat(ImAxis_Y1, "%.0f");
|
||||
@@ -802,14 +803,12 @@ void CountsGui(const mjModel* model, mjData* data) {
|
||||
|
||||
int nefc = nisland == 1 ? data->nefc : data->island_nefc[k];
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("total", +[](int i, void* user_data) {
|
||||
const float x = static_cast<float>(i);
|
||||
const float y = *(static_cast<int*>(user_data));
|
||||
return ImPlotPoint{x, y};
|
||||
}, &nefc, npoints);
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("active", +[](int i, void* user_data) {
|
||||
const mjSolverStat* stats = static_cast<const mjSolverStat*>(user_data);
|
||||
const float x = static_cast<float>(i);
|
||||
@@ -817,7 +816,6 @@ void CountsGui(const mjModel* model, mjData* data) {
|
||||
return ImPlotPoint{x, y};
|
||||
}, stats, npoints);
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("changed", +[](int i, void* user_data) {
|
||||
const mjSolverStat* stats = static_cast<const mjSolverStat*>(user_data);
|
||||
const float x = static_cast<float>(i);
|
||||
@@ -829,7 +827,6 @@ void CountsGui(const mjModel* model, mjData* data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("evals", +[](int i, void* user_data) {
|
||||
const mjSolverStat* stats = static_cast<const mjSolverStat*>(user_data);
|
||||
const float x = static_cast<float>(i);
|
||||
@@ -841,7 +838,6 @@ void CountsGui(const mjModel* model, mjData* data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ImPlot::SetNextLineStyle(IMPLOT_AUTO_COL, 3.0f);
|
||||
ImPlot::PlotLineG("updates", +[](int i, void* user_data) {
|
||||
const mjSolverStat* stats = static_cast<const mjSolverStat*>(user_data);
|
||||
const float x = static_cast<float>(i);
|
||||
@@ -850,6 +846,7 @@ void CountsGui(const mjModel* model, mjData* data) {
|
||||
}, stats, npoints);
|
||||
}
|
||||
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,9 @@ void SimProfiler::Update(const mjModel* model, const mjData* data) {
|
||||
return;
|
||||
}
|
||||
|
||||
mjtNum avg_total = total / number;
|
||||
cpu_total_.erase(cpu_total_.begin());
|
||||
cpu_total_.push_back(total / number);
|
||||
cpu_total_.push_back(avg_total);
|
||||
|
||||
mjtNum collision = data->timer[mjTIMER_POS_COLLISION].duration / number;
|
||||
cpu_collision_.erase(cpu_collision_.begin());
|
||||
@@ -80,7 +81,7 @@ void SimProfiler::Update(const mjModel* model, const mjData* data) {
|
||||
cpu_solve_.erase(cpu_solve_.begin());
|
||||
cpu_solve_.push_back(solve);
|
||||
|
||||
mjtNum other = total - collision - prepare - solve;
|
||||
mjtNum other = avg_total - collision - prepare - solve;
|
||||
cpu_other_.erase(cpu_other_.begin());
|
||||
cpu_other_.push_back(other);
|
||||
|
||||
@@ -119,7 +120,8 @@ void SimProfiler::Update(const mjModel* model, const mjData* data) {
|
||||
|
||||
|
||||
void SimProfiler::CpuTimeGraph() {
|
||||
if (ImPlot::BeginPlot("CPU Time", ImVec2(-1, 0))) {
|
||||
if (ImPlot::BeginPlot("CPU Time", ImVec2(-1, 0), ImPlotFlags_NoMouseText)) {
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 2.0f);
|
||||
ImPlot::SetupAxis(ImAxis_X1, "frame", ImPlotAxisFlags_AutoFit);
|
||||
ImPlot::SetupAxis(ImAxis_Y1, "msec", ImPlotAxisFlags_AutoFit);
|
||||
ImPlot::SetupAxisFormat(ImAxis_Y1, "%.2f");
|
||||
@@ -136,12 +138,14 @@ void SimProfiler::CpuTimeGraph() {
|
||||
1, -(int)cpu_collision_.size());
|
||||
ImPlot::PlotLine("other", cpu_other_.data(), cpu_other_.size(), 1,
|
||||
-(int)cpu_other_.size());
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
|
||||
void SimProfiler::DimensionsGraph() {
|
||||
if (ImPlot::BeginPlot("Dimensions", ImVec2(-1, 0))) {
|
||||
if (ImPlot::BeginPlot("Dimensions", ImVec2(-1, 0), ImPlotFlags_NoMouseText)) {
|
||||
ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 2.0f);
|
||||
ImPlot::SetupAxis(ImAxis_X1, "frame", ImPlotAxisFlags_AutoFit);
|
||||
ImPlot::SetupAxis(ImAxis_Y1, "count", ImPlotAxisFlags_AutoFit);
|
||||
ImPlot::SetupAxisFormat(ImAxis_Y1, "%.0f");
|
||||
@@ -160,6 +164,7 @@ void SimProfiler::DimensionsGraph() {
|
||||
-(int)dim_contact_.size());
|
||||
ImPlot::PlotLine("iteration", dim_iteration_.data(), dim_iteration_.size(),
|
||||
1, -(int)dim_iteration_.size());
|
||||
ImPlot::PopStyleVar();
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user