Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -222,6 +222,27 @@ void b3GetJointState(b3PhysicsClientHandle physClient, b3SharedMemoryStatusHandl
|
||||
}
|
||||
}
|
||||
|
||||
void b3GetLinkState(b3PhysicsClientHandle physClient, b3SharedMemoryStatusHandle statusHandle, int linkIndex, b3LinkState *state)
|
||||
{
|
||||
const SharedMemoryStatus* status = (const SharedMemoryStatus* ) statusHandle;
|
||||
b3Assert(status);
|
||||
int bodyIndex = status->m_sendActualStateArgs.m_bodyUniqueId;
|
||||
b3Assert(bodyIndex>=0);
|
||||
if (bodyIndex>=0)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
state->m_worldPosition[i] = status->m_sendActualStateArgs.m_linkState[7 * linkIndex + i];
|
||||
state->m_localInertialPosition[i] = status->m_sendActualStateArgs.m_linkLocalInertialFrames[7 * linkIndex + i];
|
||||
}
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
state->m_worldOrientation[i] = status->m_sendActualStateArgs.m_linkState[7 * linkIndex + 3 + i];
|
||||
state->m_localInertialOrientation[i] = status->m_sendActualStateArgs.m_linkLocalInertialFrames[7 * linkIndex + 3 + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b3SharedMemoryCommandHandle b3CreateBoxShapeCommandInit(b3PhysicsClientHandle physClient)
|
||||
{
|
||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||
|
||||
@@ -130,6 +130,7 @@ int b3CreateSensorEnableIMUForLink(b3SharedMemoryCommandHandle commandHandle, in
|
||||
|
||||
b3SharedMemoryCommandHandle b3RequestActualStateCommandInit(b3PhysicsClientHandle physClient,int bodyUniqueId);
|
||||
void b3GetJointState(b3PhysicsClientHandle physClient, b3SharedMemoryStatusHandle statusHandle, int jointIndex, struct b3JointSensorState *state);
|
||||
void b3GetLinkState(b3PhysicsClientHandle physClient, b3SharedMemoryStatusHandle statusHandle, int linkIndex, struct b3LinkState *state);
|
||||
|
||||
b3SharedMemoryCommandHandle b3PickBody(b3PhysicsClientHandle physClient, double rayFromWorldX,
|
||||
double rayFromWorldY, double rayFromWorldZ,
|
||||
|
||||
@@ -82,6 +82,7 @@ struct InteralBodyData
|
||||
int m_testData;
|
||||
|
||||
btTransform m_rootLocalInertialFrame;
|
||||
btAlignedObjectArray<btTransform> m_linkLocalInertialFrames;
|
||||
|
||||
InteralBodyData()
|
||||
:m_multiBody(0),
|
||||
@@ -763,11 +764,18 @@ bool PhysicsServerCommandProcessor::loadUrdf(const char* fileName, const btVecto
|
||||
//disable serialization of the collision objects (they are too big, and the client likely doesn't need them);
|
||||
util->m_memSerializer->m_skipPointers.insert(mb->getBaseCollider(),0);
|
||||
|
||||
bodyHandle->m_linkLocalInertialFrames.reserve(mb->getNumLinks());
|
||||
for (int i=0;i<mb->getNumLinks();i++)
|
||||
{
|
||||
//disable serialization of the collision objects
|
||||
util->m_memSerializer->m_skipPointers.insert(mb->getLink(i).m_collider,0);
|
||||
int urdfLinkIndex = creation.m_mb2urdfLink[i];
|
||||
btScalar mass;
|
||||
btVector3 localInertiaDiagonal(0,0,0);
|
||||
btTransform localInertialFrame;
|
||||
u2b.getMassAndInertia(urdfLinkIndex, mass,localInertiaDiagonal,localInertialFrame);
|
||||
bodyHandle->m_linkLocalInertialFrames.push_back(localInertialFrame);
|
||||
|
||||
std::string* linkName = new std::string(u2b.getLinkName(urdfLinkIndex).c_str());
|
||||
m_data->m_strings.push_back(linkName);
|
||||
util->m_memSerializer->registerNameForPointer(linkName->c_str(),linkName->c_str());
|
||||
@@ -1349,9 +1357,32 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
||||
//}
|
||||
}
|
||||
}
|
||||
btVector3 linkLocalInertialOrigin = body->m_linkLocalInertialFrames[l].getOrigin();
|
||||
btQuaternion linkLocalInertialRotation = body->m_linkLocalInertialFrames[l].getRotation();
|
||||
|
||||
btVector3 linkOrigin = mb->getLink(l).m_cachedWorldTransform.getOrigin();
|
||||
btQuaternion linkRotation = mb->getLink(l).m_cachedWorldTransform.getRotation();
|
||||
|
||||
serverCmd.m_sendActualStateArgs.m_linkState[l*7+0] = linkOrigin.getX();
|
||||
serverCmd.m_sendActualStateArgs.m_linkState[l*7+1] = linkOrigin.getY();
|
||||
serverCmd.m_sendActualStateArgs.m_linkState[l*7+2] = linkOrigin.getZ();
|
||||
serverCmd.m_sendActualStateArgs.m_linkState[l*7+3] = linkRotation.x();
|
||||
serverCmd.m_sendActualStateArgs.m_linkState[l*7+4] = linkRotation.y();
|
||||
serverCmd.m_sendActualStateArgs.m_linkState[l*7+5] = linkRotation.z();
|
||||
serverCmd.m_sendActualStateArgs.m_linkState[l*7+6] = linkRotation.w();
|
||||
|
||||
serverCmd.m_sendActualStateArgs.m_linkLocalInertialFrames[l*7+0] = linkLocalInertialOrigin.getX();
|
||||
serverCmd.m_sendActualStateArgs.m_linkLocalInertialFrames[l*7+1] = linkLocalInertialOrigin.getY();
|
||||
serverCmd.m_sendActualStateArgs.m_linkLocalInertialFrames[l*7+2] = linkLocalInertialOrigin.getZ();
|
||||
|
||||
serverCmd.m_sendActualStateArgs.m_linkLocalInertialFrames[l*7+3] = linkLocalInertialRotation.x();
|
||||
serverCmd.m_sendActualStateArgs.m_linkLocalInertialFrames[l*7+4] = linkLocalInertialRotation.y();
|
||||
serverCmd.m_sendActualStateArgs.m_linkLocalInertialFrames[l*7+5] = linkLocalInertialRotation.z();
|
||||
serverCmd.m_sendActualStateArgs.m_linkLocalInertialFrames[l*7+6] = linkLocalInertialRotation.w();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
serverCmd.m_sendActualStateArgs.m_numDegreeOfFreedomQ = totalDegreeOfFreedomQ;
|
||||
serverCmd.m_sendActualStateArgs.m_numDegreeOfFreedomU = totalDegreeOfFreedomU;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define MAX_NUM_SENSORS 256
|
||||
#define MAX_URDF_FILENAME_LENGTH 1024
|
||||
#define MAX_FILENAME_LENGTH MAX_URDF_FILENAME_LENGTH
|
||||
#define MAX_NUM_LINKS MAX_DEGREE_OF_FREEDOM
|
||||
|
||||
struct TmpFloat3
|
||||
{
|
||||
@@ -196,6 +197,9 @@ struct SendActualStateArgs
|
||||
double m_jointReactionForces[6*MAX_DEGREE_OF_FREEDOM];
|
||||
|
||||
double m_jointMotorForce[MAX_DEGREE_OF_FREEDOM];
|
||||
|
||||
double m_linkState[7*MAX_NUM_LINKS];
|
||||
double m_linkLocalInertialFrames[7*MAX_NUM_LINKS];
|
||||
};
|
||||
|
||||
enum EnumSensorTypes
|
||||
|
||||
@@ -105,6 +105,20 @@ struct b3DebugLines
|
||||
const float* m_linesColor;//float red,green,blue times 'm_numDebugLines'.
|
||||
};
|
||||
|
||||
///b3LinkState provides extra information such as the Cartesian world coordinates
|
||||
///center of mass (COM) of the link, relative to the world reference frame.
|
||||
///Orientation is a quaternion x,y,z,w
|
||||
///Note: to compute the URDF link frame (which equals the joint frame at joint position 0)
|
||||
///use URDF link frame = link COM frame * inertiaFrame.inverse()
|
||||
struct b3LinkState
|
||||
{
|
||||
double m_worldPosition[3];
|
||||
double m_worldOrientation[4];
|
||||
|
||||
double m_localInertialPosition[3];
|
||||
double m_localInertialOrientation[4];
|
||||
};
|
||||
|
||||
//todo: discuss and decide about control mode and combinations
|
||||
enum {
|
||||
// POSITION_CONTROL=0,
|
||||
|
||||
Reference in New Issue
Block a user