Add mjs_bodyToFrame() to convert a body to a frame.

Also add test for attaching the world body.

PiperOrigin-RevId: 685603933
Change-Id: I3cfe7d226d6f032b5a587e44d0f4f18207977188
This commit is contained in:
Alessio Quaglino
2024-10-14 00:38:26 -07:00
committed by Copybara-Service
parent 52a0149cd1
commit 766cd20273
12 changed files with 169 additions and 6 deletions
+11
View File
@@ -666,6 +666,17 @@ const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* s
// Transform body into a frame.
mjsFrame* mjs_bodyToFrame(mjsBody** body) {
mjCBody* bodyC = static_cast<mjCBody*>((*body)->element);
mjCFrame* frameC = bodyC->ToFrame();
delete bodyC;
*body = nullptr;
return &frameC->spec;
}
// get id
int mjs_getId(mjsElement* element) {
if (!element) {