Fix a few issues with the passive viewer.

1. Create an arena for the mjData instance used by the passive viewer visualization.

When using the passive viewer, stuff gets copied from the real mjData into a minimal struct.
That struct didn't have a stack, and now visualization for Flex does stack allocs.

2. Add missing a missing field in scene state for flex visualization.

3. Fix a memory leak where mjvScene wasn't released on exit in the passive viewer.

4. Add some locks in places where the render thread and Simulate::Sync collide.

This fixes #1280.

PiperOrigin-RevId: 591891676
Change-Id: I592f286cab9719c8d9af84e42f9756ea1f9f1971
This commit is contained in:
Nimrod Gileadi
2023-12-18 07:32:20 -08:00
committed by Copybara-Service
parent 8ecb16abfa
commit 7cb7c87f70
9 changed files with 61 additions and 9 deletions
+6 -1
View File
@@ -99,5 +99,10 @@ target_link_libraries(engine_util_spatial_test fixture gmock)
mujoco_test(engine_vfs_test)
target_link_libraries(engine_vfs_test fixture gmock)
mujoco_test(engine_vis_state_test)
mujoco_test(
engine_vis_state_test
PROPERTIES
ENVIRONMENT
"MUJOCO_PLUGIN_DIR=$<TARGET_FILE_DIR:elasticity>"
)
target_link_libraries(engine_vis_state_test fixture gmock)
+4 -4
View File
@@ -35,17 +35,17 @@ static const char* const kTendonPath =
"engine/testdata/island/tendon_wrap.xml";
static const char* const kFrustumPath =
"engine/testdata/vis_visualize/frustum.xml";
static const char* const kModelPath =
"testdata/model.xml";
static const char* const kFlex = "testdata/flex.xml";
static const char* const kModelPath = "testdata/model.xml";
#define EXPECT_ZERO(exp) EXPECT_EQ(0, exp);
TEST_F(MjvSceneStateTest, CanUpdateFromState) {
for (const char* path :
{kHammockPath, kTendonPath, kModelPath, kFrustumPath}) {
{kHammockPath, kTendonPath, kModelPath, kFrustumPath, kFlex}) {
const std::string xml_path = GetTestDataFilePath(path);
mjModel* model = mj_loadXML(xml_path.c_str(), nullptr, 0, 0);
ASSERT_THAT(model, NotNull());
ASSERT_THAT(model, NotNull()) << "Failed to load model from " << path;
mjData* data = mj_makeData(model);
while (data->time < 2) {