2015-09-25 05:50:34 +00:00
|
|
|
#include "PhysicsClientSharedMemory.h"
|
|
|
|
#include "PosixSharedMemory.h"
|
|
|
|
#include "Win32SharedMemory.h"
|
2018-05-16 19:10:34 +00:00
|
|
|
#include "Bullet3Common/b3AlignedObjectArray.h"
|
|
|
|
#include "Bullet3Common/b3Vector3.h"
|
2015-11-11 20:44:26 +00:00
|
|
|
#include <string.h>
|
2018-05-16 19:10:34 +00:00
|
|
|
#include "Bullet3Common/b3HashMap.h"
|
2015-09-25 05:50:34 +00:00
|
|
|
#include "Bullet3Common/b3Logging.h"
|
|
|
|
#include "../Utils/b3ResourcePath.h"
|
|
|
|
#include "../../Extras/Serialize/BulletFileLoader/btBulletFile.h"
|
|
|
|
#include "../../Extras/Serialize/BulletFileLoader/autogenerated/bullet.h"
|
|
|
|
#include "SharedMemoryBlock.h"
|
2015-11-23 04:50:32 +00:00
|
|
|
#include "BodyJointInfoUtility.h"
|
2018-06-02 20:40:08 +00:00
|
|
|
#include "SharedMemoryUserData.h"
|
2018-06-16 13:19:49 +00:00
|
|
|
#include "LinearMath/btQuickprof.h"
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2015-10-13 18:32:25 +00:00
|
|
|
struct BodyJointInfoCache
|
|
|
|
{
|
2016-09-27 19:13:45 +00:00
|
|
|
std::string m_baseName;
|
2018-05-16 19:10:34 +00:00
|
|
|
b3AlignedObjectArray<b3JointInfo> m_jointInfo;
|
2017-03-29 22:37:33 +00:00
|
|
|
std::string m_bodyName;
|
2018-07-03 15:45:19 +00:00
|
|
|
btAlignedObjectArray<int> m_userDataIds;
|
2019-03-27 01:13:04 +00:00
|
|
|
int m_numDofs;
|
2018-09-23 21:17:31 +00:00
|
|
|
~BodyJointInfoCache()
|
2018-06-02 20:40:08 +00:00
|
|
|
{
|
|
|
|
}
|
2015-10-13 18:32:25 +00:00
|
|
|
};
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
struct PhysicsClientSharedMemoryInternalData
|
|
|
|
{
|
|
|
|
SharedMemoryInterface* m_sharedMemory;
|
|
|
|
bool m_ownsSharedMemory;
|
|
|
|
SharedMemoryBlock* m_testBlock1;
|
2018-06-16 13:19:49 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
btAlignedObjectArray<CProfileSample*> m_profileTimings;
|
2018-06-16 16:37:53 +00:00
|
|
|
btHashMap<btHashString, std::string*> m_profileTimingStringArray;
|
2018-06-16 13:19:49 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
btHashMap<btHashInt, BodyJointInfoCache*> m_bodyJointMap;
|
|
|
|
btHashMap<btHashInt, b3UserConstraint> m_userConstraintInfoMap;
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
btAlignedObjectArray<TmpFloat3> m_debugLinesFrom;
|
|
|
|
btAlignedObjectArray<TmpFloat3> m_debugLinesTo;
|
|
|
|
btAlignedObjectArray<TmpFloat3> m_debugLinesColor;
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2016-05-31 17:23:04 +00:00
|
|
|
int m_cachedCameraPixelsWidth;
|
|
|
|
int m_cachedCameraPixelsHeight;
|
2018-06-02 20:40:08 +00:00
|
|
|
btAlignedObjectArray<unsigned char> m_cachedCameraPixelsRGBA;
|
|
|
|
btAlignedObjectArray<float> m_cachedCameraDepthBuffer;
|
|
|
|
btAlignedObjectArray<int> m_cachedSegmentationMaskBuffer;
|
2018-05-16 19:10:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
btAlignedObjectArray<b3ContactPointData> m_cachedContactPoints;
|
2018-06-02 20:40:08 +00:00
|
|
|
btAlignedObjectArray<b3OverlappingObject> m_cachedOverlappingObjects;
|
|
|
|
btAlignedObjectArray<b3VisualShapeData> m_cachedVisualShapes;
|
|
|
|
btAlignedObjectArray<b3CollisionShapeData> m_cachedCollisionShapes;
|
2018-05-16 19:10:34 +00:00
|
|
|
|
2018-06-02 20:40:08 +00:00
|
|
|
btAlignedObjectArray<b3VRControllerEvent> m_cachedVREvents;
|
|
|
|
btAlignedObjectArray<b3KeyboardEvent> m_cachedKeyboardEvents;
|
|
|
|
btAlignedObjectArray<b3MouseEvent> m_cachedMouseEvents;
|
|
|
|
btAlignedObjectArray<double> m_cachedMassMatrix;
|
2018-09-23 21:17:31 +00:00
|
|
|
btAlignedObjectArray<b3RayHitInfo> m_raycastHits;
|
2018-05-16 19:10:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
btAlignedObjectArray<int> m_bodyIdsRequestInfo;
|
2018-06-02 20:40:08 +00:00
|
|
|
btAlignedObjectArray<int> m_constraintIdsRequestInfo;
|
|
|
|
|
2018-07-03 15:45:19 +00:00
|
|
|
btAlignedObjectArray<int> m_userDataIdsRequestInfo;
|
|
|
|
btHashMap<btHashInt, SharedMemoryUserData> m_userDataMap;
|
|
|
|
btHashMap<SharedMemoryUserDataHashKey, int> m_userDataHandleLookup;
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
SharedMemoryStatus m_tempBackupServerStatus;
|
|
|
|
|
|
|
|
SharedMemoryStatus m_lastServerStatus;
|
2017-01-23 03:08:31 +00:00
|
|
|
|
2019-03-07 07:27:59 +00:00
|
|
|
SendActualStateSharedMemoryStorage m_cachedState;
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
int m_counter;
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool m_isConnected;
|
|
|
|
bool m_waitingForServer;
|
|
|
|
bool m_hasLastServerStatus;
|
|
|
|
int m_sharedMemoryKey;
|
|
|
|
bool m_verboseOutput;
|
2017-02-24 23:34:11 +00:00
|
|
|
double m_timeOutInSeconds;
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2019-03-07 07:27:59 +00:00
|
|
|
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
PhysicsClientSharedMemoryInternalData()
|
|
|
|
: m_sharedMemory(0),
|
2016-03-10 22:36:46 +00:00
|
|
|
m_ownsSharedMemory(false),
|
2018-09-23 21:17:31 +00:00
|
|
|
m_testBlock1(0),
|
2016-05-31 17:23:04 +00:00
|
|
|
m_cachedCameraPixelsWidth(0),
|
|
|
|
m_cachedCameraPixelsHeight(0),
|
2018-09-23 21:17:31 +00:00
|
|
|
m_counter(0),
|
|
|
|
m_isConnected(false),
|
|
|
|
m_waitingForServer(false),
|
|
|
|
m_hasLastServerStatus(false),
|
|
|
|
m_sharedMemoryKey(SHARED_MEMORY_KEY),
|
|
|
|
m_verboseOutput(false),
|
2017-10-25 15:15:01 +00:00
|
|
|
m_timeOutInSeconds(1e30)
|
2018-09-23 21:17:31 +00:00
|
|
|
{
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
void processServerStatus();
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool canSubmitCommand() const;
|
2015-09-25 05:50:34 +00:00
|
|
|
};
|
|
|
|
|
2016-09-27 19:13:45 +00:00
|
|
|
int PhysicsClientSharedMemory::getNumBodies() const
|
|
|
|
{
|
|
|
|
return m_data->m_bodyJointMap.size();
|
|
|
|
}
|
2015-11-11 20:44:26 +00:00
|
|
|
|
2016-09-27 19:13:45 +00:00
|
|
|
int PhysicsClientSharedMemory::getBodyUniqueId(int serialIndex) const
|
2015-10-13 18:32:25 +00:00
|
|
|
{
|
2016-09-27 19:13:45 +00:00
|
|
|
if ((serialIndex >= 0) && (serialIndex < getNumBodies()))
|
|
|
|
{
|
|
|
|
return m_data->m_bodyJointMap.getKeyAtIndex(serialIndex).getUid1();
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PhysicsClientSharedMemory::getBodyInfo(int bodyUniqueId, struct b3BodyInfo& info) const
|
|
|
|
{
|
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache* bodyJoints = *bodyJointsPtr;
|
2018-09-23 21:17:31 +00:00
|
|
|
strcpy(info.m_baseName, bodyJoints->m_baseName.c_str());
|
|
|
|
strcpy(info.m_bodyName, bodyJoints->m_bodyName.c_str());
|
2016-09-27 19:13:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-17 00:12:59 +00:00
|
|
|
|
2016-09-27 19:13:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
int PhysicsClientSharedMemory::getNumJoints(int bodyUniqueId) const
|
2016-09-27 19:13:45 +00:00
|
|
|
{
|
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
2015-10-13 18:32:25 +00:00
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache* bodyJoints = *bodyJointsPtr;
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
return bodyJoints->m_jointInfo.size();
|
2015-10-13 18:32:25 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2019-03-26 22:07:55 +00:00
|
|
|
int PhysicsClientSharedMemory::getNumDofs(int bodyUniqueId) const
|
|
|
|
{
|
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache* bodyJoints = *bodyJointsPtr;
|
|
|
|
return bodyJoints->m_numDofs;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-27 19:13:45 +00:00
|
|
|
bool PhysicsClientSharedMemory::getJointInfo(int bodyUniqueId, int jointIndex, b3JointInfo& info) const
|
2015-10-13 18:32:25 +00:00
|
|
|
{
|
2016-09-27 19:13:45 +00:00
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
2015-10-13 18:32:25 +00:00
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache* bodyJoints = *bodyJointsPtr;
|
2016-11-04 20:15:10 +00:00
|
|
|
if ((jointIndex >= 0) && (jointIndex < bodyJoints->m_jointInfo.size()))
|
|
|
|
{
|
|
|
|
info = bodyJoints->m_jointInfo[jointIndex];
|
2018-11-13 22:32:18 +00:00
|
|
|
info.m_qSize = 0;
|
|
|
|
info.m_uSize = 0;
|
2018-11-10 22:26:31 +00:00
|
|
|
switch (info.m_jointType)
|
|
|
|
{
|
|
|
|
case eSphericalType:
|
|
|
|
{
|
|
|
|
info.m_qSize = 4;//quaterion x,y,z,w
|
|
|
|
info.m_uSize = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ePlanarType:
|
|
|
|
{
|
|
|
|
info.m_qSize = 2;
|
|
|
|
info.m_uSize = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ePrismaticType:
|
|
|
|
case eRevoluteType:
|
|
|
|
{
|
|
|
|
info.m_qSize = 1;
|
|
|
|
info.m_uSize = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2016-11-04 20:15:10 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-10-13 18:32:25 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
return false;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 03:08:31 +00:00
|
|
|
int PhysicsClientSharedMemory::getNumUserConstraints() const
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
return m_data->m_userConstraintInfoMap.size();
|
2017-01-23 03:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PhysicsClientSharedMemory::getUserConstraintInfo(int constraintUniqueId, struct b3UserConstraint& info) const
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
b3UserConstraint* constraintPtr = m_data->m_userConstraintInfoMap[constraintUniqueId];
|
|
|
|
if (constraintPtr)
|
|
|
|
{
|
|
|
|
info = *constraintPtr;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2017-01-23 03:08:31 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 01:25:25 +00:00
|
|
|
int PhysicsClientSharedMemory::getUserConstraintId(int serialIndex) const
|
|
|
|
{
|
|
|
|
if ((serialIndex >= 0) && (serialIndex < getNumUserConstraints()))
|
|
|
|
{
|
|
|
|
return m_data->m_userConstraintInfoMap.getKeyAtIndex(serialIndex).getUid1();
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-09-25 05:50:34 +00:00
|
|
|
PhysicsClientSharedMemory::PhysicsClientSharedMemory()
|
|
|
|
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data = new PhysicsClientSharedMemoryInternalData;
|
2015-09-25 05:50:34 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_sharedMemory = new Win32SharedMemoryClient();
|
2015-09-25 05:50:34 +00:00
|
|
|
#else
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_sharedMemory = new PosixSharedMemory();
|
2015-09-25 05:50:34 +00:00
|
|
|
#endif
|
2016-03-10 22:36:46 +00:00
|
|
|
m_data->m_ownsSharedMemory = true;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
PhysicsClientSharedMemory::~PhysicsClientSharedMemory()
|
|
|
|
{
|
|
|
|
if (m_data->m_isConnected)
|
|
|
|
{
|
|
|
|
disconnectSharedMemory();
|
|
|
|
}
|
2017-01-23 03:08:31 +00:00
|
|
|
resetData();
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < m_data->m_profileTimingStringArray.size(); i++)
|
2018-06-16 16:37:53 +00:00
|
|
|
{
|
|
|
|
std::string** str = m_data->m_profileTimingStringArray.getAtIndex(i);
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
delete *str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_data->m_profileTimingStringArray.clear();
|
|
|
|
|
2016-03-10 22:36:46 +00:00
|
|
|
if (m_data->m_ownsSharedMemory)
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
delete m_data->m_sharedMemory;
|
2016-03-10 22:36:46 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
delete m_data;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 04:53:29 +00:00
|
|
|
void PhysicsClientSharedMemory::removeCachedBody(int bodyUniqueId)
|
|
|
|
{
|
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < (*bodyJointsPtr)->m_userDataIds.size(); i++)
|
|
|
|
{
|
2018-07-03 15:45:19 +00:00
|
|
|
const int userDataId = (*bodyJointsPtr)->m_userDataIds[i];
|
2018-09-23 21:17:31 +00:00
|
|
|
SharedMemoryUserData* userData = m_data->m_userDataMap[userDataId];
|
2018-07-03 15:45:19 +00:00
|
|
|
m_data->m_userDataHandleLookup.remove(SharedMemoryUserDataHashKey(userData));
|
|
|
|
m_data->m_userDataMap.remove(userDataId);
|
|
|
|
}
|
2017-05-04 04:53:29 +00:00
|
|
|
delete (*bodyJointsPtr);
|
|
|
|
m_data->m_bodyJointMap.remove(bodyUniqueId);
|
|
|
|
}
|
|
|
|
}
|
2017-01-23 03:08:31 +00:00
|
|
|
void PhysicsClientSharedMemory::resetData()
|
|
|
|
{
|
|
|
|
m_data->m_debugLinesFrom.clear();
|
|
|
|
m_data->m_debugLinesTo.clear();
|
|
|
|
m_data->m_debugLinesColor.clear();
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < m_data->m_bodyJointMap.size(); i++)
|
2017-01-23 03:08:31 +00:00
|
|
|
{
|
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
delete (*bodyJointsPtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_data->m_bodyJointMap.clear();
|
|
|
|
m_data->m_userConstraintInfoMap.clear();
|
2018-07-03 15:45:19 +00:00
|
|
|
m_data->m_userDataHandleLookup.clear();
|
|
|
|
m_data->m_userDataMap.clear();
|
2017-01-23 03:08:31 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
void PhysicsClientSharedMemory::setSharedMemoryKey(int key)
|
|
|
|
{
|
|
|
|
m_data->m_sharedMemoryKey = key;
|
2017-08-15 00:02:20 +00:00
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2016-03-10 22:36:46 +00:00
|
|
|
void PhysicsClientSharedMemory::setSharedMemoryInterface(class SharedMemoryInterface* sharedMem)
|
|
|
|
{
|
2017-08-15 00:02:20 +00:00
|
|
|
if (sharedMem)
|
2016-03-10 22:36:46 +00:00
|
|
|
{
|
2017-08-15 00:02:20 +00:00
|
|
|
if (m_data->m_sharedMemory && m_data->m_ownsSharedMemory)
|
|
|
|
{
|
|
|
|
delete m_data->m_sharedMemory;
|
|
|
|
}
|
|
|
|
m_data->m_ownsSharedMemory = false;
|
|
|
|
m_data->m_sharedMemory = sharedMem;
|
|
|
|
};
|
2016-03-10 22:36:46 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
void PhysicsClientSharedMemory::disconnectSharedMemory()
|
|
|
|
{
|
|
|
|
if (m_data->m_isConnected && m_data->m_sharedMemory)
|
|
|
|
{
|
|
|
|
m_data->m_sharedMemory->releaseSharedMemory(m_data->m_sharedMemoryKey, SHARED_MEMORY_SIZE);
|
|
|
|
}
|
2016-03-10 22:36:46 +00:00
|
|
|
m_data->m_isConnected = false;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool PhysicsClientSharedMemory::isConnected() const
|
|
|
|
{
|
2017-08-30 02:14:27 +00:00
|
|
|
return m_data->m_isConnected && (m_data->m_testBlock1->m_magicId == SHARED_MEMORY_MAGIC_NUMBER);
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool PhysicsClientSharedMemory::connect()
|
|
|
|
{
|
|
|
|
/// server always has to create and initialize shared memory
|
|
|
|
bool allowCreation = false;
|
|
|
|
m_data->m_testBlock1 = (SharedMemoryBlock*)m_data->m_sharedMemory->allocateSharedMemory(
|
|
|
|
m_data->m_sharedMemoryKey, SHARED_MEMORY_SIZE, allowCreation);
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_testBlock1)
|
|
|
|
{
|
|
|
|
if (m_data->m_testBlock1->m_magicId != SHARED_MEMORY_MAGIC_NUMBER)
|
|
|
|
{
|
Improve debug text/line rendering, can be use to draw frames and text in local coordinate of an object / link.
example:
kuka = p.loadURDF("kuka_iiwa/model.urdf")
p.getNumJoints(kuka)
pybullet.addUserDebugLine([0,0,0],[0,0,0.1],[0,0,1],trackObjectUniqueId=2,trackLinkIndex=6)
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],trackObjectUniqueId=2,trackLinkIndex=6)
Also allow to render text using a given orientation (instead of pointing to the camera), example:
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],textOrientation=[0,0,0,1], trackObjectUniqueId=2,trackLinkIndex=6)
Add drawTexturedTriangleMesh, for drawing 3d text.
Expose readSingleInstanceTransformToCPU, to extract position/orientation from graphics index.
updateTexture: allow to not flip texels around up axis
2017-05-24 05:05:26 +00:00
|
|
|
//there is no chance people are still using this software 100 years from now ;-)
|
2018-09-23 21:17:31 +00:00
|
|
|
if ((m_data->m_testBlock1->m_magicId < 211705023) &&
|
|
|
|
(m_data->m_testBlock1->m_magicId >= 201705023))
|
Improve debug text/line rendering, can be use to draw frames and text in local coordinate of an object / link.
example:
kuka = p.loadURDF("kuka_iiwa/model.urdf")
p.getNumJoints(kuka)
pybullet.addUserDebugLine([0,0,0],[0,0,0.1],[0,0,1],trackObjectUniqueId=2,trackLinkIndex=6)
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],trackObjectUniqueId=2,trackLinkIndex=6)
Also allow to render text using a given orientation (instead of pointing to the camera), example:
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],textOrientation=[0,0,0,1], trackObjectUniqueId=2,trackLinkIndex=6)
Add drawTexturedTriangleMesh, for drawing 3d text.
Expose readSingleInstanceTransformToCPU, to extract position/orientation from graphics index.
updateTexture: allow to not flip texels around up axis
2017-05-24 05:05:26 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Error("Error: physics server version mismatch (expected %d got %d)\n", SHARED_MEMORY_MAGIC_NUMBER, m_data->m_testBlock1->m_magicId);
|
|
|
|
}
|
|
|
|
else
|
Improve debug text/line rendering, can be use to draw frames and text in local coordinate of an object / link.
example:
kuka = p.loadURDF("kuka_iiwa/model.urdf")
p.getNumJoints(kuka)
pybullet.addUserDebugLine([0,0,0],[0,0,0.1],[0,0,1],trackObjectUniqueId=2,trackLinkIndex=6)
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],trackObjectUniqueId=2,trackLinkIndex=6)
Also allow to render text using a given orientation (instead of pointing to the camera), example:
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],textOrientation=[0,0,0,1], trackObjectUniqueId=2,trackLinkIndex=6)
Add drawTexturedTriangleMesh, for drawing 3d text.
Expose readSingleInstanceTransformToCPU, to extract position/orientation from graphics index.
updateTexture: allow to not flip texels around up axis
2017-05-24 05:05:26 +00:00
|
|
|
{
|
|
|
|
b3Error("Error connecting to shared memory: please start server before client\n");
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_sharedMemory->releaseSharedMemory(m_data->m_sharedMemoryKey,
|
|
|
|
SHARED_MEMORY_SIZE);
|
|
|
|
m_data->m_testBlock1 = 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Connected to existing shared memory, status OK.\n");
|
|
|
|
}
|
|
|
|
m_data->m_isConnected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//b3Warning("Cannot connect to shared memory");
|
|
|
|
return false;
|
|
|
|
}
|
2016-11-17 00:12:59 +00:00
|
|
|
#if 0
|
|
|
|
if (m_data->m_isConnected)
|
|
|
|
{
|
|
|
|
//get all existing bodies and body info...
|
|
|
|
|
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
//now transfer the information of the individual objects etc.
|
|
|
|
command.m_type = CMD_REQUEST_BODY_INFO;
|
|
|
|
command.m_sdfRequestInfoArgs.m_bodyUniqueId = 37;
|
|
|
|
submitClientCommand(command);
|
2017-02-22 17:33:30 +00:00
|
|
|
|
|
|
|
double startTime = clock.getTimeInSeconds();
|
|
|
|
double timeOutInSeconds = 10;
|
|
|
|
|
2016-11-17 00:12:59 +00:00
|
|
|
const SharedMemoryStatus* status = 0;
|
|
|
|
|
2017-02-22 17:33:30 +00:00
|
|
|
while ((status == 0) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
2016-11-17 00:12:59 +00:00
|
|
|
{
|
|
|
|
status = processServerStatus();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//submitClientCommand(command);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2018-09-23 21:17:31 +00:00
|
|
|
return true;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2016-06-16 01:01:41 +00:00
|
|
|
///todo(erwincoumans) refactor this: merge with PhysicsDirect::processBodyJointInfo
|
|
|
|
void PhysicsClientSharedMemory::processBodyJointInfo(int bodyUniqueId, const SharedMemoryStatus& serverCmd)
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
bParse::btBulletFile bf(
|
|
|
|
&this->m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[0],
|
|
|
|
serverCmd.m_numDataStreamBytes);
|
|
|
|
bf.setFileDNAisMemoryDNA();
|
|
|
|
bf.parse(false);
|
|
|
|
|
|
|
|
BodyJointInfoCache* bodyJoints = new BodyJointInfoCache;
|
|
|
|
m_data->m_bodyJointMap.insert(bodyUniqueId, bodyJoints);
|
2017-03-29 22:37:33 +00:00
|
|
|
bodyJoints->m_bodyName = serverCmd.m_dataStreamArguments.m_bodyName;
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < bf.m_multiBodies.size(); i++)
|
|
|
|
{
|
|
|
|
int flag = bf.getFlags();
|
|
|
|
if ((flag & bParse::FD_DOUBLE_PRECISION) != 0)
|
|
|
|
{
|
|
|
|
Bullet::btMultiBodyDoubleData* mb =
|
|
|
|
(Bullet::btMultiBodyDoubleData*)bf.m_multiBodies[i];
|
|
|
|
|
2016-09-27 19:13:45 +00:00
|
|
|
bodyJoints->m_baseName = mb->m_baseName;
|
2018-09-23 21:17:31 +00:00
|
|
|
addJointInfoFromMultiBodyData(mb, bodyJoints, m_data->m_verboseOutput);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Bullet::btMultiBodyFloatData* mb =
|
|
|
|
(Bullet::btMultiBodyFloatData*)bf.m_multiBodies[i];
|
2016-09-27 19:13:45 +00:00
|
|
|
bodyJoints->m_baseName = mb->m_baseName;
|
2018-09-23 21:17:31 +00:00
|
|
|
addJointInfoFromMultiBodyData(mb, bodyJoints, m_data->m_verboseOutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bf.ok())
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Received robot description ok!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
b3Warning("Robot description not received");
|
|
|
|
}
|
2016-06-16 01:01:41 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
void addJointInfoFromConstraint(int linkIndex, const T* con, U* bodyJoints, bool verboseOutput)
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
|
|
|
b3JointInfo info;
|
2017-10-04 01:01:53 +00:00
|
|
|
info.m_jointName[0] = 0;
|
|
|
|
info.m_linkName[0] = 0;
|
2017-08-30 02:14:27 +00:00
|
|
|
info.m_flags = 0;
|
|
|
|
info.m_jointIndex = linkIndex;
|
2018-09-23 21:17:31 +00:00
|
|
|
info.m_qIndex = linkIndex + 7;
|
|
|
|
info.m_uIndex = linkIndex + 6;
|
2017-08-30 02:14:27 +00:00
|
|
|
//derive type from limits
|
|
|
|
|
|
|
|
if (con->m_typeConstraintData.m_name)
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
strcpy(info.m_jointName, con->m_typeConstraintData.m_name);
|
|
|
|
|
2017-08-30 02:14:27 +00:00
|
|
|
//info.m_linkName = strDup(con->m_typeConstraintData.m_name);
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
btVector3 linearLowerLimit(con->m_linearLowerLimit.m_floats[0], con->m_linearLowerLimit.m_floats[1], con->m_linearLowerLimit.m_floats[2]);
|
|
|
|
btVector3 linearUpperLimit(con->m_linearUpperLimit.m_floats[0], con->m_linearUpperLimit.m_floats[1], con->m_linearUpperLimit.m_floats[2]);
|
|
|
|
btVector3 angularLowerLimit(con->m_angularLowerLimit.m_floats[0], con->m_angularLowerLimit.m_floats[1], con->m_angularLowerLimit.m_floats[2]);
|
|
|
|
btVector3 angularUpperLimit(con->m_angularUpperLimit.m_floats[0], con->m_angularUpperLimit.m_floats[1], con->m_angularUpperLimit.m_floats[2]);
|
|
|
|
|
2017-08-30 02:14:27 +00:00
|
|
|
//very simple, rudimentary extraction of constaint type, from limits
|
|
|
|
info.m_jointType = eFixedType;
|
2018-09-23 21:17:31 +00:00
|
|
|
info.m_jointDamping = 0; //mb->m_links[link].m_jointDamping;
|
|
|
|
info.m_jointFriction = 0; //mb->m_links[link].m_jointFriction;
|
|
|
|
info.m_jointLowerLimit = 0; //mb->m_links[link].m_jointLowerLimit;
|
|
|
|
info.m_jointUpperLimit = 0; //mb->m_links[link].m_jointUpperLimit;
|
|
|
|
info.m_jointMaxForce = 0; //mb->m_links[link].m_jointMaxForce;
|
|
|
|
info.m_jointMaxVelocity = 0; //mb->m_links[link].m_jointMaxVelocity;
|
2017-08-30 02:14:27 +00:00
|
|
|
|
|
|
|
if (linearLowerLimit.isZero() && linearUpperLimit.isZero() && angularLowerLimit.isZero() && angularUpperLimit.isZero())
|
|
|
|
{
|
|
|
|
info.m_jointType = eFixedType;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
|
|
|
if (linearLowerLimit.isZero() && linearUpperLimit.isZero())
|
|
|
|
{
|
|
|
|
info.m_jointType = eRevoluteType;
|
2018-09-23 21:17:31 +00:00
|
|
|
btVector3 limitRange = angularLowerLimit.absolute() + angularUpperLimit.absolute();
|
2017-08-30 02:14:27 +00:00
|
|
|
int limitAxis = limitRange.maxAxis();
|
|
|
|
info.m_jointLowerLimit = angularLowerLimit[limitAxis];
|
|
|
|
info.m_jointUpperLimit = angularUpperLimit[limitAxis];
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
|
|
|
info.m_jointType = ePrismaticType;
|
2018-09-23 21:17:31 +00:00
|
|
|
btVector3 limitRange = linearLowerLimit.absolute() + linearUpperLimit.absolute();
|
2017-08-30 02:14:27 +00:00
|
|
|
int limitAxis = limitRange.maxAxis();
|
|
|
|
info.m_jointLowerLimit = linearLowerLimit[limitAxis];
|
|
|
|
info.m_jointUpperLimit = linearUpperLimit[limitAxis];
|
|
|
|
}
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2017-08-30 02:14:27 +00:00
|
|
|
//if (mb->m_links[link].m_linkName) {
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2017-08-30 02:14:27 +00:00
|
|
|
if ((info.m_jointType == eRevoluteType) ||
|
2018-09-23 21:17:31 +00:00
|
|
|
(info.m_jointType == ePrismaticType))
|
|
|
|
{
|
2017-08-30 02:14:27 +00:00
|
|
|
info.m_flags |= JOINT_HAS_MOTORIZED_POWER;
|
|
|
|
}
|
|
|
|
bodyJoints->m_jointInfo.push_back(info);
|
|
|
|
};
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus()
|
|
|
|
{
|
|
|
|
// SharedMemoryStatus* stat = 0;
|
|
|
|
|
|
|
|
if (!m_data->m_testBlock1)
|
|
|
|
{
|
2016-03-10 22:36:46 +00:00
|
|
|
m_data->m_lastServerStatus.m_type = CMD_SHARED_MEMORY_NOT_INITIALIZED;
|
|
|
|
return &m_data->m_lastServerStatus;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (!m_data->m_waitingForServer)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_testBlock1->m_magicId != SHARED_MEMORY_MAGIC_NUMBER)
|
|
|
|
{
|
|
|
|
m_data->m_lastServerStatus.m_type = CMD_SHARED_MEMORY_NOT_INITIALIZED;
|
|
|
|
return &m_data->m_lastServerStatus;
|
|
|
|
}
|
2016-03-10 22:36:46 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_testBlock1->m_numServerCommands >
|
|
|
|
m_data->m_testBlock1->m_numProcessedServerCommands)
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("processServerCMD");
|
2018-09-23 21:17:31 +00:00
|
|
|
btAssert(m_data->m_testBlock1->m_numServerCommands ==
|
|
|
|
m_data->m_testBlock1->m_numProcessedServerCommands + 1);
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
const SharedMemoryStatus& serverCmd = m_data->m_testBlock1->m_serverCommands[0];
|
2019-03-07 07:27:59 +00:00
|
|
|
|
|
|
|
if (serverCmd.m_type==CMD_ACTUAL_STATE_UPDATE_COMPLETED)
|
|
|
|
{
|
|
|
|
SendActualStateSharedMemoryStorage* serverState = (SendActualStateSharedMemoryStorage*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
|
|
|
m_data->m_cachedState = *serverState;
|
|
|
|
//ideally we provided a 'getCachedState' but that would require changing the API, so we store a pointer instead.
|
|
|
|
m_data->m_testBlock1->m_serverCommands[0].m_sendActualStateArgs.m_stateDetails = &m_data->m_cachedState;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_lastServerStatus = serverCmd;
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
// EnumSharedMemoryServerStatus s = (EnumSharedMemoryServerStatus)serverCmd.m_type;
|
|
|
|
// consume the command
|
2015-11-23 04:50:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
switch (serverCmd.m_type)
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_CLIENT_COMMAND_COMPLETED:
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_CLIENT_COMMAND_COMPLETED");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server completed command");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-12-31 22:43:15 +00:00
|
|
|
|
|
|
|
case CMD_MJCF_LOADING_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_MJCF_LOADING_COMPLETED");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server loading the MJCF OK\n");
|
|
|
|
}
|
|
|
|
break;
|
2016-12-31 22:43:15 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_SDF_LOADING_COMPLETED:
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_SDF_LOADING_COMPLETED");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server loading the SDF OK\n");
|
|
|
|
}
|
2016-11-04 20:15:10 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-06-03 17:57:56 +00:00
|
|
|
|
|
|
|
case CMD_CREATE_MULTI_BODY_COMPLETED:
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_URDF_LOADING_COMPLETED:
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_URDF_LOADING_COMPLETED");
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server loading the URDF OK\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serverCmd.m_numDataStreamBytes > 0)
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
bParse::btBulletFile bf(
|
|
|
|
this->m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor,
|
|
|
|
serverCmd.m_numDataStreamBytes);
|
|
|
|
bf.setFileDNAisMemoryDNA();
|
|
|
|
bf.parse(false);
|
2016-09-27 19:13:45 +00:00
|
|
|
int bodyUniqueId = serverCmd.m_dataStreamArguments.m_bodyUniqueId;
|
2015-10-13 18:32:25 +00:00
|
|
|
|
|
|
|
BodyJointInfoCache* bodyJoints = new BodyJointInfoCache;
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_bodyJointMap.insert(bodyUniqueId, bodyJoints);
|
2017-03-29 22:37:33 +00:00
|
|
|
bodyJoints->m_bodyName = serverCmd.m_dataStreamArguments.m_bodyName;
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < bf.m_constraints.size(); i++)
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
|
|
|
int flag = bf.getFlags();
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
if ((flag & bParse::FD_DOUBLE_PRECISION) != 0)
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
Bullet::btGeneric6DofSpring2ConstraintDoubleData2* con =
|
|
|
|
(Bullet::btGeneric6DofSpring2ConstraintDoubleData2*)bf.m_constraints[i];
|
|
|
|
addJointInfoFromConstraint(i, con, bodyJoints, m_data->m_verboseOutput);
|
|
|
|
}
|
|
|
|
else
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
Bullet::btGeneric6DofSpring2ConstraintData* con =
|
|
|
|
(Bullet::btGeneric6DofSpring2ConstraintData*)bf.m_constraints[i];
|
|
|
|
addJointInfoFromConstraint(i, con, bodyJoints, m_data->m_verboseOutput);
|
2017-08-30 02:14:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < bf.m_multiBodies.size(); i++)
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
int flag = bf.getFlags();
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if ((flag & bParse::FD_DOUBLE_PRECISION) != 0)
|
2017-08-30 02:14:27 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
Bullet::btMultiBodyDoubleData* mb =
|
|
|
|
(Bullet::btMultiBodyDoubleData*)bf.m_multiBodies[i];
|
2017-03-03 19:33:20 +00:00
|
|
|
if (mb->m_baseName)
|
|
|
|
{
|
|
|
|
bodyJoints->m_baseName = mb->m_baseName;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
addJointInfoFromMultiBodyData(mb, bodyJoints, m_data->m_verboseOutput);
|
|
|
|
}
|
|
|
|
else
|
2015-11-23 04:50:32 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
Bullet::btMultiBodyFloatData* mb =
|
|
|
|
(Bullet::btMultiBodyFloatData*)bf.m_multiBodies[i];
|
2017-03-03 19:33:20 +00:00
|
|
|
if (mb->m_baseName)
|
|
|
|
{
|
|
|
|
bodyJoints->m_baseName = mb->m_baseName;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
addJointInfoFromMultiBodyData(mb, bodyJoints, m_data->m_verboseOutput);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bf.ok())
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Received robot description ok!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
b3Warning("Robot description not received");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_DESIRED_STATE_RECEIVED_COMPLETED:
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_DESIRED_STATE_RECEIVED_COMPLETED");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server received desired state");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_STEP_FORWARD_SIMULATION_COMPLETED:
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_STEP_FORWARD_SIMULATION_COMPLETED");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server completed step simulation");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_URDF_LOADING_FAILED:
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_URDF_LOADING_FAILED");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server failed loading the URDF...\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2017-10-19 02:15:35 +00:00
|
|
|
case CMD_USER_CONSTRAINT_REQUEST_STATE_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-01-23 03:08:31 +00:00
|
|
|
case CMD_USER_CONSTRAINT_INFO_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_USER_CONSTRAINT_INFO_COMPLETED");
|
|
|
|
|
|
|
|
int cid = serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId;
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_userConstraintInfoMap.insert(cid, serverCmd.m_userConstraintResultArgs);
|
2017-01-23 03:08:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_USER_CONSTRAINT_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_USER_CONSTRAINT_COMPLETED");
|
2017-01-23 03:08:31 +00:00
|
|
|
int cid = serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId;
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_userConstraintInfoMap.insert(cid, serverCmd.m_userConstraintResultArgs);
|
2017-01-23 03:08:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REMOVE_USER_CONSTRAINT_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_REMOVE_USER_CONSTRAINT_COMPLETED");
|
2017-01-23 03:08:31 +00:00
|
|
|
int cid = serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId;
|
|
|
|
m_data->m_userConstraintInfoMap.remove(cid);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CHANGE_USER_CONSTRAINT_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CHANGE_USER_CONSTRAINT_COMPLETED");
|
|
|
|
|
2017-01-23 03:08:31 +00:00
|
|
|
int cid = serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId;
|
|
|
|
b3UserConstraint* userConstraintPtr = m_data->m_userConstraintInfoMap[cid];
|
|
|
|
if (userConstraintPtr)
|
|
|
|
{
|
|
|
|
const b3UserConstraint* serverConstraint = &serverCmd.m_userConstraintResultArgs;
|
|
|
|
if (serverCmd.m_updateFlags & USER_CONSTRAINT_CHANGE_PIVOT_IN_B)
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
userConstraintPtr->m_childFrame[0] = serverConstraint->m_childFrame[0];
|
|
|
|
userConstraintPtr->m_childFrame[1] = serverConstraint->m_childFrame[1];
|
|
|
|
userConstraintPtr->m_childFrame[2] = serverConstraint->m_childFrame[2];
|
2017-01-23 03:08:31 +00:00
|
|
|
}
|
|
|
|
if (serverCmd.m_updateFlags & USER_CONSTRAINT_CHANGE_FRAME_ORN_IN_B)
|
|
|
|
{
|
|
|
|
userConstraintPtr->m_childFrame[3] = serverConstraint->m_childFrame[3];
|
|
|
|
userConstraintPtr->m_childFrame[4] = serverConstraint->m_childFrame[4];
|
|
|
|
userConstraintPtr->m_childFrame[5] = serverConstraint->m_childFrame[5];
|
|
|
|
userConstraintPtr->m_childFrame[6] = serverConstraint->m_childFrame[6];
|
|
|
|
}
|
|
|
|
if (serverCmd.m_updateFlags & USER_CONSTRAINT_CHANGE_MAX_FORCE)
|
|
|
|
{
|
|
|
|
userConstraintPtr->m_maxAppliedForce = serverConstraint->m_maxAppliedForce;
|
|
|
|
}
|
2017-10-22 18:03:41 +00:00
|
|
|
if (serverCmd.m_updateFlags & USER_CONSTRAINT_CHANGE_GEAR_RATIO)
|
|
|
|
{
|
|
|
|
userConstraintPtr->m_gearRatio = serverConstraint->m_gearRatio;
|
|
|
|
}
|
|
|
|
if (serverCmd.m_updateFlags & USER_CONSTRAINT_CHANGE_RELATIVE_POSITION_TARGET)
|
|
|
|
{
|
|
|
|
userConstraintPtr->m_relativePositionTarget = serverConstraint->m_relativePositionTarget;
|
|
|
|
}
|
|
|
|
if (serverCmd.m_updateFlags & USER_CONSTRAINT_CHANGE_ERP)
|
|
|
|
{
|
|
|
|
userConstraintPtr->m_erp = serverConstraint->m_erp;
|
|
|
|
}
|
|
|
|
if (serverCmd.m_updateFlags & USER_CONSTRAINT_CHANGE_GEAR_AUX_LINK)
|
|
|
|
{
|
|
|
|
userConstraintPtr->m_gearAuxLink = serverConstraint->m_gearAuxLink;
|
|
|
|
}
|
2017-01-23 03:08:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CMD_USER_CONSTRAINT_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_USER_CONSTRAINT_FAILED");
|
2017-01-23 03:08:31 +00:00
|
|
|
b3Warning("createConstraint failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REMOVE_USER_CONSTRAINT_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_REMOVE_USER_CONSTRAINT_FAILED");
|
2017-01-23 03:08:31 +00:00
|
|
|
b3Warning("removeConstraint failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CHANGE_USER_CONSTRAINT_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CHANGE_USER_CONSTRAINT_FAILED");
|
2017-11-12 18:36:30 +00:00
|
|
|
//b3Warning("changeConstraint failed");
|
2017-01-23 03:08:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_ACTUAL_STATE_UPDATE_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_ACTUAL_STATE_UPDATE_FAILED");
|
2017-01-23 03:08:31 +00:00
|
|
|
b3Warning("request actual state failed");
|
|
|
|
break;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_BODY_INFO_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_BODY_INFO_COMPLETED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Received body info\n");
|
|
|
|
}
|
|
|
|
int bodyUniqueId = serverCmd.m_dataStreamArguments.m_bodyUniqueId;
|
|
|
|
processBodyJointInfo(bodyUniqueId, serverCmd);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-12-31 22:43:15 +00:00
|
|
|
case CMD_MJCF_LOADING_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_MJCF_LOADING_FAILED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server failed loading the MJCF...\n");
|
|
|
|
}
|
|
|
|
break;
|
2016-12-31 22:43:15 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_SDF_LOADING_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_SDF_LOADING_FAILED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server failed loading the SDF...\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CMD_BULLET_DATA_STREAM_RECEIVED_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_BULLET_DATA_STREAM_RECEIVED_COMPLETED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server received bullet data stream OK\n");
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_BULLET_DATA_STREAM_RECEIVED_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_BULLET_DATA_STREAM_RECEIVED_FAILED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server failed receiving bullet data stream\n");
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_ACTUAL_STATE_UPDATE_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_ACTUAL_STATE_UPDATE_COMPLETED");
|
2019-03-07 07:27:59 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Printf("Received actual state\n");
|
|
|
|
|
2017-03-26 20:06:46 +00:00
|
|
|
SharedMemoryStatus& command = m_data->m_testBlock1->m_serverCommands[0];
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2017-03-26 20:06:46 +00:00
|
|
|
int numQ = command.m_sendActualStateArgs.m_numDegreeOfFreedomQ;
|
|
|
|
int numU = command.m_sendActualStateArgs.m_numDegreeOfFreedomU;
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Printf("size Q = %d, size U = %d\n", numQ, numU);
|
2017-03-26 20:06:46 +00:00
|
|
|
char msg[1024];
|
|
|
|
{
|
|
|
|
sprintf(msg, "Q=[");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < numQ; i++)
|
|
|
|
{
|
|
|
|
if (i < numQ - 1)
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
sprintf(msg, "%s%f,", msg,
|
2019-03-07 07:27:59 +00:00
|
|
|
m_data->m_cachedState.m_actualStateQ[i]);
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
sprintf(msg, "%s%f", msg,
|
2019-03-07 07:27:59 +00:00
|
|
|
m_data->m_cachedState.m_actualStateQ[i]);
|
2017-03-26 20:06:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sprintf(msg, "%s]", msg);
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Printf(msg);
|
|
|
|
|
|
|
|
sprintf(msg, "U=[");
|
|
|
|
|
|
|
|
for (int i = 0; i < numU; i++)
|
|
|
|
{
|
|
|
|
if (i < numU - 1)
|
|
|
|
{
|
|
|
|
sprintf(msg, "%s%f,", msg,
|
2019-03-07 07:27:59 +00:00
|
|
|
m_data->m_cachedState.m_actualStateQdot[i]);
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(msg, "%s%f", msg,
|
2019-03-07 07:27:59 +00:00
|
|
|
m_data->m_cachedState.m_actualStateQdot[i]);
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sprintf(msg, "%s]", msg);
|
|
|
|
|
|
|
|
b3Printf(msg);
|
|
|
|
b3Printf("\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_RESET_SIMULATION_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_RESET_SIMULATION_COMPLETED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("CMD_RESET_SIMULATION_COMPLETED clean data\n");
|
|
|
|
}
|
2017-01-23 03:08:31 +00:00
|
|
|
resetData();
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_DEBUG_LINES_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_DEBUG_LINES_COMPLETED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Success receiving %d debug lines",
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_numDebugLines);
|
|
|
|
}
|
|
|
|
|
|
|
|
int numLines = serverCmd.m_sendDebugLinesArgs.m_numDebugLines;
|
|
|
|
float* linesFrom =
|
|
|
|
(float*)&m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[0];
|
|
|
|
float* linesTo =
|
|
|
|
(float*)(&m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[0] +
|
|
|
|
numLines * 3 * sizeof(float));
|
|
|
|
float* linesColor =
|
|
|
|
(float*)(&m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[0] +
|
|
|
|
2 * numLines * 3 * sizeof(float));
|
|
|
|
|
|
|
|
m_data->m_debugLinesFrom.resize(serverCmd.m_sendDebugLinesArgs.m_startingLineIndex +
|
|
|
|
numLines);
|
|
|
|
m_data->m_debugLinesTo.resize(serverCmd.m_sendDebugLinesArgs.m_startingLineIndex +
|
|
|
|
numLines);
|
|
|
|
m_data->m_debugLinesColor.resize(
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_startingLineIndex + numLines);
|
|
|
|
|
|
|
|
for (int i = 0; i < numLines; i++)
|
|
|
|
{
|
|
|
|
TmpFloat3 from = CreateTmpFloat3(linesFrom[i * 3], linesFrom[i * 3 + 1],
|
|
|
|
linesFrom[i * 3 + 2]);
|
|
|
|
TmpFloat3 to =
|
|
|
|
CreateTmpFloat3(linesTo[i * 3], linesTo[i * 3 + 1], linesTo[i * 3 + 2]);
|
|
|
|
TmpFloat3 color = CreateTmpFloat3(linesColor[i * 3], linesColor[i * 3 + 1],
|
|
|
|
linesColor[i * 3 + 2]);
|
|
|
|
|
|
|
|
m_data
|
|
|
|
->m_debugLinesFrom[serverCmd.m_sendDebugLinesArgs.m_startingLineIndex + i] =
|
|
|
|
from;
|
|
|
|
m_data->m_debugLinesTo[serverCmd.m_sendDebugLinesArgs.m_startingLineIndex + i] =
|
|
|
|
to;
|
|
|
|
m_data->m_debugLinesColor[serverCmd.m_sendDebugLinesArgs.m_startingLineIndex +
|
|
|
|
i] = color;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2015-10-27 22:46:13 +00:00
|
|
|
case CMD_RIGID_BODY_CREATION_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_RIGID_BODY_CREATION_COMPLETED");
|
2015-10-27 22:46:13 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_DEBUG_LINES_OVERFLOW_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_DEBUG_LINES_OVERFLOW_FAILED");
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Warning("Error receiving debug lines");
|
|
|
|
m_data->m_debugLinesFrom.resize(0);
|
|
|
|
m_data->m_debugLinesTo.resize(0);
|
|
|
|
m_data->m_debugLinesColor.resize(0);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CMD_CAMERA_IMAGE_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CAMERA_IMAGE_COMPLETED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
2016-05-31 17:23:04 +00:00
|
|
|
{
|
|
|
|
b3Printf("Camera image OK\n");
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
int numBytesPerPixel = 4; //RGBA
|
|
|
|
int numTotalPixels = serverCmd.m_sendPixelDataArguments.m_startingPixelIndex +
|
|
|
|
serverCmd.m_sendPixelDataArguments.m_numPixelsCopied +
|
|
|
|
serverCmd.m_sendPixelDataArguments.m_numRemainingPixels;
|
2016-05-31 17:23:04 +00:00
|
|
|
|
|
|
|
m_data->m_cachedCameraPixelsWidth = 0;
|
|
|
|
m_data->m_cachedCameraPixelsHeight = 0;
|
2016-06-02 00:47:41 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
int numPixels = serverCmd.m_sendPixelDataArguments.m_imageWidth * serverCmd.m_sendPixelDataArguments.m_imageHeight;
|
2016-06-02 00:47:41 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_cachedCameraPixelsRGBA.reserve(numPixels * numBytesPerPixel);
|
2016-05-31 17:23:04 +00:00
|
|
|
m_data->m_cachedCameraDepthBuffer.resize(numTotalPixels);
|
2016-08-11 21:55:30 +00:00
|
|
|
m_data->m_cachedSegmentationMaskBuffer.resize(numTotalPixels);
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_cachedCameraPixelsRGBA.resize(numTotalPixels * numBytesPerPixel);
|
|
|
|
|
2016-05-31 17:23:04 +00:00
|
|
|
unsigned char* rgbaPixelsReceived =
|
2018-09-23 21:17:31 +00:00
|
|
|
(unsigned char*)&m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[0];
|
|
|
|
// printf("pixel = %d\n", rgbaPixelsReceived[0]);
|
|
|
|
|
|
|
|
float* depthBuffer = (float*)&(m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[serverCmd.m_sendPixelDataArguments.m_numPixelsCopied * 4]);
|
|
|
|
int* segmentationMaskBuffer = (int*)&(m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[serverCmd.m_sendPixelDataArguments.m_numPixelsCopied * 8]);
|
|
|
|
|
|
|
|
for (int i = 0; i < serverCmd.m_sendPixelDataArguments.m_numPixelsCopied; i++)
|
2016-06-07 23:11:58 +00:00
|
|
|
{
|
|
|
|
m_data->m_cachedCameraDepthBuffer[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex] = depthBuffer[i];
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < serverCmd.m_sendPixelDataArguments.m_numPixelsCopied; i++)
|
2016-08-11 21:55:30 +00:00
|
|
|
{
|
|
|
|
m_data->m_cachedSegmentationMaskBuffer[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex] = segmentationMaskBuffer[i];
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < serverCmd.m_sendPixelDataArguments.m_numPixelsCopied * numBytesPerPixel; i++)
|
2016-05-31 17:23:04 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_cachedCameraPixelsRGBA[i + serverCmd.m_sendPixelDataArguments.m_startingPixelIndex * numBytesPerPixel] = rgbaPixelsReceived[i];
|
2016-05-31 17:23:04 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CMD_CAMERA_IMAGE_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CAMERA_IMAGE_FAILED");
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Warning("Camera image FAILED\n");
|
|
|
|
break;
|
|
|
|
}
|
2016-08-10 01:40:12 +00:00
|
|
|
case CMD_CALCULATED_INVERSE_DYNAMICS_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CALCULATED_INVERSE_DYNAMICS_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Inverse Dynamics computations failed");
|
|
|
|
break;
|
|
|
|
}
|
2016-11-10 19:22:22 +00:00
|
|
|
case CMD_REQUEST_AABB_OVERLAP_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Overlapping object query failed");
|
|
|
|
break;
|
|
|
|
}
|
2016-12-27 03:40:09 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_REQUEST_RAY_CAST_INTERSECTIONS_COMPLETED:
|
|
|
|
{
|
|
|
|
B3_PROFILE("m_raycastHits");
|
|
|
|
if (m_data->m_verboseOutput)
|
2016-12-27 03:40:09 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Printf("Raycast completed");
|
|
|
|
}
|
|
|
|
m_data->m_raycastHits.clear();
|
|
|
|
b3RayHitInfo* rayHits = (b3RayHitInfo*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
|
|
|
for (int i = 0; i < serverCmd.m_raycastHits.m_numRaycastHits; i++)
|
|
|
|
{
|
|
|
|
m_data->m_raycastHits.push_back(rayHits[i]);
|
2016-12-27 03:40:09 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-12-27 03:40:09 +00:00
|
|
|
|
|
|
|
case CMD_REQUEST_VR_EVENTS_DATA_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_REQUEST_VR_EVENTS_DATA_COMPLETED");
|
2016-12-27 03:40:09 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Request VR Events completed");
|
|
|
|
}
|
|
|
|
m_data->m_cachedVREvents.clear();
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < serverCmd.m_sendVREvents.m_numVRControllerEvents; i++)
|
2016-12-27 03:40:09 +00:00
|
|
|
{
|
|
|
|
m_data->m_cachedVREvents.push_back(serverCmd.m_sendVREvents.m_controllerEvents[i]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-02 20:33:22 +00:00
|
|
|
case CMD_REQUEST_KEYBOARD_EVENTS_DATA_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_REQUEST_KEYBOARD_EVENTS_DATA_COMPLETED");
|
2017-03-02 20:33:22 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Request keyboard events completed");
|
|
|
|
}
|
|
|
|
m_data->m_cachedKeyboardEvents.resize(serverCmd.m_sendKeyboardEvents.m_numKeyboardEvents);
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < serverCmd.m_sendKeyboardEvents.m_numKeyboardEvents; i++)
|
2017-03-02 20:33:22 +00:00
|
|
|
{
|
|
|
|
m_data->m_cachedKeyboardEvents[i] = serverCmd.m_sendKeyboardEvents.m_keyboardEvents[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-06-17 20:29:14 +00:00
|
|
|
case CMD_REQUEST_MOUSE_EVENTS_DATA_COMPLETED:
|
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_REQUEST_MOUSE_EVENTS_DATA_COMPLETED");
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Request mouse events completed");
|
|
|
|
}
|
|
|
|
m_data->m_cachedMouseEvents.resize(serverCmd.m_sendMouseEvents.m_numMouseEvents);
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < serverCmd.m_sendMouseEvents.m_numMouseEvents; i++)
|
2017-06-17 20:29:14 +00:00
|
|
|
{
|
|
|
|
m_data->m_cachedMouseEvents[i] = serverCmd.m_sendMouseEvents.m_mouseEvents[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-11-10 19:22:22 +00:00
|
|
|
case CMD_REQUEST_AABB_OVERLAP_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_REQUEST_AABB_OVERLAP_COMPLETED");
|
2016-11-10 19:22:22 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Overlapping object request completed");
|
|
|
|
}
|
|
|
|
|
|
|
|
int startOverlapIndex = serverCmd.m_sendOverlappingObjectsArgs.m_startingOverlappingObjectIndex;
|
|
|
|
int numOverlapCopied = serverCmd.m_sendOverlappingObjectsArgs.m_numOverlappingObjectsCopied;
|
|
|
|
m_data->m_cachedOverlappingObjects.resize(startOverlapIndex + numOverlapCopied);
|
|
|
|
b3OverlappingObject* objects = (b3OverlappingObject*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
|
|
|
|
|
|
|
for (int i = 0; i < numOverlapCopied; i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedOverlappingObjects[startOverlapIndex + i] = objects[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_CONTACT_POINT_INFORMATION_COMPLETED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CONTACT_POINT_INFORMATION_COMPLETED");
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Contact Point Information Request OK\n");
|
|
|
|
}
|
|
|
|
int startContactIndex = serverCmd.m_sendContactPointArgs.m_startingContactPointIndex;
|
|
|
|
int numContactsCopied = serverCmd.m_sendContactPointArgs.m_numContactPointsCopied;
|
|
|
|
|
|
|
|
m_data->m_cachedContactPoints.resize(startContactIndex + numContactsCopied);
|
2016-09-01 20:30:07 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
b3ContactPointData* contactData = (b3ContactPointData*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
|
|
|
|
|
|
|
for (int i = 0; i < numContactsCopied; i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedContactPoints[startContactIndex + i] = contactData[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CONTACT_POINT_INFORMATION_FAILED:
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CONTACT_POINT_INFORMATION_FAILED");
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Warning("Contact Point Information Request failed");
|
|
|
|
break;
|
|
|
|
}
|
2016-10-13 06:03:36 +00:00
|
|
|
|
2016-10-13 06:07:41 +00:00
|
|
|
case CMD_SAVE_WORLD_COMPLETED:
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
B3_PROFILE("CMD_SAVE_WORLD_COMPLETED");
|
|
|
|
break;
|
2017-03-26 20:06:46 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2016-10-13 06:03:36 +00:00
|
|
|
case CMD_SAVE_WORLD_FAILED:
|
2016-10-13 06:07:41 +00:00
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_SAVE_WORLD_FAILED");
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Warning("Saving world failed");
|
2016-10-13 06:07:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CALCULATE_INVERSE_KINEMATICS_COMPLETED:
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
B3_PROFILE("CMD_CALCULATE_INVERSE_KINEMATICS_COMPLETED");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CALCULATE_INVERSE_KINEMATICS_FAILED:
|
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_CALCULATE_INVERSE_KINEMATICS_FAILED");
|
|
|
|
b3Warning("Calculate Inverse Kinematics Request failed");
|
|
|
|
break;
|
|
|
|
}
|
2016-10-19 05:05:28 +00:00
|
|
|
case CMD_VISUAL_SHAPE_INFO_COMPLETED:
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
B3_PROFILE("CMD_VISUAL_SHAPE_INFO_COMPLETED");
|
|
|
|
if (m_data->m_verboseOutput)
|
2016-10-19 05:05:28 +00:00
|
|
|
{
|
|
|
|
b3Printf("Visual Shape Information Request OK\n");
|
|
|
|
}
|
|
|
|
int startVisualShapeIndex = serverCmd.m_sendVisualShapeArgs.m_startingVisualShapeIndex;
|
|
|
|
int numVisualShapesCopied = serverCmd.m_sendVisualShapeArgs.m_numVisualShapesCopied;
|
|
|
|
m_data->m_cachedVisualShapes.resize(startVisualShapeIndex + numVisualShapesCopied);
|
|
|
|
b3VisualShapeData* shapeData = (b3VisualShapeData*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
|
|
|
for (int i = 0; i < numVisualShapesCopied; i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedVisualShapes[startVisualShapeIndex + i] = shapeData[i];
|
|
|
|
}
|
2016-10-13 06:07:41 +00:00
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_VISUAL_SHAPE_INFO_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Visual Shape Info Request failed");
|
|
|
|
break;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
case CMD_VISUAL_SHAPE_UPDATE_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_VISUAL_SHAPE_UPDATE_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Visual Shape Update failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_LOAD_TEXTURE_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_LOAD_TEXTURE_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Load texture failed");
|
|
|
|
break;
|
|
|
|
}
|
2016-11-12 02:07:42 +00:00
|
|
|
case CMD_BULLET_LOADING_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_BULLET_LOADING_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Load .bullet failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_BULLET_SAVING_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Save .bullet failed");
|
|
|
|
break;
|
|
|
|
}
|
2017-01-17 23:42:32 +00:00
|
|
|
case CMD_USER_DEBUG_DRAW_PARAMETER_COMPLETED:
|
2016-11-14 15:39:34 +00:00
|
|
|
case CMD_USER_DEBUG_DRAW_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_USER_DEBUG_DRAW_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("User debug draw failed");
|
|
|
|
break;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2017-01-21 02:13:24 +00:00
|
|
|
case CMD_SYNC_BODY_INFO_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-02-17 22:25:53 +00:00
|
|
|
case CMD_STATE_LOGGING_START_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
case CMD_STATE_LOGGING_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
case CMD_STATE_LOGGING_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("State Logging failed");
|
|
|
|
break;
|
|
|
|
}
|
2017-04-10 18:03:41 +00:00
|
|
|
case CMD_REQUEST_OPENGL_VISUALIZER_CAMERA_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Request visualizer camera failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REQUEST_OPENGL_VISUALIZER_CAMERA_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-05-04 04:53:29 +00:00
|
|
|
case CMD_REMOVE_BODY_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REMOVE_BODY_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Removing body failed");
|
|
|
|
break;
|
|
|
|
}
|
2017-05-09 17:31:28 +00:00
|
|
|
case CMD_GET_DYNAMICS_INFO_COMPLETED:
|
2017-05-08 05:21:38 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-05-09 17:31:28 +00:00
|
|
|
case CMD_GET_DYNAMICS_INFO_FAILED:
|
2017-05-08 05:21:38 +00:00
|
|
|
{
|
2017-05-09 17:44:33 +00:00
|
|
|
b3Warning("Request dynamics info failed");
|
2017-05-08 05:21:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-06-03 17:57:56 +00:00
|
|
|
case CMD_CREATE_COLLISION_SHAPE_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Request createCollisionShape failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CREATE_COLLISION_SHAPE_COMPLETED:
|
|
|
|
case CMD_CREATE_VISUAL_SHAPE_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CMD_CREATE_MULTI_BODY_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Request createMultiBody failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CREATE_VISUAL_SHAPE_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Request createVisualShape failed");
|
|
|
|
break;
|
|
|
|
}
|
2017-06-17 01:10:10 +00:00
|
|
|
case CMD_REQUEST_COLLISION_INFO_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REQUEST_COLLISION_INFO_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Request getCollisionInfo failed");
|
|
|
|
break;
|
|
|
|
}
|
2017-09-23 02:17:57 +00:00
|
|
|
case CMD_CUSTOM_COMMAND_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-09-26 17:05:17 +00:00
|
|
|
case CMD_CALCULATED_JACOBIAN_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CALCULATED_JACOBIAN_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("jacobian calculation failed");
|
|
|
|
break;
|
|
|
|
}
|
2017-09-23 02:17:57 +00:00
|
|
|
case CMD_CUSTOM_COMMAND_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("custom plugin command failed");
|
|
|
|
break;
|
|
|
|
}
|
2017-06-03 17:57:56 +00:00
|
|
|
|
2017-10-05 15:23:10 +00:00
|
|
|
case CMD_CALCULATED_MASS_MATRIX_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("calculate mass matrix failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_CALCULATED_MASS_MATRIX_COMPLETED:
|
|
|
|
{
|
|
|
|
double* matrixData = (double*)&this->m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[0];
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_cachedMassMatrix.resize(serverCmd.m_massMatrixResultArgs.m_dofCount * serverCmd.m_massMatrixResultArgs.m_dofCount);
|
|
|
|
for (int i = 0; i < serverCmd.m_massMatrixResultArgs.m_dofCount * serverCmd.m_massMatrixResultArgs.m_dofCount; i++)
|
2017-10-05 15:23:10 +00:00
|
|
|
{
|
|
|
|
m_data->m_cachedMassMatrix[i] = matrixData[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-10-05 18:43:14 +00:00
|
|
|
case CMD_REQUEST_PHYSICS_SIMULATION_PARAMETERS_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-12-31 23:37:16 +00:00
|
|
|
case CMD_SAVE_STATE_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-12-28 18:05:51 +00:00
|
|
|
case CMD_RESTORE_STATE_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("restoreState failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_RESTORE_STATE_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-12-22 22:45:36 +00:00
|
|
|
case CMD_BULLET_SAVING_COMPLETED:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2018-01-04 03:17:28 +00:00
|
|
|
case CMD_COLLISION_SHAPE_INFO_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("getCollisionShapeData failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_COLLISION_SHAPE_INFO_COMPLETED:
|
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_COLLISION_SHAPE_INFO_COMPLETED");
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Collision Shape Information Request OK\n");
|
|
|
|
}
|
|
|
|
int numCollisionShapesCopied = serverCmd.m_sendCollisionShapeArgs.m_numCollisionShapes;
|
|
|
|
m_data->m_cachedCollisionShapes.resize(numCollisionShapesCopied);
|
|
|
|
b3CollisionShapeData* shapeData = (b3CollisionShapeData*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
|
|
|
for (int i = 0; i < numCollisionShapesCopied; i++)
|
|
|
|
{
|
|
|
|
m_data->m_cachedCollisionShapes[i] = shapeData[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2018-01-10 06:47:56 +00:00
|
|
|
case CMD_LOAD_SOFT_BODY_FAILED:
|
2018-09-23 21:17:31 +00:00
|
|
|
{
|
2019-04-25 22:18:25 +00:00
|
|
|
B3_PROFILE("CMD_LOAD_SOFT_BODY_FAILED");
|
|
|
|
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server failed loading the SoftBody...\n");
|
|
|
|
}
|
|
|
|
break;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
2018-01-10 06:47:56 +00:00
|
|
|
case CMD_LOAD_SOFT_BODY_COMPLETED:
|
2018-09-23 21:17:31 +00:00
|
|
|
{
|
2019-04-25 22:18:25 +00:00
|
|
|
B3_PROFILE("CMD_LOAD_SOFT_BODY_COMPLETED");
|
|
|
|
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Server loading the SoftBody OK\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
b3Assert(serverCmd.m_numDataStreamBytes);
|
|
|
|
if (serverCmd.m_numDataStreamBytes > 0)
|
|
|
|
{
|
|
|
|
bParse::btBulletFile bf(
|
|
|
|
this->m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor,
|
|
|
|
serverCmd.m_numDataStreamBytes);
|
|
|
|
bf.setFileDNAisMemoryDNA();
|
|
|
|
bf.parse(false);
|
|
|
|
int bodyUniqueId = serverCmd.m_dataStreamArguments.m_bodyUniqueId;
|
|
|
|
|
|
|
|
BodyJointInfoCache* bodyJoints = new BodyJointInfoCache;
|
|
|
|
m_data->m_bodyJointMap.insert(bodyUniqueId, bodyJoints);
|
|
|
|
bodyJoints->m_bodyName = serverCmd.m_dataStreamArguments.m_bodyName;
|
|
|
|
bodyJoints->m_baseName = "baseLink";
|
|
|
|
|
|
|
|
if (bf.ok())
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
|
|
|
{
|
|
|
|
b3Printf("Received robot description ok!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
b3Warning("Robot description not received when loading soft body!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
2018-06-02 20:40:08 +00:00
|
|
|
case CMD_SYNC_USER_DATA_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Synchronizing user data failed.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REQUEST_USER_DATA_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Requesting user data failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_ADD_USER_DATA_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Adding user data failed (do the specified body and link exist?)");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REMOVE_USER_DATA_FAILED:
|
|
|
|
{
|
|
|
|
b3Warning("Removing user data failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CMD_REQUEST_USER_DATA_COMPLETED:
|
|
|
|
case CMD_SYNC_USER_DATA_COMPLETED:
|
|
|
|
case CMD_REMOVE_USER_DATA_COMPLETED:
|
|
|
|
case CMD_ADD_USER_DATA_COMPLETED:
|
2019-04-04 03:06:40 +00:00
|
|
|
case CMD_REMOVE_STATE_FAILED:
|
|
|
|
case CMD_REMOVE_STATE_COMPLETED:
|
2018-06-02 20:40:08 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
b3Error("Unknown server status %d\n", serverCmd.m_type);
|
|
|
|
btAssert(0);
|
|
|
|
}
|
|
|
|
};
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_testBlock1->m_numProcessedServerCommands++;
|
|
|
|
// we don't have more than 1 command outstanding (in total, either server or client)
|
|
|
|
btAssert(m_data->m_testBlock1->m_numProcessedServerCommands ==
|
|
|
|
m_data->m_testBlock1->m_numServerCommands);
|
2016-05-31 17:23:04 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (m_data->m_testBlock1->m_numServerCommands ==
|
|
|
|
m_data->m_testBlock1->m_numProcessedServerCommands)
|
|
|
|
{
|
|
|
|
m_data->m_waitingForServer = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_data->m_waitingForServer = true;
|
|
|
|
}
|
2016-12-31 22:43:15 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if ((serverCmd.m_type == CMD_SDF_LOADING_COMPLETED) || (serverCmd.m_type == CMD_MJCF_LOADING_COMPLETED) || (serverCmd.m_type == CMD_SYNC_BODY_INFO_COMPLETED))
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_LOADING_COMPLETED");
|
2017-01-23 03:08:31 +00:00
|
|
|
int numConstraints = serverCmd.m_sdfLoadedArgs.m_numUserConstraints;
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < numConstraints; i++)
|
2017-01-23 03:08:31 +00:00
|
|
|
{
|
|
|
|
int constraintUid = serverCmd.m_sdfLoadedArgs.m_userConstraintUniqueIds[i];
|
|
|
|
m_data->m_constraintIdsRequestInfo.push_back(constraintUid);
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
int numBodies = serverCmd.m_sdfLoadedArgs.m_numBodies;
|
|
|
|
if (numBodies > 0)
|
|
|
|
{
|
|
|
|
m_data->m_tempBackupServerStatus = m_data->m_lastServerStatus;
|
|
|
|
|
|
|
|
for (int i = 0; i < numBodies; i++)
|
|
|
|
{
|
|
|
|
m_data->m_bodyIdsRequestInfo.push_back(serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
int bodyId = m_data->m_bodyIdsRequestInfo[m_data->m_bodyIdsRequestInfo.size() - 1];
|
|
|
|
m_data->m_bodyIdsRequestInfo.pop_back();
|
|
|
|
|
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
//now transfer the information of the individual objects etc.
|
|
|
|
command.m_type = CMD_REQUEST_BODY_INFO;
|
|
|
|
command.m_sdfRequestInfoArgs.m_bodyUniqueId = bodyId;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serverCmd.m_type == CMD_SYNC_USER_DATA_COMPLETED)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
B3_PROFILE("CMD_SYNC_USER_DATA_COMPLETED");
|
2018-06-04 13:10:48 +00:00
|
|
|
// Remove all cached user data entries.
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < m_data->m_bodyJointMap.size(); i++)
|
2018-06-04 13:10:48 +00:00
|
|
|
{
|
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
|
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
2018-07-03 15:45:19 +00:00
|
|
|
(*bodyJointsPtr)->m_userDataIds.clear();
|
2018-06-04 13:10:48 +00:00
|
|
|
}
|
2018-07-03 15:45:19 +00:00
|
|
|
m_data->m_userDataMap.clear();
|
|
|
|
m_data->m_userDataHandleLookup.clear();
|
2018-06-04 13:10:48 +00:00
|
|
|
}
|
2018-06-02 20:40:08 +00:00
|
|
|
const int numIdentifiers = serverCmd.m_syncUserDataArgs.m_numUserDataIdentifiers;
|
2018-09-23 21:17:31 +00:00
|
|
|
if (numIdentifiers > 0)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
m_data->m_tempBackupServerStatus = m_data->m_lastServerStatus;
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
const int* identifiers = (int*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
2018-07-03 15:45:19 +00:00
|
|
|
m_data->m_userDataIdsRequestInfo.reserve(numIdentifiers - 1);
|
|
|
|
// Store the identifiers that still need to be requested.
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < numIdentifiers - 1; i++)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
m_data->m_userDataIdsRequestInfo.push_back(identifiers[i]);
|
|
|
|
}
|
|
|
|
|
2018-07-03 15:45:19 +00:00
|
|
|
// Request individual user data entries, start with last identifier.
|
2018-06-02 20:40:08 +00:00
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
command.m_type = CMD_REQUEST_USER_DATA;
|
2018-07-03 15:45:19 +00:00
|
|
|
command.m_userDataRequestArgs.m_userDataId = identifiers[numIdentifiers - 1];
|
2018-06-02 20:40:08 +00:00
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (serverCmd.m_type == CMD_ADD_USER_DATA_COMPLETED || serverCmd.m_type == CMD_REQUEST_USER_DATA_COMPLETED)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
B3_PROFILE("CMD_ADD_USER_DATA_COMPLETED");
|
2018-07-03 15:45:19 +00:00
|
|
|
const UserDataResponseArgs response = serverCmd.m_userDataResponseArgs;
|
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[response.m_bodyUniqueId];
|
2018-09-23 21:17:31 +00:00
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
|
|
|
const char* dataStream = m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
2018-07-03 15:45:19 +00:00
|
|
|
SharedMemoryUserData* userData = m_data->m_userDataMap[response.m_userDataId];
|
2018-09-23 21:17:31 +00:00
|
|
|
if (userData)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
// Only replace the value.
|
2018-07-03 15:45:19 +00:00
|
|
|
userData->replaceValue(dataStream, response.m_valueLength, response.m_valueType);
|
2018-06-02 20:40:08 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
else
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
// Add a new user data entry.
|
2018-09-23 21:17:31 +00:00
|
|
|
const char* key = response.m_key;
|
2018-07-03 15:45:19 +00:00
|
|
|
m_data->m_userDataMap.insert(response.m_userDataId, SharedMemoryUserData(key, response.m_bodyUniqueId, response.m_linkIndex, response.m_visualShapeIndex));
|
|
|
|
userData = m_data->m_userDataMap[response.m_userDataId];
|
|
|
|
userData->replaceValue(dataStream, response.m_valueLength, response.m_valueType);
|
|
|
|
m_data->m_userDataHandleLookup.insert(SharedMemoryUserDataHashKey(userData), response.m_userDataId);
|
|
|
|
(*bodyJointsPtr)->m_userDataIds.push_back(response.m_userDataId);
|
2018-06-02 20:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (serverCmd.m_type == CMD_REQUEST_USER_DATA_COMPLETED)
|
|
|
|
{
|
|
|
|
if (m_data->m_userDataIdsRequestInfo.size() > 0)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
// Request individual user data entries.
|
2018-09-23 21:17:31 +00:00
|
|
|
const int userDataId = m_data->m_userDataIdsRequestInfo[m_data->m_userDataIdsRequestInfo.size() - 1];
|
2018-06-02 20:40:08 +00:00
|
|
|
m_data->m_userDataIdsRequestInfo.pop_back();
|
|
|
|
|
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
command.m_type = CMD_REQUEST_USER_DATA;
|
2018-07-03 15:45:19 +00:00
|
|
|
command.m_userDataRequestArgs.m_userDataId = userDataId;
|
2018-06-02 20:40:08 +00:00
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
m_data->m_lastServerStatus = m_data->m_tempBackupServerStatus;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (serverCmd.m_type == CMD_REMOVE_USER_DATA_COMPLETED)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
B3_PROFILE("CMD_REMOVE_USER_DATA_COMPLETED");
|
2018-07-03 15:45:19 +00:00
|
|
|
const int userDataId = serverCmd.m_removeUserDataResponseArgs.m_userDataId;
|
2018-09-23 21:17:31 +00:00
|
|
|
SharedMemoryUserData* userData = m_data->m_userDataMap[userDataId];
|
|
|
|
if (userData)
|
|
|
|
{
|
2018-07-03 15:45:19 +00:00
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[userData->m_bodyUniqueId];
|
2018-09-23 21:17:31 +00:00
|
|
|
if (bodyJointsPtr && *bodyJointsPtr)
|
|
|
|
{
|
2018-07-03 15:45:19 +00:00
|
|
|
(*bodyJointsPtr)->m_userDataIds.remove(userDataId);
|
2018-06-02 20:40:08 +00:00
|
|
|
}
|
2018-07-03 15:45:19 +00:00
|
|
|
m_data->m_userDataHandleLookup.remove(SharedMemoryUserDataHashKey(userData));
|
|
|
|
m_data->m_userDataMap.remove(userDataId);
|
2018-06-02 20:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-04 04:53:29 +00:00
|
|
|
if (serverCmd.m_type == CMD_REMOVE_BODY_COMPLETED)
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < serverCmd.m_removeObjectArgs.m_numBodies; i++)
|
2017-05-04 04:53:29 +00:00
|
|
|
{
|
|
|
|
int bodyUniqueId = serverCmd.m_removeObjectArgs.m_bodyUniqueIds[i];
|
|
|
|
removeCachedBody(bodyUniqueId);
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < serverCmd.m_removeObjectArgs.m_numUserConstraints; i++)
|
2017-05-04 20:14:24 +00:00
|
|
|
{
|
|
|
|
int key = serverCmd.m_removeObjectArgs.m_userConstraintUniqueIds[i];
|
|
|
|
m_data->m_userConstraintInfoMap.remove(key);
|
|
|
|
}
|
2017-05-04 04:53:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 03:08:31 +00:00
|
|
|
if (serverCmd.m_type == CMD_USER_CONSTRAINT_INFO_COMPLETED)
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_USER_CONSTRAINT_INFO_COMPLETED");
|
|
|
|
|
2017-01-23 03:08:31 +00:00
|
|
|
if (m_data->m_constraintIdsRequestInfo.size())
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
int cid = m_data->m_constraintIdsRequestInfo[m_data->m_constraintIdsRequestInfo.size() - 1];
|
2017-01-23 03:08:31 +00:00
|
|
|
m_data->m_constraintIdsRequestInfo.pop_back();
|
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
command.m_type = CMD_USER_CONSTRAINT;
|
|
|
|
command.m_updateFlags = USER_CONSTRAINT_REQUEST_INFO;
|
|
|
|
command.m_userConstraintArguments.m_userConstraintUniqueId = cid;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
2017-01-23 03:08:31 +00:00
|
|
|
else
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_lastServerStatus = m_data->m_tempBackupServerStatus;
|
2017-01-23 03:08:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (serverCmd.m_type == CMD_BODY_INFO_COMPLETED)
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_BODY_INFO_COMPLETED");
|
2018-09-23 21:17:31 +00:00
|
|
|
//are there any bodies left to be processed?
|
|
|
|
if (m_data->m_bodyIdsRequestInfo.size())
|
|
|
|
{
|
|
|
|
int bodyId = m_data->m_bodyIdsRequestInfo[m_data->m_bodyIdsRequestInfo.size() - 1];
|
|
|
|
m_data->m_bodyIdsRequestInfo.pop_back();
|
|
|
|
|
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
//now transfer the information of the individual objects etc.
|
|
|
|
command.m_type = CMD_REQUEST_BODY_INFO;
|
|
|
|
command.m_sdfRequestInfoArgs.m_bodyUniqueId = bodyId;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-23 03:08:31 +00:00
|
|
|
if (m_data->m_constraintIdsRequestInfo.size())
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
int cid = m_data->m_constraintIdsRequestInfo[m_data->m_constraintIdsRequestInfo.size() - 1];
|
2017-01-23 03:08:31 +00:00
|
|
|
m_data->m_constraintIdsRequestInfo.pop_back();
|
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
command.m_type = CMD_USER_CONSTRAINT;
|
|
|
|
command.m_updateFlags = USER_CONSTRAINT_REQUEST_INFO;
|
|
|
|
command.m_userConstraintArguments.m_userConstraintUniqueId = cid;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
2017-01-23 03:08:31 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_lastServerStatus = m_data->m_tempBackupServerStatus;
|
2017-01-23 03:08:31 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-10 19:22:22 +00:00
|
|
|
|
|
|
|
if (serverCmd.m_type == CMD_REQUEST_AABB_OVERLAP_COMPLETED)
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_REQUEST_AABB_OVERLAP_COMPLETED2");
|
2016-11-10 19:22:22 +00:00
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
if (serverCmd.m_sendOverlappingObjectsArgs.m_numRemainingOverlappingObjects > 0 && serverCmd.m_sendOverlappingObjectsArgs.m_numOverlappingObjectsCopied)
|
|
|
|
{
|
|
|
|
command.m_type = CMD_REQUEST_AABB_OVERLAP;
|
|
|
|
command.m_requestOverlappingObjectsArgs.m_startingOverlappingObjectIndex = serverCmd.m_sendOverlappingObjectsArgs.m_startingOverlappingObjectIndex + serverCmd.m_sendOverlappingObjectsArgs.m_numOverlappingObjectsCopied;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
if (serverCmd.m_type == CMD_CONTACT_POINT_INFORMATION_COMPLETED)
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CONTACT_POINT_INFORMATION_COMPLETED2");
|
2018-09-23 21:17:31 +00:00
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
if (serverCmd.m_sendContactPointArgs.m_numRemainingContactPoints > 0 && serverCmd.m_sendContactPointArgs.m_numContactPointsCopied)
|
2016-09-01 20:30:07 +00:00
|
|
|
{
|
|
|
|
command.m_type = CMD_REQUEST_CONTACT_POINT_INFORMATION;
|
2018-09-23 21:17:31 +00:00
|
|
|
command.m_requestContactPointArguments.m_startingContactPointIndex = serverCmd.m_sendContactPointArgs.m_startingContactPointIndex + serverCmd.m_sendContactPointArgs.m_numContactPointsCopied;
|
2016-09-01 20:30:07 +00:00
|
|
|
command.m_requestContactPointArguments.m_objectAIndexFilter = -1;
|
|
|
|
command.m_requestContactPointArguments.m_objectBIndexFilter = -1;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
if (serverCmd.m_type == CMD_VISUAL_SHAPE_INFO_COMPLETED)
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_VISUAL_SHAPE_INFO_COMPLETED2");
|
2016-10-19 05:05:28 +00:00
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
2018-09-23 21:17:31 +00:00
|
|
|
if (serverCmd.m_sendVisualShapeArgs.m_numRemainingVisualShapes > 0 && serverCmd.m_sendVisualShapeArgs.m_numVisualShapesCopied)
|
2016-10-19 05:05:28 +00:00
|
|
|
{
|
|
|
|
command.m_type = CMD_REQUEST_VISUAL_SHAPE_INFO;
|
|
|
|
command.m_requestVisualShapeDataArguments.m_startingVisualShapeIndex = serverCmd.m_sendVisualShapeArgs.m_startingVisualShapeIndex + serverCmd.m_sendVisualShapeArgs.m_numVisualShapesCopied;
|
|
|
|
command.m_requestVisualShapeDataArguments.m_bodyUniqueId = serverCmd.m_sendVisualShapeArgs.m_bodyUniqueId;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-31 17:23:04 +00:00
|
|
|
if (serverCmd.m_type == CMD_CAMERA_IMAGE_COMPLETED)
|
|
|
|
{
|
2017-03-26 20:06:46 +00:00
|
|
|
B3_PROFILE("CMD_CAMERA_IMAGE_COMPLETED2");
|
2016-05-31 17:23:04 +00:00
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
|
|
|
|
2016-08-08 21:23:44 +00:00
|
|
|
if (serverCmd.m_sendPixelDataArguments.m_numRemainingPixels > 0 && serverCmd.m_sendPixelDataArguments.m_numPixelsCopied)
|
2016-05-31 17:23:04 +00:00
|
|
|
{
|
|
|
|
// continue requesting remaining pixels
|
|
|
|
command.m_type = CMD_REQUEST_CAMERA_IMAGE_DATA;
|
2018-09-23 21:17:31 +00:00
|
|
|
command.m_requestPixelDataArguments.m_startPixelIndex =
|
|
|
|
serverCmd.m_sendPixelDataArguments.m_startingPixelIndex +
|
2016-05-31 17:23:04 +00:00
|
|
|
serverCmd.m_sendPixelDataArguments.m_numPixelsCopied;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
2016-05-31 17:23:04 +00:00
|
|
|
{
|
|
|
|
m_data->m_cachedCameraPixelsWidth = serverCmd.m_sendPixelDataArguments.m_imageWidth;
|
|
|
|
m_data->m_cachedCameraPixelsHeight = serverCmd.m_sendPixelDataArguments.m_imageHeight;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if ((serverCmd.m_type == CMD_DEBUG_LINES_COMPLETED) &&
|
|
|
|
(serverCmd.m_sendDebugLinesArgs.m_numRemainingDebugLines > 0))
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("CMD_DEBUG_LINES_COMPLETED2");
|
2018-09-23 21:17:31 +00:00
|
|
|
SharedMemoryCommand& command = m_data->m_testBlock1->m_clientCommands[0];
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
// continue requesting debug lines for drawing
|
|
|
|
command.m_type = CMD_REQUEST_DEBUG_LINES;
|
|
|
|
command.m_requestDebugLinesArguments.m_startingLineIndex =
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_numDebugLines +
|
|
|
|
serverCmd.m_sendDebugLinesArgs.m_startingLineIndex;
|
|
|
|
submitClientCommand(command);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
return &m_data->m_lastServerStatus;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_data->m_verboseOutput)
|
2017-03-26 20:06:46 +00:00
|
|
|
{
|
|
|
|
B3_PROFILE("m_verboseOutput");
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
b3Printf("m_numServerStatus = %d, processed = %d\n",
|
|
|
|
m_data->m_testBlock1->m_numServerCommands,
|
|
|
|
m_data->m_testBlock1->m_numProcessedServerCommands);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool PhysicsClientSharedMemory::canSubmitCommand() const
|
|
|
|
{
|
2017-03-02 20:33:22 +00:00
|
|
|
if (m_data->m_isConnected && !m_data->m_waitingForServer)
|
|
|
|
{
|
|
|
|
if (m_data->m_testBlock1->m_magicId == SHARED_MEMORY_MAGIC_NUMBER)
|
|
|
|
{
|
|
|
|
return true;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
2017-03-02 20:33:22 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
struct SharedMemoryCommand* PhysicsClientSharedMemory::getAvailableSharedMemoryCommand()
|
|
|
|
{
|
|
|
|
static int sequence = 0;
|
|
|
|
m_data->m_testBlock1->m_clientCommands[0].m_sequenceNumber = sequence++;
|
|
|
|
return &m_data->m_testBlock1->m_clientCommands[0];
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool PhysicsClientSharedMemory::submitClientCommand(const SharedMemoryCommand& command)
|
|
|
|
{
|
|
|
|
/// at the moment we allow a maximum of 1 outstanding command, so we check for this
|
|
|
|
// once the server processed the command and returns a status, we clear the flag
|
|
|
|
// "m_data->m_waitingForServer" and allow submitting the next command
|
2015-09-25 05:50:34 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (!m_data->m_waitingForServer)
|
|
|
|
{
|
|
|
|
if (&m_data->m_testBlock1->m_clientCommands[0] != &command)
|
|
|
|
{
|
|
|
|
m_data->m_testBlock1->m_clientCommands[0] = command;
|
|
|
|
}
|
|
|
|
m_data->m_testBlock1->m_numClientCommands++;
|
|
|
|
m_data->m_waitingForServer = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2018-06-15 14:47:04 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
void PhysicsClientSharedMemory::uploadBulletFileToSharedMemory(const char* data, int len)
|
|
|
|
{
|
|
|
|
btAssert(len < SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
if (len >= SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE)
|
|
|
|
{
|
|
|
|
b3Warning("uploadBulletFileToSharedMemory %d exceeds max size %d\n", len,
|
|
|
|
SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
//m_data->m_testBlock1->m_bulletStreamDataClientToServer[i] = data[i];
|
2017-07-01 02:11:43 +00:00
|
|
|
m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[i] = data[i];
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-06-16 15:14:00 +00:00
|
|
|
void PhysicsClientSharedMemory::uploadRaysToSharedMemory(struct SharedMemoryCommand& command, const double* rayFromWorldArray, const double* rayToWorldArray, int numRays)
|
|
|
|
{
|
2018-06-16 19:28:21 +00:00
|
|
|
int curNumStreamingRays = command.m_requestRaycastIntersections.m_numStreamingRays;
|
|
|
|
int newNumRays = curNumStreamingRays + numRays;
|
2018-09-23 21:17:31 +00:00
|
|
|
btAssert(newNumRays < MAX_RAY_INTERSECTION_BATCH_SIZE_STREAMING);
|
2018-06-16 15:14:00 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
if (newNumRays < MAX_RAY_INTERSECTION_BATCH_SIZE_STREAMING)
|
2018-06-16 15:14:00 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < numRays; i++)
|
2018-06-16 15:14:00 +00:00
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
b3RayData* rayDataStream = (b3RayData*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
|
|
|
rayDataStream[curNumStreamingRays + i].m_rayFromPosition[0] = rayFromWorldArray[i * 3 + 0];
|
|
|
|
rayDataStream[curNumStreamingRays + i].m_rayFromPosition[1] = rayFromWorldArray[i * 3 + 1];
|
|
|
|
rayDataStream[curNumStreamingRays + i].m_rayFromPosition[2] = rayFromWorldArray[i * 3 + 2];
|
|
|
|
rayDataStream[curNumStreamingRays + i].m_rayToPosition[0] = rayToWorldArray[i * 3 + 0];
|
|
|
|
rayDataStream[curNumStreamingRays + i].m_rayToPosition[1] = rayToWorldArray[i * 3 + 1];
|
|
|
|
rayDataStream[curNumStreamingRays + i].m_rayToPosition[2] = rayToWorldArray[i * 3 + 2];
|
2018-06-16 19:28:21 +00:00
|
|
|
command.m_requestRaycastIntersections.m_numStreamingRays++;
|
2018-06-16 15:14:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-31 17:23:04 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedCameraImage(struct b3CameraImageData* cameraData)
|
|
|
|
{
|
|
|
|
cameraData->m_pixelWidth = m_data->m_cachedCameraPixelsWidth;
|
|
|
|
cameraData->m_pixelHeight = m_data->m_cachedCameraPixelsHeight;
|
2016-08-12 20:55:37 +00:00
|
|
|
cameraData->m_depthValues = m_data->m_cachedCameraDepthBuffer.size() ? &m_data->m_cachedCameraDepthBuffer[0] : 0;
|
2016-05-31 17:23:04 +00:00
|
|
|
cameraData->m_rgbColorData = m_data->m_cachedCameraPixelsRGBA.size() ? &m_data->m_cachedCameraPixelsRGBA[0] : 0;
|
2018-09-23 21:17:31 +00:00
|
|
|
cameraData->m_segmentationMaskValues = m_data->m_cachedSegmentationMaskBuffer.size() ? &m_data->m_cachedSegmentationMaskBuffer[0] : 0;
|
2016-05-31 17:23:04 +00:00
|
|
|
}
|
|
|
|
|
2016-09-01 20:30:07 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedContactPointInformation(struct b3ContactInformation* contactPointData)
|
|
|
|
{
|
|
|
|
contactPointData->m_numContactPoints = m_data->m_cachedContactPoints.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
contactPointData->m_contactPointData = contactPointData->m_numContactPoints ? &m_data->m_cachedContactPoints[0] : 0;
|
2016-09-01 20:30:07 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 19:22:22 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedOverlappingObjects(struct b3AABBOverlapData* overlappingObjects)
|
|
|
|
{
|
|
|
|
overlappingObjects->m_numOverlappingObjects = m_data->m_cachedOverlappingObjects.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
overlappingObjects->m_overlappingObjects = m_data->m_cachedOverlappingObjects.size() ? &m_data->m_cachedOverlappingObjects[0] : 0;
|
2016-11-10 19:22:22 +00:00
|
|
|
}
|
|
|
|
|
2016-12-27 03:40:09 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedVREvents(struct b3VREventsData* vrEventsData)
|
|
|
|
{
|
|
|
|
vrEventsData->m_numControllerEvents = m_data->m_cachedVREvents.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
vrEventsData->m_controllerEvents = vrEventsData->m_numControllerEvents ? &m_data->m_cachedVREvents[0] : 0;
|
2016-12-27 03:40:09 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 20:33:22 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedKeyboardEvents(struct b3KeyboardEventsData* keyboardEventsData)
|
|
|
|
{
|
|
|
|
keyboardEventsData->m_numKeyboardEvents = m_data->m_cachedKeyboardEvents.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
keyboardEventsData->m_keyboardEvents = keyboardEventsData->m_numKeyboardEvents ? &m_data->m_cachedKeyboardEvents[0] : 0;
|
2017-03-02 20:33:22 +00:00
|
|
|
}
|
|
|
|
|
2017-06-17 20:29:14 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedMouseEvents(struct b3MouseEventsData* mouseEventsData)
|
|
|
|
{
|
|
|
|
mouseEventsData->m_numMouseEvents = m_data->m_cachedMouseEvents.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
mouseEventsData->m_mouseEvents = mouseEventsData->m_numMouseEvents ? &m_data->m_cachedMouseEvents[0] : 0;
|
2017-06-17 20:29:14 +00:00
|
|
|
}
|
|
|
|
|
2016-12-27 03:40:09 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedRaycastHits(struct b3RaycastInformation* raycastHits)
|
|
|
|
{
|
|
|
|
raycastHits->m_numRayHits = m_data->m_raycastHits.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
raycastHits->m_rayHits = raycastHits->m_numRayHits ? &m_data->m_raycastHits[0] : 0;
|
2016-12-27 03:40:09 +00:00
|
|
|
}
|
|
|
|
|
2017-10-05 15:23:10 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedMassMatrix(int dofCountCheck, double* massMatrix)
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
int sz = dofCountCheck * dofCountCheck;
|
2017-10-05 15:23:10 +00:00
|
|
|
if (sz == m_data->m_cachedMassMatrix.size())
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
for (int i = 0; i < sz; i++)
|
2017-10-05 15:23:10 +00:00
|
|
|
{
|
|
|
|
massMatrix[i] = m_data->m_cachedMassMatrix[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-19 05:05:28 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedVisualShapeInformation(struct b3VisualShapeInformation* visualShapesInfo)
|
|
|
|
{
|
|
|
|
visualShapesInfo->m_numVisualShapes = m_data->m_cachedVisualShapes.size();
|
|
|
|
visualShapesInfo->m_visualShapeData = visualShapesInfo->m_numVisualShapes ? &m_data->m_cachedVisualShapes[0] : 0;
|
|
|
|
}
|
|
|
|
|
2018-01-04 03:17:28 +00:00
|
|
|
void PhysicsClientSharedMemory::getCachedCollisionShapeInformation(struct b3CollisionShapeInformation* collisionShapesInfo)
|
|
|
|
{
|
|
|
|
collisionShapesInfo->m_numCollisionShapes = m_data->m_cachedCollisionShapes.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
collisionShapesInfo->m_collisionShapeData = collisionShapesInfo->m_numCollisionShapes ? &m_data->m_cachedCollisionShapes[0] : 0;
|
2018-01-04 03:17:28 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
const float* PhysicsClientSharedMemory::getDebugLinesFrom() const
|
|
|
|
{
|
|
|
|
if (m_data->m_debugLinesFrom.size())
|
|
|
|
{
|
|
|
|
return &m_data->m_debugLinesFrom[0].m_x;
|
|
|
|
}
|
|
|
|
return 0;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
const float* PhysicsClientSharedMemory::getDebugLinesTo() const
|
|
|
|
{
|
|
|
|
if (m_data->m_debugLinesTo.size())
|
|
|
|
{
|
|
|
|
return &m_data->m_debugLinesTo[0].m_x;
|
|
|
|
}
|
|
|
|
return 0;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
2018-09-23 21:17:31 +00:00
|
|
|
const float* PhysicsClientSharedMemory::getDebugLinesColor() const
|
|
|
|
{
|
|
|
|
if (m_data->m_debugLinesColor.size())
|
|
|
|
{
|
|
|
|
return &m_data->m_debugLinesColor[0].m_x;
|
|
|
|
}
|
|
|
|
return 0;
|
2015-09-25 05:50:34 +00:00
|
|
|
}
|
|
|
|
int PhysicsClientSharedMemory::getNumDebugLines() const { return m_data->m_debugLinesFrom.size(); }
|
2016-12-27 03:40:09 +00:00
|
|
|
|
2017-02-24 23:34:11 +00:00
|
|
|
void PhysicsClientSharedMemory::setTimeOut(double timeOutInSeconds)
|
|
|
|
{
|
|
|
|
m_data->m_timeOutInSeconds = timeOutInSeconds;
|
|
|
|
}
|
|
|
|
double PhysicsClientSharedMemory::getTimeOut() const
|
|
|
|
{
|
|
|
|
return m_data->m_timeOutInSeconds;
|
|
|
|
}
|
2018-06-02 20:40:08 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool PhysicsClientSharedMemory::getCachedUserData(int userDataId, struct b3UserDataValue& valueOut) const
|
|
|
|
{
|
|
|
|
SharedMemoryUserData* userDataPtr = m_data->m_userDataMap[userDataId];
|
|
|
|
if (!userDataPtr)
|
2018-06-02 20:40:08 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
valueOut.m_type = (userDataPtr)->m_type;
|
|
|
|
valueOut.m_length = userDataPtr->m_bytes.size();
|
2018-09-23 21:17:31 +00:00
|
|
|
valueOut.m_data1 = userDataPtr->m_bytes.size() ? &userDataPtr->m_bytes[0] : 0;
|
2018-06-02 20:40:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
int PhysicsClientSharedMemory::getCachedUserDataId(int bodyUniqueId, int linkIndex, int visualShapeIndex, const char* key) const
|
|
|
|
{
|
2018-07-03 15:45:19 +00:00
|
|
|
int* userDataId = m_data->m_userDataHandleLookup.find(SharedMemoryUserDataHashKey(key, bodyUniqueId, linkIndex, visualShapeIndex));
|
2018-09-23 21:17:31 +00:00
|
|
|
if (!userDataId)
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return *userDataId;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
int PhysicsClientSharedMemory::getNumUserData(int bodyUniqueId) const
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
2018-09-23 21:17:31 +00:00
|
|
|
if (!bodyJointsPtr || !(*bodyJointsPtr))
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2018-07-03 15:45:19 +00:00
|
|
|
return (*bodyJointsPtr)->m_userDataIds.size();
|
2018-06-02 20:40:08 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
void PhysicsClientSharedMemory::getUserDataInfo(int bodyUniqueId, int userDataIndex, const char** keyOut, int* userDataIdOut, int* linkIndexOut, int* visualShapeIndexOut) const
|
|
|
|
{
|
2018-06-02 20:40:08 +00:00
|
|
|
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
2018-09-23 21:17:31 +00:00
|
|
|
if (!bodyJointsPtr || !(*bodyJointsPtr) || userDataIndex < 0 || userDataIndex > (*bodyJointsPtr)->m_userDataIds.size())
|
2018-06-02 20:40:08 +00:00
|
|
|
{
|
|
|
|
*keyOut = 0;
|
|
|
|
*userDataIdOut = -1;
|
|
|
|
return;
|
|
|
|
}
|
2018-07-03 15:45:19 +00:00
|
|
|
int userDataId = (*bodyJointsPtr)->m_userDataIds[userDataIndex];
|
2018-09-23 21:17:31 +00:00
|
|
|
SharedMemoryUserData* userData = m_data->m_userDataMap[userDataId];
|
2018-07-03 15:45:19 +00:00
|
|
|
|
|
|
|
*userDataIdOut = userDataId;
|
|
|
|
*keyOut = userData->m_key.c_str();
|
|
|
|
*linkIndexOut = userData->m_linkIndex;
|
|
|
|
*visualShapeIndexOut = userData->m_visualShapeIndex;
|
2018-06-02 20:40:08 +00:00
|
|
|
}
|
2018-06-16 13:19:49 +00:00
|
|
|
|
|
|
|
void PhysicsClientSharedMemory::pushProfileTiming(const char* timingName)
|
|
|
|
{
|
2018-06-16 16:37:53 +00:00
|
|
|
std::string** strPtr = m_data->m_profileTimingStringArray[timingName];
|
|
|
|
std::string* str = 0;
|
|
|
|
if (strPtr)
|
|
|
|
{
|
|
|
|
str = *strPtr;
|
2018-09-23 21:17:31 +00:00
|
|
|
}
|
|
|
|
else
|
2018-06-16 16:37:53 +00:00
|
|
|
{
|
|
|
|
str = new std::string(timingName);
|
2018-09-23 21:17:31 +00:00
|
|
|
m_data->m_profileTimingStringArray.insert(timingName, str);
|
|
|
|
}
|
2018-06-16 13:19:49 +00:00
|
|
|
m_data->m_profileTimings.push_back(new CProfileSample(str->c_str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhysicsClientSharedMemory::popProfileTiming()
|
|
|
|
{
|
|
|
|
if (m_data->m_profileTimings.size())
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
CProfileSample* sample = m_data->m_profileTimings[m_data->m_profileTimings.size() - 1];
|
2018-06-16 13:19:49 +00:00
|
|
|
m_data->m_profileTimings.pop_back();
|
|
|
|
delete sample;
|
|
|
|
}
|
|
|
|
}
|