diff --git a/source/RobotAPI/components/RobotState/SharedRobotServants.cpp b/source/RobotAPI/components/RobotState/SharedRobotServants.cpp index 3f78deea41d9139c9248fc10024d6b73ed38c5d2..94d35b724d947e9c1cfd7e2351e1c5fdd18aa943 100644 --- a/source/RobotAPI/components/RobotState/SharedRobotServants.cpp +++ b/source/RobotAPI/components/RobotState/SharedRobotServants.cpp @@ -277,6 +277,32 @@ namespace armarx return _node->getJointLimitLow(); } + Vector3BasePtr SharedRobotNodeServant::getCoM(const Current& current) const + { + ReadLockPtr lock = _node->getRobot()->getReadLock(); + return new Vector3(_node->getCoMLocal()); + } + + FloatSeq SharedRobotNodeServant::getInertia(const Current& current) const + { + ReadLockPtr lock = _node->getRobot()->getReadLock(); + FloatSeq result; + + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + { + result.push_back(_node->getInertiaMatrix()(i, j)); + } + + return result; + } + + float SharedRobotNodeServant::getMass(const Current& current) const + { + ReadLockPtr lock = _node->getRobot()->getReadLock(); + return _node->getMass(); + } + /////////////////////////////// // SharedRobotServant diff --git a/source/RobotAPI/components/RobotState/SharedRobotServants.h b/source/RobotAPI/components/RobotState/SharedRobotServants.h index ffb43145a0476a69e7969fd716311413f95f0365..bf48eef8e2da125b9d4495bc10fe0ce343308b04 100644 --- a/source/RobotAPI/components/RobotState/SharedRobotServants.h +++ b/source/RobotAPI/components/RobotState/SharedRobotServants.h @@ -72,7 +72,7 @@ namespace armarx */ class SharedRobotNodeServant : virtual public SharedRobotNodeInterface, - public SharedObjectBase + public SharedObjectBase { public: SharedRobotNodeServant(VirtualRobot::RobotNodePtr node /*,const Ice::Current & current = Ice::Current()*/); @@ -98,6 +98,10 @@ namespace armarx virtual float getJointLimitHigh(const Ice::Current& current = Ice::Current()) const; virtual float getJointLimitLow(const Ice::Current& current = Ice::Current()) const; + virtual Vector3BasePtr getCoM(const Ice::Current& current = Ice::Current()) const; + virtual Ice::FloatSeq getInertia(const Ice::Current& current = Ice::Current()) const; + virtual float getMass(const Ice::Current& current = Ice::Current()) const; + protected: diff --git a/source/RobotAPI/interface/core/RobotState.ice b/source/RobotAPI/interface/core/RobotState.ice index 8db9ea88f97194426603e449fe9f149bf3e82f33..056ef0c53f99599b49bf7b8ed7d7f6d846cbf504 100644 --- a/source/RobotAPI/interface/core/RobotState.ice +++ b/source/RobotAPI/interface/core/RobotState.ice @@ -28,6 +28,8 @@ #include <RobotAPI/interface/units/PlatformUnitInterface.ice> #include <RobotAPI/interface/core/FramedPoseBase.ice> #include <ArmarXCore/interface/observers/Timestamp.ice> +#include <ArmarXCore/interface/core/BasicTypes.ice> +#include <Ice/BuiltinSequences.ice> module armarx { @@ -115,6 +117,15 @@ module armarx ["cpp:const"] idempotent float getJointLimitLow(); + ["cpp:const"] idempotent + Vector3Base getCoM(); + + ["cpp:const"] idempotent + Ice::FloatSeq getInertia(); + + ["cpp:const"] idempotent + float getMass(); + }; diff --git a/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp b/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp index a75392014800b19193af241b99232e4ef240b2d9..3cb73dba296fc23c108ab0d74f929323af6b8b13 100644 --- a/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp +++ b/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp @@ -234,6 +234,16 @@ namespace armarx JointType jt = remoteNode->getType(); + SceneObject::Physics physics; + physics.localCoM = Vector3Ptr::dynamicCast(remoteNode->getCoM())->toEigen(); + std::vector<float> inertia = remoteNode->getInertia(); + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + { + physics.inertiaMatrix(i, j) = inertia.at(i * 3 + j); + } + physics.massKg = remoteNode->getMass(); + switch (jt) { case ePrismatic: @@ -248,13 +258,13 @@ namespace armarx axis = result4f.block(0, 0, 3, 1); result = prismaticNodeFactory->createRobotNode(robo, name, VirtualRobot::VisualizationNodePtr(), VirtualRobot::CollisionModelPtr(), - jvLo, jvHi, jointOffset, idMatrix, idVec3, axis); + jvLo, jvHi, jointOffset, idMatrix, idVec3, axis, physics); } break; case eFixed: result = fixedNodeFactory->createRobotNode(robo, name, VirtualRobot::VisualizationNodePtr(), VirtualRobot::CollisionModelPtr(), 0, - 0, 0, localTransform, idVec3, idVec3); + 0, 0, localTransform, idVec3, idVec3, physics); break; case eRevolute: @@ -269,7 +279,7 @@ namespace armarx axis = result4f.block(0, 0, 3, 1); result = revoluteNodeFactory->createRobotNode(robo, name, VirtualRobot::VisualizationNodePtr(), VirtualRobot::CollisionModelPtr(), - jvLo, jvHi, jointOffset, localTransform, axis, idVec3); + jvLo, jvHi, jointOffset, localTransform, axis, idVec3, physics); } break;