Creating a mesh geom progammatically #2623
Replies: 4 comments
-
Hi, strings can be assigned with mjs_setString, since the memory it's managed internally you can't assign a user-managed pointer to the name directly. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer. Yes, I used mjs_setString before (for joints & actuators) but in this case it makes the code crash:
The first mjs_setString call works (for mesh->name) but the second one crashes. And it seems to make sense, since geom->meshname is a null pointer.
|
Beta Was this translation helpful? Give feedback.
-
Ah, wait, found it. It's because of that call to mjs_defaultGeom() in my code:
For some reason it nullifies "meshname". This did not create issues with other geoms and it looked like a good idea to initialize everything to default values, but I guess this was a mistake. Without that call I am now getting new error messages about the actual mesh data, so this first problem is fixed. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Alright, it all works now. Excellent. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Intro
Hello, I am interested in physics engines and starting to learn MuJoCo.
My setup
MuJoCo 3.2.2, C API, Windows
My question
I need help creating a mesh geom from code (i.e. without loading the data from a file). Everything else works (box, sphere, capsule, cylinder) but meshes do not. I am getting errors like these, so it seems it is just the names (rather than the mesh data) that are wrong. It makes sense, as the other geoms did not need names:
Code is basically like this:
Am I missing a step or doing something wrong? Note that I managed to use names before to map actuators to joints, but for some reason it does not work for mapping meshes to geoms.
Minimal model and/or code that explain my question
No response
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions