Replace large timeout (1024*1024*1024) using real-time clock timeout (10 seconds default)
Change SHARED_MEMORY_MAGIC_NUMBER to make sure server/client are using the same version (shared memory) add --realtimesimulation to physics server (GUI, VR) remove --G Xcode from build_cmake_pybullet_double.sh
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
rm CMakeCache.txt
|
rm CMakeCache.txt
|
||||||
mkdir build_cmake
|
mkdir build_cmake
|
||||||
cd build_cmake
|
cd build_cmake
|
||||||
cmake -DBUILD_PYBULLET=ON -DBUILD_PYBULLET_NUMPY=OFF -DUSE_DOUBLE_PRECISION=ON -DCMAKE_BUILD_TYPE=Release -G Xcode ..
|
cmake -DBUILD_PYBULLET=ON -DBUILD_PYBULLET_NUMPY=OFF -DUSE_DOUBLE_PRECISION=ON -DCMAKE_BUILD_TYPE=Release ..
|
||||||
make -j12
|
make -j12
|
||||||
cd examples
|
cd examples
|
||||||
cd pybullet
|
cd pybullet
|
||||||
|
|||||||
@@ -1033,9 +1033,15 @@ int b3SubmitClientCommand(b3PhysicsClientHandle physClient, const b3SharedMemory
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "../Utils/b3Clock.h"
|
||||||
|
|
||||||
|
|
||||||
b3SharedMemoryStatusHandle b3SubmitClientCommandAndWaitStatus(b3PhysicsClientHandle physClient, const b3SharedMemoryCommandHandle commandHandle)
|
b3SharedMemoryStatusHandle b3SubmitClientCommandAndWaitStatus(b3PhysicsClientHandle physClient, const b3SharedMemoryCommandHandle commandHandle)
|
||||||
{
|
{
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
b3SharedMemoryStatusHandle statusHandle = 0;
|
b3SharedMemoryStatusHandle statusHandle = 0;
|
||||||
b3Assert(commandHandle);
|
b3Assert(commandHandle);
|
||||||
b3Assert(physClient);
|
b3Assert(physClient);
|
||||||
@@ -1043,7 +1049,7 @@ b3SharedMemoryStatusHandle b3SubmitClientCommandAndWaitStatus(b3PhysicsClientHan
|
|||||||
{
|
{
|
||||||
b3SubmitClientCommand(physClient, commandHandle);
|
b3SubmitClientCommand(physClient, commandHandle);
|
||||||
|
|
||||||
while ((statusHandle == 0) && (timeout-- > 0))
|
while ((statusHandle == 0) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
statusHandle = b3ProcessServerStatus(physClient);
|
statusHandle = b3ProcessServerStatus(physClient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,11 +268,13 @@ bool PhysicsClientSharedMemory::connect() {
|
|||||||
command.m_type = CMD_REQUEST_BODY_INFO;
|
command.m_type = CMD_REQUEST_BODY_INFO;
|
||||||
command.m_sdfRequestInfoArgs.m_bodyUniqueId = 37;
|
command.m_sdfRequestInfoArgs.m_bodyUniqueId = 37;
|
||||||
submitClientCommand(command);
|
submitClientCommand(command);
|
||||||
int timeout = 1024 * 1024 * 1024;
|
|
||||||
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
const SharedMemoryStatus* status = 0;
|
const SharedMemoryStatus* status = 0;
|
||||||
|
|
||||||
while ((status == 0) && (timeout-- > 0))
|
while ((status == 0) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
status = processServerStatus();
|
status = processServerStatus();
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ struct TcpNetworkedInternalData
|
|||||||
m_tcpSocket.Initialize();
|
m_tcpSocket.Initialize();
|
||||||
|
|
||||||
m_isConnected = m_tcpSocket.Open(m_hostName.c_str(),m_port);
|
m_isConnected = m_tcpSocket.Open(m_hostName.c_str(),m_port);
|
||||||
|
if (m_isConnected)
|
||||||
|
{
|
||||||
|
m_tcpSocket.SetSendTimeout(5,0);
|
||||||
|
m_tcpSocket.SetReceiveTimeout(5,0);
|
||||||
|
}
|
||||||
|
int key = SHARED_MEMORY_MAGIC_NUMBER;
|
||||||
|
m_tcpSocket.Send((uint8*)&key,4);
|
||||||
|
|
||||||
return m_isConnected;
|
return m_isConnected;
|
||||||
}
|
}
|
||||||
@@ -243,6 +250,8 @@ bool TcpNetworkedPhysicsProcessor::connect()
|
|||||||
|
|
||||||
void TcpNetworkedPhysicsProcessor::disconnect()
|
void TcpNetworkedPhysicsProcessor::disconnect()
|
||||||
{
|
{
|
||||||
|
const char msg[16]="disconnect";
|
||||||
|
m_data->m_tcpSocket.Send((const uint8 *)msg,10);
|
||||||
m_data->m_tcpSocket.Close();
|
m_data->m_tcpSocket.Close();
|
||||||
m_data->m_isConnected = false;
|
m_data->m_isConnected = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,26 +464,32 @@ bool UdpNetworkedPhysicsProcessor::processCommand(const struct SharedMemoryComma
|
|||||||
printf("PhysicsClientUDP::processCommand\n");
|
printf("PhysicsClientUDP::processCommand\n");
|
||||||
}
|
}
|
||||||
// int sz = sizeof(SharedMemoryCommand);
|
// int sz = sizeof(SharedMemoryCommand);
|
||||||
int timeout = 1024 * 1024 * 1024;
|
|
||||||
|
b3Clock clock;
|
||||||
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
m_data->m_cs->lock();
|
m_data->m_cs->lock();
|
||||||
m_data->m_clientCmd = clientCmd;
|
m_data->m_clientCmd = clientCmd;
|
||||||
m_data->m_hasCommand = true;
|
m_data->m_hasCommand = true;
|
||||||
m_data->m_cs->unlock();
|
m_data->m_cs->unlock();
|
||||||
|
|
||||||
while (m_data->m_hasCommand && (timeout-- > 0))
|
while ((m_data->m_hasCommand) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
b3Clock::usleep(0);
|
b3Clock::usleep(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
timeout = 1024 * 1024 * 1024;
|
|
||||||
|
|
||||||
bool hasStatus = false;
|
bool hasStatus = false;
|
||||||
|
|
||||||
|
b3Clock clock;
|
||||||
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
const SharedMemoryStatus* stat = 0;
|
const SharedMemoryStatus* stat = 0;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
while ((!hasStatus) && (clock.getTimeInSeconds() - startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
hasStatus = receiveStatus(serverStatusOut, bufferServerToClient, bufferSizeInBytes);
|
hasStatus = receiveStatus(serverStatusOut, bufferServerToClient, bufferSizeInBytes);
|
||||||
b3Clock::usleep(100);
|
b3Clock::usleep(100);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
||||||
#include "SharedMemoryCommands.h"
|
#include "SharedMemoryCommands.h"
|
||||||
#include "PhysicsCommandProcessorInterface.h"
|
#include "PhysicsCommandProcessorInterface.h"
|
||||||
|
#include "../Utils/b3Clock.h"
|
||||||
|
|
||||||
#include "LinearMath/btHashMap.h"
|
#include "LinearMath/btHashMap.h"
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
@@ -137,8 +137,10 @@ bool PhysicsDirect::connect()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double timeSec = clock.getTimeInSeconds();
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-timeSec <10 ))
|
||||||
{
|
{
|
||||||
const SharedMemoryStatus* stat = processServerStatus();
|
const SharedMemoryStatus* stat = processServerStatus();
|
||||||
if (stat)
|
if (stat)
|
||||||
@@ -226,8 +228,11 @@ bool PhysicsDirect::processDebugLines(const struct SharedMemoryCommand& orgComma
|
|||||||
|
|
||||||
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
|
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
const SharedMemoryStatus* stat = processServerStatus();
|
const SharedMemoryStatus* stat = processServerStatus();
|
||||||
if (stat)
|
if (stat)
|
||||||
@@ -308,8 +313,11 @@ bool PhysicsDirect::processVisualShapeData(const struct SharedMemoryCommand& org
|
|||||||
{
|
{
|
||||||
bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
|
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
const SharedMemoryStatus* stat = processServerStatus();
|
const SharedMemoryStatus* stat = processServerStatus();
|
||||||
if (stat)
|
if (stat)
|
||||||
@@ -359,8 +367,11 @@ bool PhysicsDirect::processOverlappingObjects(const struct SharedMemoryCommand&
|
|||||||
{
|
{
|
||||||
bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command, m_data->m_serverStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
|
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
const SharedMemoryStatus* stat = processServerStatus();
|
const SharedMemoryStatus* stat = processServerStatus();
|
||||||
if (stat)
|
if (stat)
|
||||||
@@ -414,8 +425,11 @@ bool PhysicsDirect::processContactPointData(const struct SharedMemoryCommand& or
|
|||||||
{
|
{
|
||||||
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
|
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
const SharedMemoryStatus* stat = processServerStatus();
|
const SharedMemoryStatus* stat = processServerStatus();
|
||||||
if (stat)
|
if (stat)
|
||||||
@@ -475,8 +489,11 @@ bool PhysicsDirect::processCamera(const struct SharedMemoryCommand& orgCommand)
|
|||||||
|
|
||||||
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
|
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
const SharedMemoryStatus* stat = processServerStatus();
|
const SharedMemoryStatus* stat = processServerStatus();
|
||||||
if (stat)
|
if (stat)
|
||||||
@@ -735,8 +752,11 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
|||||||
bool hasStatus = m_data->m_commandProcessor->processCommand(infoRequestCommand, infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
bool hasStatus = m_data->m_commandProcessor->processCommand(infoRequestCommand, infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
|
|
||||||
|
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
hasStatus = m_data->m_commandProcessor->receiveStatus(infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
hasStatus = m_data->m_commandProcessor->receiveStatus(infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
@@ -759,8 +779,11 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
|||||||
bool hasStatus = m_data->m_commandProcessor->processCommand(infoRequestCommand, infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
bool hasStatus = m_data->m_commandProcessor->processCommand(infoRequestCommand, infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
|
|
||||||
|
|
||||||
int timeout = 1024 * 1024 * 1024;
|
b3Clock clock;
|
||||||
while ((!hasStatus) && (timeout-- > 0))
|
double startTime = clock.getTimeInSeconds();
|
||||||
|
double timeOutInSeconds = 10;
|
||||||
|
|
||||||
|
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
|
||||||
{
|
{
|
||||||
hasStatus = m_data->m_commandProcessor->receiveStatus(infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
hasStatus = m_data->m_commandProcessor->receiveStatus(infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1153,6 +1153,12 @@ public:
|
|||||||
gCreateDefaultRobotAssets = true;
|
gCreateDefaultRobotAssets = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.CheckCmdLineFlag("realtimesimulation"))
|
||||||
|
{
|
||||||
|
//gEnableRealTimeSimVR = true;
|
||||||
|
m_physicsServer.enableRealTimeSimulation(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (args.CheckCmdLineFlag("norobotassets"))
|
if (args.CheckCmdLineFlag("norobotassets"))
|
||||||
{
|
{
|
||||||
gCreateDefaultRobotAssets = false;
|
gCreateDefaultRobotAssets = false;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef SHARED_MEMORY_BLOCK_H
|
#ifndef SHARED_MEMORY_BLOCK_H
|
||||||
#define SHARED_MEMORY_BLOCK_H
|
#define SHARED_MEMORY_BLOCK_H
|
||||||
|
|
||||||
#define SHARED_MEMORY_MAGIC_NUMBER 64738
|
|
||||||
#define SHARED_MEMORY_MAX_COMMANDS 4
|
#define SHARED_MEMORY_MAX_COMMANDS 4
|
||||||
|
|
||||||
|
|
||||||
#include "SharedMemoryCommands.h"
|
#include "SharedMemoryCommands.h"
|
||||||
|
|
||||||
struct SharedMemoryBlock
|
struct SharedMemoryBlock
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#define SHARED_MEMORY_PUBLIC_H
|
#define SHARED_MEMORY_PUBLIC_H
|
||||||
|
|
||||||
#define SHARED_MEMORY_KEY 12347
|
#define SHARED_MEMORY_KEY 12347
|
||||||
|
///increase the SHARED_MEMORY_MAGIC_NUMBER whenever incompatible changes are made in the structures
|
||||||
|
///my convention is year/month/day/rev
|
||||||
|
#define SHARED_MEMORY_MAGIC_NUMBER 201702220
|
||||||
|
|
||||||
enum EnumSharedMemoryClientCommand
|
enum EnumSharedMemoryClientCommand
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,10 +44,7 @@ int main(int argc, char *argv[])
|
|||||||
sm->setGuiHelper(&guiHelper);
|
sm->setGuiHelper(&guiHelper);
|
||||||
|
|
||||||
int port = 6667;
|
int port = 6667;
|
||||||
if (parseArgs.GetCmdLineArgument("port",port))
|
parseArgs.GetCmdLineArgument("port",port);
|
||||||
{
|
|
||||||
printf("Using TCP port %d\n", port);
|
|
||||||
}
|
|
||||||
|
|
||||||
gVerboseNetworkMessagesServer = parseArgs.CheckCmdLineFlag("verbose");
|
gVerboseNetworkMessagesServer = parseArgs.CheckCmdLineFlag("verbose");
|
||||||
|
|
||||||
@@ -65,6 +62,8 @@ int main(int argc, char *argv[])
|
|||||||
if (isPhysicsClientConnected)
|
if (isPhysicsClientConnected)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
printf("Starting TCP server using port %d\n", port);
|
||||||
|
|
||||||
CPassiveSocket socket;
|
CPassiveSocket socket;
|
||||||
CActiveSocket *pClient = NULL;
|
CActiveSocket *pClient = NULL;
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ int main(int argc, char *argv[])
|
|||||||
socket.Initialize();
|
socket.Initialize();
|
||||||
|
|
||||||
socket.Listen("localhost", port);
|
socket.Listen("localhost", port);
|
||||||
socket.SetBlocking();
|
//socket.SetBlocking();
|
||||||
|
|
||||||
int curNumErr = 0;
|
int curNumErr = 0;
|
||||||
|
|
||||||
@@ -90,6 +89,19 @@ int main(int argc, char *argv[])
|
|||||||
int clientPort = socket.GetClientPort();
|
int clientPort = socket.GetClientPort();
|
||||||
printf("connected from %s:%d\n", socket.GetClientAddr(),clientPort);
|
printf("connected from %s:%d\n", socket.GetClientAddr(),clientPort);
|
||||||
|
|
||||||
|
if (pClient->Receive(4))
|
||||||
|
{
|
||||||
|
int clientKey = *(int*)pClient->GetData();
|
||||||
|
|
||||||
|
if (clientKey==SHARED_MEMORY_MAGIC_NUMBER)
|
||||||
|
{
|
||||||
|
printf("Client version OK %d\n", clientKey);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
printf("Server version (%d) mismatches Client Version (%d)\n", SHARED_MEMORY_MAGIC_NUMBER,clientKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Receive request from the client.
|
// Receive request from the client.
|
||||||
@@ -102,9 +114,14 @@ int main(int argc, char *argv[])
|
|||||||
int maxLen = 4 + sizeof(SharedMemoryStatus)+SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE;
|
int maxLen = 4 + sizeof(SharedMemoryStatus)+SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (pClient->Receive(maxLen))
|
||||||
|
{
|
||||||
|
|
||||||
//heuristic to detect disconnected clients
|
//heuristic to detect disconnected clients
|
||||||
CSimpleSocket::CSocketError err = pClient->GetSocketError();
|
CSimpleSocket::CSocketError err = pClient->GetSocketError();
|
||||||
if (err != CSimpleSocket::SocketSuccess)
|
|
||||||
|
if (err != CSimpleSocket::SocketSuccess || !pClient->IsSocketValid())
|
||||||
{
|
{
|
||||||
b3Clock::usleep(100);
|
b3Clock::usleep(100);
|
||||||
|
|
||||||
@@ -118,9 +135,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pClient->Receive(maxLen))
|
|
||||||
{
|
|
||||||
|
|
||||||
curNumErr = 0;
|
curNumErr = 0;
|
||||||
char* msg2 = (char*) pClient->GetData();
|
char* msg2 = (char*) pClient->GetData();
|
||||||
int numBytesRec2 = pClient->GetBytesReceived();
|
int numBytesRec2 = pClient->GetBytesReceived();
|
||||||
@@ -132,9 +146,26 @@ int main(int argc, char *argv[])
|
|||||||
bytesReceived[curSize+i] = msg2[i];
|
bytesReceived[curSize+i] = msg2[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytesReceived.size() == 4 || bytesReceived.size()==sizeof(SharedMemoryCommand))
|
if (bytesReceived.size() >= 4)
|
||||||
{
|
{
|
||||||
int numBytesRec = bytesReceived.size();
|
int numBytesRec = bytesReceived.size();
|
||||||
|
if (numBytesRec>=10)
|
||||||
|
{
|
||||||
|
if (strncmp(&bytesReceived[0],"disconnect",10)==0)
|
||||||
|
{
|
||||||
|
printf("Disconnect request received\n");
|
||||||
|
bytesReceived.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp(&bytesReceived[0],"terminateserver",10)==0)
|
||||||
|
{
|
||||||
|
printf("Terminate server request received\n");
|
||||||
|
exitRequested = true;
|
||||||
|
bytesReceived.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gVerboseNetworkMessagesServer)
|
if (gVerboseNetworkMessagesServer)
|
||||||
{
|
{
|
||||||
@@ -143,15 +174,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
receivedData = true;
|
receivedData = true;
|
||||||
|
|
||||||
if (strncmp(&bytesReceived[0],"stop",4)==0)
|
|
||||||
{
|
|
||||||
printf("Stop request received\n");
|
|
||||||
exitRequested = true;
|
|
||||||
bytesReceived.clear();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SharedMemoryCommand cmd;
|
SharedMemoryCommand cmd;
|
||||||
|
|
||||||
SharedMemoryCommand* cmdPtr = 0;
|
SharedMemoryCommand* cmdPtr = 0;
|
||||||
@@ -233,12 +255,15 @@ int main(int argc, char *argv[])
|
|||||||
pClient->Send( &packetData[0], packetData.size() );
|
pClient->Send( &packetData[0], packetData.size() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bytesReceived.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("received packet with unknown contents\n");
|
//likely an incomplete packet, let's append more bytes
|
||||||
|
//printf("received packet with unknown contents\n");
|
||||||
}
|
}
|
||||||
bytesReceived.clear();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,6 +281,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
socket.Close();
|
socket.Close();
|
||||||
socket.Shutdown(CSimpleSocket::Both);
|
socket.Shutdown(CSimpleSocket::Both);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
printf("Error: cannot connect to shared memory physics server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
delete sm;
|
delete sm;
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ static PyObject* pybullet_connectPhysicsServer(PyObject* self, PyObject* args, P
|
|||||||
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command);
|
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command);
|
||||||
statusType = b3GetStatusType(statusHandle);
|
statusType = b3GetStatusType(statusHandle);
|
||||||
#if 0
|
#if 0
|
||||||
if (statusType != CMD_BODY_INFO_COMPLETED) {
|
if (statusType != CMD_BODY_INFO_COMPLETED)
|
||||||
|
{
|
||||||
PyErr_SetString(SpamError, "b3InitSyncBodyInfoCommand failed.");
|
PyErr_SetString(SpamError, "b3InitSyncBodyInfoCommand failed.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ ENDIF()
|
|||||||
../../examples/SharedMemory/PosixSharedMemory.h
|
../../examples/SharedMemory/PosixSharedMemory.h
|
||||||
../../examples/Utils/b3ResourcePath.cpp
|
../../examples/Utils/b3ResourcePath.cpp
|
||||||
../../examples/Utils/b3ResourcePath.h
|
../../examples/Utils/b3ResourcePath.h
|
||||||
|
../../examples/Utils/b3Clock.cpp
|
||||||
|
../../examples/Utils/b3Clock.h
|
||||||
../../examples/Utils/RobotLoggingUtil.cpp
|
../../examples/Utils/RobotLoggingUtil.cpp
|
||||||
../../examples/Utils/RobotLoggingUtil.h
|
../../examples/Utils/RobotLoggingUtil.h
|
||||||
../../examples/SharedMemory/TinyRendererVisualShapeConverter.cpp
|
../../examples/SharedMemory/TinyRendererVisualShapeConverter.cpp
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ project ("Test_SharedMemoryPhysicsClient")
|
|||||||
"../../examples/SharedMemory/Win32SharedMemory.h",
|
"../../examples/SharedMemory/Win32SharedMemory.h",
|
||||||
"../../examples/SharedMemory/PosixSharedMemory.cpp",
|
"../../examples/SharedMemory/PosixSharedMemory.cpp",
|
||||||
"../../examples/SharedMemory/PosixSharedMemory.h",
|
"../../examples/SharedMemory/PosixSharedMemory.h",
|
||||||
|
"../../examples/Utils/b3Clock.cpp",
|
||||||
|
"../../examples/Utils/b3Clock.h",
|
||||||
"../../examples/Utils/b3ResourcePath.cpp",
|
"../../examples/Utils/b3ResourcePath.cpp",
|
||||||
"../../examples/Utils/b3ResourcePath.h",
|
"../../examples/Utils/b3ResourcePath.h",
|
||||||
}
|
}
|
||||||
@@ -200,6 +202,8 @@ project ("Test_PhysicsServerLoopBack")
|
|||||||
"../../examples/Utils/b3ResourcePath.h",
|
"../../examples/Utils/b3ResourcePath.h",
|
||||||
"../../examples/Utils/RobotLoggingUtil.cpp",
|
"../../examples/Utils/RobotLoggingUtil.cpp",
|
||||||
"../../examples/Utils/RobotLoggingUtil.h",
|
"../../examples/Utils/RobotLoggingUtil.h",
|
||||||
|
"../../examples/Utils/b3Clock.cpp",
|
||||||
|
"../../examples/Utils/b3Clock.h",
|
||||||
"../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp",
|
"../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp",
|
||||||
"../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp",
|
"../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp",
|
||||||
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
|
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
|
||||||
@@ -276,6 +280,8 @@ project ("Test_PhysicsServerLoopBack")
|
|||||||
"../../examples/Utils/b3ResourcePath.h",
|
"../../examples/Utils/b3ResourcePath.h",
|
||||||
"../../examples/Utils/RobotLoggingUtil.cpp",
|
"../../examples/Utils/RobotLoggingUtil.cpp",
|
||||||
"../../examples/Utils/RobotLoggingUtil.h",
|
"../../examples/Utils/RobotLoggingUtil.h",
|
||||||
|
"../../examples/Utils/b3Clock.cpp",
|
||||||
|
"../../examples/Utils/b3Clock.h",
|
||||||
"../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp",
|
"../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp",
|
||||||
"../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp",
|
"../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp",
|
||||||
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
|
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
|
||||||
|
|||||||
Reference in New Issue
Block a user