From f28150c36894874598548684d876261cce109bae Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 24 Oct 2015 13:48:53 -0700 Subject: [PATCH 1/3] catch setting of invalid joint angles in PhysicsClientC_Api use the proper m_bodyUniqueIndex (todo: fix this field, move to shared command data) --- examples/SharedMemory/PhysicsClientC_API.cpp | 12 ++++++++---- examples/SharedMemory/PhysicsServer.cpp | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/SharedMemory/PhysicsClientC_API.cpp b/examples/SharedMemory/PhysicsClientC_API.cpp index 1d76ae427..1a0acbcdb 100644 --- a/examples/SharedMemory/PhysicsClientC_API.cpp +++ b/examples/SharedMemory/PhysicsClientC_API.cpp @@ -313,12 +313,16 @@ int b3CreatePoseCommandSetJointPositions(b3SharedMemoryCommandHandle commandHand int b3CreatePoseCommandSetJointPosition(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle, int jointIndex, double jointPosition) { struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle; - b3Assert(command); - b3Assert(command->m_type == CMD_INIT_POSE); - command->m_updateFlags |=INIT_POSE_HAS_JOINT_STATE; + b3Assert(command); + b3Assert(command->m_type == CMD_INIT_POSE); + command->m_updateFlags |=INIT_POSE_HAS_JOINT_STATE; b3JointInfo info; b3GetJointInfo(physClient, command->m_initPoseArgs.m_bodyUniqueId,jointIndex, &info); - command->m_initPoseArgs.m_initialStateQ[info.m_qIndex] = jointPosition; + btAssert((info.m_flags & JOINT_HAS_MOTORIZED_POWER) && info.m_qIndex >=0); + if ((info.m_flags & JOINT_HAS_MOTORIZED_POWER) && info.m_qIndex >=0) + { + command->m_initPoseArgs.m_initialStateQ[info.m_qIndex] = jointPosition; + } return 0; } diff --git a/examples/SharedMemory/PhysicsServer.cpp b/examples/SharedMemory/PhysicsServer.cpp index 97d5aa55d..878eb57e5 100644 --- a/examples/SharedMemory/PhysicsServer.cpp +++ b/examples/SharedMemory/PhysicsServer.cpp @@ -1246,7 +1246,7 @@ void PhysicsServerSharedMemory::processClientCommands() { b3Printf("Server Init Pose not implemented yet"); } - int bodyUniqueId = clientCmd.m_sendDesiredStateCommandArgument.m_bodyUniqueId; + int bodyUniqueId = clientCmd.m_initPoseArgs.m_bodyUniqueId; InteralBodyData* body = m_data->getHandle(bodyUniqueId); if (body && body->m_multiBody) From 818037c011575bfc2a9962ea4445cd940bf108f9 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 24 Oct 2015 13:49:25 -0700 Subject: [PATCH 2/3] Fix issue related to CMD_RESET_SIMULATION --- examples/SharedMemory/PhysicsServer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/SharedMemory/PhysicsServer.cpp b/examples/SharedMemory/PhysicsServer.cpp index 878eb57e5..a9bdc787e 100644 --- a/examples/SharedMemory/PhysicsServer.cpp +++ b/examples/SharedMemory/PhysicsServer.cpp @@ -1301,8 +1301,9 @@ void PhysicsServerSharedMemory::processClientCommands() m_data->m_guiHelper->getRenderInterface()->removeAllInstances(); } deleteDynamicsWorld(); - createEmptyDynamicsWorld(); - + createEmptyDynamicsWorld(); + m_data->exitHandles(); + m_data->initHandles(); SharedMemoryStatus& serverCmd =m_data->createServerStatus(CMD_RESET_SIMULATION_COMPLETED,clientCmd.m_sequenceNumber,timeStamp); m_data->submitServerStatus(serverCmd); From ec1947bbbd38d1068a04f6321290d343f1357ec4 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 24 Oct 2015 13:50:11 -0700 Subject: [PATCH 3/3] add SIM_PARAM_UPDATE_DELTA_TIME flag to fix setting the time step in shared memory API --- examples/SharedMemory/PhysicsClientC_API.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/SharedMemory/PhysicsClientC_API.cpp b/examples/SharedMemory/PhysicsClientC_API.cpp index 1a0acbcdb..2a81fcdab 100644 --- a/examples/SharedMemory/PhysicsClientC_API.cpp +++ b/examples/SharedMemory/PhysicsClientC_API.cpp @@ -95,6 +95,7 @@ int b3PhysicsParamSetTimeStep(b3SharedMemoryCommandHandle commandHandle, double { struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle; b3Assert(command->m_type == CMD_SEND_PHYSICS_SIMULATION_PARAMETERS); + command->m_updateFlags |= SIM_PARAM_UPDATE_DELTA_TIME; command->m_physSimParamArgs.m_deltaTime = timeStep; return 0; }