Remove user_objetcs and user_model includes from xml_urdf.

PiperOrigin-RevId: 609330384
Change-Id: I19b330e4063d3be4401dcf1b2b957b55e0616037
This commit is contained in:
Alessio Quaglino
2024-02-22 04:53:54 -08:00
committed by Copybara-Service
parent 5fe3e169ab
commit 34d4a69027
3 changed files with 23 additions and 8 deletions
+12
View File
@@ -370,6 +370,18 @@ mjmBody* mjm_findChild(mjmBody* bodyspec, const char* name) {
// find mesh by name
mjmMesh* mjm_findMesh(mjmModel* modelspec, const char* name) {
mjCModel* model = reinterpret_cast<mjCModel*>(modelspec->element);
mjCMesh* mesh = (mjCMesh*)model->FindObject(mjOBJ_MESH, std::string(name));
if (!mesh) {
return nullptr;
}
return &(static_cast<mjCMesh*>(mesh)->spec);
}
// set frame
void mjm_setFrame(mjElement dest, mjmFrame* frame) {
if (!frame) {
+4 -1
View File
@@ -824,11 +824,14 @@ MJAPI mjmModel* mjm_getModel(mjmBody* body);
MJAPI mjmDefault* mjm_getDefault(mjElement element);
// Find body in model by name.
MJAPI mjmBody* mjm_findBody(mjmModel* modelspec, const char* name);
MJAPI mjmBody* mjm_findBody(mjmModel* model, const char* name);
// Find child body by name.
MJAPI mjmBody* mjm_findChild(mjmBody* body, const char* name);
// Find mesh by name.
MJAPI mjmMesh* mjm_findMesh(mjmModel* model, const char* name);
// Get element id.
MJAPI int mjm_getId(mjElement element);
+7 -7
View File
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <array>
#include <cstring>
#include <iostream>
#include <string>
@@ -19,11 +20,10 @@
#include <mujoco/mjmodel.h>
#include "user/user_api.h"
#include "user/user_model.h"
#include "user/user_objects.h"
#include "user/user_util.h"
#include "xml/xml_native_reader.h"
#include "xml/xml_urdf.h"
#include "xml/xml_util.h"
#include "tinyxml2.h"
@@ -575,7 +575,7 @@ mjmGeom* mjXURDF::Geom(XMLElement* geom_elem, mjmBody* pbody, bool collision) {
meshname = mjuu_stripext(meshname);
// look for existing mesh
mjCMesh* mesh = (mjCMesh*)model->FindObject(mjOBJ_MESH, meshname);
mjmMesh* mesh = mjm_findMesh(&model->spec, meshname.c_str());
mjmMesh* pmesh = 0;
// does not exist: create
@@ -584,16 +584,16 @@ mjmGeom* mjXURDF::Geom(XMLElement* geom_elem, mjmBody* pbody, bool collision) {
}
// exists with different scale: append name with '1', create
else if (mesh->spec.scale[0]!=meshscale[0] ||
mesh->spec.scale[1]!=meshscale[1] ||
mesh->spec.scale[2]!=meshscale[2]) {
else if (mesh->scale[0]!=meshscale[0] ||
mesh->scale[1]!=meshscale[1] ||
mesh->scale[2]!=meshscale[2]) {
pmesh = mjm_addMesh(&model->spec, 0);
meshname = meshname + "1";
}
// point to already existing spec
else {
pmesh = &mesh->spec;
pmesh = mesh;
}
// set fields