Add mjmBody and mjmPlugin and their compiler C APIs.

PiperOrigin-RevId: 604937231
Change-Id: Ib8a2105ce6c0500d6a610258b46f192d9e73169d
This commit is contained in:
Alessio Quaglino
2024-02-07 04:16:20 -08:00
committed by Copybara-Service
parent b9c50ad79c
commit a3e49d582e
17 changed files with 626 additions and 332 deletions
+17
View File
@@ -17,6 +17,7 @@
#include "src/engine/engine_plugin.h"
#include <array>
#include <cstdint>
#include <sstream>
#include <string>
@@ -421,6 +422,22 @@ constexpr char xml[] = R"(
</mujoco>
)";
TEST_F(MujocoTest, EmptyPluginDisallowed) {
static constexpr char xml[] = R"(
<mujoco>
<worldbody>
<plugin/>
</worldbody>
</mujoco>
)";
std::array<char, 1024> error;
mjModel* m = LoadModelFromString(xml, error.data(), error.size());
EXPECT_THAT(m, testing::IsNull()) << error.data();
EXPECT_THAT(error.data(), HasSubstr(
"neither 'plugin' nor 'instance' is specified for body 'world'"));
mj_deleteModel(m);
}
TEST_F(PluginTest, FirstPartyPlugins) {
EXPECT_THAT(mjp_pluginCount(), kNumTruePlugins);
}
+2 -3
View File
@@ -18,7 +18,6 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "src/user/user_api.h"
#include <mujoco/mjmodel.h>
#include "test/fixture.h"
namespace mujoco {
@@ -31,8 +30,8 @@ using ::testing::HasSubstr;
TEST_F(MujocoTest, ReadWriteData) {
void* model = mjm_createModel();
void* world = mjm_findObject(model, mjOBJ_BODY, "world");
void* body = mjm_addBody(world, 0);
mjmBody* world = mjm_findBody(model, "world");
mjmBody* body = mjm_addBody(world, 0);
mjmSite* site = mjm_addSite(body, 0);
{