Merge pull request #504 from erwincoumans/master

catch setting of invalid joint angles in PhysicsClientC_Api,	Fix issue related to CMD_RESET_SIMULATION, 	add SIM_PARAM_UPDATE_DELTA_TIME flag
This commit is contained in:
erwincoumans
2015-10-25 10:53:54 -07:00
2 changed files with 13 additions and 7 deletions

View File

@@ -95,6 +95,7 @@ int b3PhysicsParamSetTimeStep(b3SharedMemoryCommandHandle commandHandle, double
{ {
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle; struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
b3Assert(command->m_type == CMD_SEND_PHYSICS_SIMULATION_PARAMETERS); b3Assert(command->m_type == CMD_SEND_PHYSICS_SIMULATION_PARAMETERS);
command->m_updateFlags |= SIM_PARAM_UPDATE_DELTA_TIME;
command->m_physSimParamArgs.m_deltaTime = timeStep; command->m_physSimParamArgs.m_deltaTime = timeStep;
return 0; return 0;
} }
@@ -313,12 +314,16 @@ int b3CreatePoseCommandSetJointPositions(b3SharedMemoryCommandHandle commandHand
int b3CreatePoseCommandSetJointPosition(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle, int jointIndex, double jointPosition) int b3CreatePoseCommandSetJointPosition(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle, int jointIndex, double jointPosition)
{ {
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle; struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
b3Assert(command); b3Assert(command);
b3Assert(command->m_type == CMD_INIT_POSE); b3Assert(command->m_type == CMD_INIT_POSE);
command->m_updateFlags |=INIT_POSE_HAS_JOINT_STATE; command->m_updateFlags |=INIT_POSE_HAS_JOINT_STATE;
b3JointInfo info; b3JointInfo info;
b3GetJointInfo(physClient, command->m_initPoseArgs.m_bodyUniqueId,jointIndex, &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; return 0;
} }

View File

@@ -1246,7 +1246,7 @@ void PhysicsServerSharedMemory::processClientCommands()
{ {
b3Printf("Server Init Pose not implemented yet"); 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); InteralBodyData* body = m_data->getHandle(bodyUniqueId);
if (body && body->m_multiBody) if (body && body->m_multiBody)
@@ -1301,8 +1301,9 @@ void PhysicsServerSharedMemory::processClientCommands()
m_data->m_guiHelper->getRenderInterface()->removeAllInstances(); m_data->m_guiHelper->getRenderInterface()->removeAllInstances();
} }
deleteDynamicsWorld(); deleteDynamicsWorld();
createEmptyDynamicsWorld(); createEmptyDynamicsWorld();
m_data->exitHandles();
m_data->initHandles();
SharedMemoryStatus& serverCmd =m_data->createServerStatus(CMD_RESET_SIMULATION_COMPLETED,clientCmd.m_sequenceNumber,timeStamp); SharedMemoryStatus& serverCmd =m_data->createServerStatus(CMD_RESET_SIMULATION_COMPLETED,clientCmd.m_sequenceNumber,timeStamp);
m_data->submitServerStatus(serverCmd); m_data->submitServerStatus(serverCmd);