Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6784cff

Browse files
authoredFeb 17, 2017
Merge pull request #964 from erwincoumans/master
initial implementation of state logging
2 parents 835dea5 + 8af6223 commit 6784cff

20 files changed

+620
-11
lines changed
 

‎examples/ExampleBrowser/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ SET(BulletExampleBrowser_SRCS
317317
../Importers/ImportURDFDemo/MyMultiBodyCreator.cpp
318318
../Importers/ImportURDFDemo/MyMultiBodyCreator.h
319319
../Importers/ImportURDFDemo/UrdfParser.cpp
320+
../Utils/RobotLoggingUtil.cpp
321+
../Utils/RobotLoggingUtil.h
320322
../Importers/ImportURDFDemo/urdfStringSplit.cpp
321323
../Importers/ImportURDFDemo/urdfStringSplit.h
322324
../Importers/ImportURDFDemo/BulletUrdfImporter.cpp

‎examples/ExampleBrowser/premake4.lua

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ project "App_BulletExampleBrowser"
9797
"../BasicDemo/BasicExample.*",
9898
"../Tutorial/*",
9999
"../ExtendedTutorials/*",
100+
"../Utils/RobotLoggingUtil.cpp",
101+
"../Utils/RobotLoggingUtil.h",
100102
"../Evolution/NN3DWalkers.cpp",
101103
"../Evolution/NN3DWalkers.h",
102104
"../Collision/*",
@@ -193,6 +195,7 @@ project "BulletExampleBrowserLib"
193195
"OpenGLGuiHelper.cpp",
194196
"OpenGLExampleBrowser.cpp",
195197
"../Utils/b3Clock.cpp",
198+
"../Utils/b3Clock.h",
196199
"../Utils/ChromeTraceUtil.cpp",
197200
"../Utils/ChromeTraceUtil.h",
198201
"*.h",

‎examples/SharedMemory/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ SET(SharedMemory_SRCS
6161
../Importers/ImportMJCFDemo/BulletMJCFImporter.h
6262
../Utils/b3ResourcePath.cpp
6363
../Utils/b3Clock.cpp
64+
../Utils/RobotLoggingUtil.cpp
65+
../Utils/RobotLoggingUtil.h
6466
../Utils/ChromeTraceUtil.cpp
6567
../Utils/ChromeTraceUtil.h
6668
../Importers/ImportURDFDemo/URDFImporterInterface.h

‎examples/SharedMemory/PhysicsClientC_API.cpp

+78
Original file line numberDiff line numberDiff line change
@@ -2467,3 +2467,81 @@ int b3SetVRCameraTrackingObject(b3SharedMemoryCommandHandle commandHandle, int o
24672467
return 0;
24682468
}
24692469

2470+
b3SharedMemoryCommandHandle b3StateLoggingCommandInit(b3PhysicsClientHandle physClient)
2471+
{
2472+
PhysicsClient* cl = (PhysicsClient*)physClient;
2473+
b3Assert(cl);
2474+
b3Assert(cl->canSubmitCommand());
2475+
struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand();
2476+
b3Assert(command);
2477+
2478+
command->m_type = CMD_STATE_LOGGING;
2479+
command->m_updateFlags = 0;
2480+
command->m_stateLoggingArguments.m_numBodyUniqueIds = 0;
2481+
2482+
return (b3SharedMemoryCommandHandle)command;
2483+
2484+
}
2485+
2486+
int b3StateLoggingStart(b3SharedMemoryCommandHandle commandHandle, int loggingType, const char* fileName)
2487+
{
2488+
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
2489+
b3Assert(command);
2490+
b3Assert(command->m_type == CMD_STATE_LOGGING);
2491+
if (command->m_type == CMD_STATE_LOGGING)
2492+
{
2493+
command->m_updateFlags |= STATE_LOGGING_START_LOG;
2494+
int len = strlen(fileName);
2495+
if (len < MAX_FILENAME_LENGTH)
2496+
{
2497+
strcpy(command->m_stateLoggingArguments.m_fileName, fileName);
2498+
}
2499+
else
2500+
{
2501+
command->m_stateLoggingArguments.m_fileName[0] = 0;
2502+
}
2503+
command->m_stateLoggingArguments.m_logType = loggingType;
2504+
}
2505+
return 0;
2506+
}
2507+
2508+
int b3GetStatusLoggingUniqueId(b3SharedMemoryStatusHandle statusHandle)
2509+
{
2510+
const SharedMemoryStatus* status = (const SharedMemoryStatus* ) statusHandle;
2511+
b3Assert(status);
2512+
b3Assert(status->m_type == CMD_STATE_LOGGING_START_COMPLETED);
2513+
if (status && status->m_type == CMD_STATE_LOGGING_START_COMPLETED)
2514+
{
2515+
return status->m_stateLoggingResultArgs.m_loggingUniqueId;
2516+
}
2517+
return -1;
2518+
}
2519+
2520+
int b3StateLoggingAddLoggingObjectUniqueId(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId)
2521+
{
2522+
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
2523+
b3Assert(command);
2524+
b3Assert(command->m_type == CMD_STATE_LOGGING);
2525+
if (command->m_type == CMD_STATE_LOGGING)
2526+
{
2527+
command->m_updateFlags |= STATE_LOGGING_FILTER_OBJECT_UNIQUE_ID;
2528+
if (command->m_stateLoggingArguments.m_numBodyUniqueIds < MAX_SDF_BODIES)
2529+
{
2530+
command->m_stateLoggingArguments.m_bodyUniqueIds[command->m_stateLoggingArguments.m_numBodyUniqueIds++] = objectUniqueId;
2531+
}
2532+
}
2533+
return 0;
2534+
}
2535+
int b3StateLoggingStop(b3SharedMemoryCommandHandle commandHandle, int loggingUid)
2536+
{
2537+
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
2538+
b3Assert(command);
2539+
b3Assert(command->m_type == CMD_STATE_LOGGING);
2540+
if (command->m_type == CMD_STATE_LOGGING)
2541+
{
2542+
command->m_updateFlags |= STATE_LOGGING_STOP_LOG;
2543+
command->m_stateLoggingArguments.m_loggingUniqueId = loggingUid;
2544+
}
2545+
return 0;
2546+
}
2547+

‎examples/SharedMemory/PhysicsClientC_API.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,11 @@ int b3SetVRCameraRootPosition(b3SharedMemoryCommandHandle commandHandle, double
343343
int b3SetVRCameraRootOrientation(b3SharedMemoryCommandHandle commandHandle, double rootOrn[4]);
344344
int b3SetVRCameraTrackingObject(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId);
345345

346-
347-
346+
b3SharedMemoryCommandHandle b3StateLoggingCommandInit(b3PhysicsClientHandle physClient);
347+
int b3StateLoggingStart(b3SharedMemoryCommandHandle commandHandle, int loggingType, const char* fileName);
348+
int b3StateLoggingAddLoggingObjectUniqueId(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId);
349+
int b3GetStatusLoggingUniqueId(b3SharedMemoryStatusHandle statusHandle);
350+
int b3StateLoggingStop(b3SharedMemoryCommandHandle commandHandle, int loggingUniqueId);
348351

349352
#ifdef __cplusplus
350353
}

‎examples/SharedMemory/PhysicsClientSharedMemory.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,20 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus() {
899899
{
900900
break;
901901
}
902+
case CMD_STATE_LOGGING_START_COMPLETED:
903+
{
904+
break;
905+
};
906+
case CMD_STATE_LOGGING_COMPLETED:
907+
{
908+
break;
909+
};
910+
911+
case CMD_STATE_LOGGING_FAILED:
912+
{
913+
b3Warning("State Logging failed");
914+
break;
915+
}
902916
default: {
903917
b3Error("Unknown server status %d\n", serverCmd.m_type);
904918
btAssert(0);

0 commit comments

Comments
 (0)
Please sign in to comment.