From fb09d58d47f13839fd21bf79e1dd2457bc057ddb Mon Sep 17 00:00:00 2001 From: qhdwight Date: Fri, 16 Feb 2024 17:48:23 -0500 Subject: [PATCH] Fix collider rendering with new se3 --- src/simulator/simulator.render.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/simulator/simulator.render.cpp b/src/simulator/simulator.render.cpp index 14ed062e4..dfc5c6845 100644 --- a/src/simulator/simulator.render.cpp +++ b/src/simulator/simulator.render.cpp @@ -411,8 +411,8 @@ namespace mrover { URDF::LinkMeta& meta = urdf.linkNameToMeta.at(link->name); SE3d linkInWorld = urdf.linkInWorld(link->name); SE3d modelInLink = btTransformToSe3(urdfPoseToBtTransform(link->visual->origin)); - SE3d modelInWorld = linkInWorld * modelInLink; - renderModel(pass, model, meta.visualUniforms.at(visualIndex), SIM3{modelInWorld, R3::Ones()}); + SE3d modelToWorld = linkInWorld * modelInLink; + renderModel(pass, model, meta.visualUniforms.at(visualIndex), SIM3{modelToWorld, R3::Ones()}); visualIndex++; } } @@ -439,27 +439,27 @@ namespace mrover { assert(collider); btCollisionShape* shape = collider->getCollisionShape(); assert(shape); - SE3d linkInWorld = urdf.linkInWorld(link->name); + SE3d linkToWorld = urdf.linkInWorld(link->name); if (auto* compound = dynamic_cast(shape)) { for (int i = 0; i < compound->getNumChildShapes(); ++i) { SE3d modelInLink = btTransformToSe3(urdfPoseToBtTransform(link->collision_array.at(i)->origin)); - SE3d shapeToWorld = modelInLink * linkInWorld; + SE3d modelInWorld = linkToWorld * modelInLink; auto* shape = compound->getChildShape(i); if (auto* box = dynamic_cast(shape)) { btVector3 extents = box->getHalfExtentsWithoutMargin() * 2; - SIM3 modelToWorld{shapeToWorld, R3{extents.x(), extents.y(), extents.z()}}; + SIM3 modelToWorld{modelInWorld, R3{extents.x(), extents.y(), extents.z()}}; renderModel(pass, mUriToModel.at(CUBE_PRIMITIVE_URI), meta.collisionUniforms.at(i), modelToWorld); } else if (auto* sphere = dynamic_cast(shape)) { btScalar diameter = sphere->getRadius() * 2; - SIM3 modelToWorld{shapeToWorld, R3{diameter, diameter, diameter}}; + SIM3 modelToWorld{modelInWorld, R3{diameter, diameter, diameter}}; renderModel(pass, mUriToModel.at(SPHERE_PRIMITIVE_URI), meta.collisionUniforms.at(i), modelToWorld); } else if (auto* cylinder = dynamic_cast(shape)) { btVector3 extents = cylinder->getHalfExtentsWithoutMargin() * 2; - SIM3 modelToWorld{shapeToWorld, R3{extents.x(), extents.y(), extents.z()}}; + SIM3 modelToWorld{modelInWorld, R3{extents.x(), extents.y(), extents.z()}}; renderModel(pass, mUriToModel.at(CYLINDER_PRIMITIVE_URI), meta.collisionUniforms.at(i), modelToWorld); } else if (auto* mesh = dynamic_cast(shape)) { - SIM3 modelToWorld{shapeToWorld, R3::Ones()}; + SIM3 modelToWorld{modelInWorld, R3::Ones()}; renderModel(pass, mUriToModel.at(mMeshToUri.at(const_cast(mesh))), meta.collisionUniforms.at(i), modelToWorld); } else { NODELET_WARN_STREAM_ONCE(std::format("Tried to render unsupported collision shape: {}", shape->getName()));