Skip to content

Commit cfd3584

Browse files
committed
initial implementation of state logging.
see examples/pybullet/logMinitaur.py for example. Other state logging will include general robot states and VR controllers state.
1 parent 2b27ab2 commit cfd3584

9 files changed

+402
-116
lines changed

examples/SharedMemory/PhysicsClientC_API.cpp

+49-10
Original file line numberDiff line numberDiff line change
@@ -2467,41 +2467,80 @@ int b3SetVRCameraTrackingObject(b3SharedMemoryCommandHandle commandHandle, int o
24672467
return 0;
24682468
}
24692469

2470-
b3SharedMemoryCommandHandle b3RobotLoggingCommandInit(b3PhysicsClientHandle physClient)
2470+
b3SharedMemoryCommandHandle b3StateLoggingCommandInit(b3PhysicsClientHandle physClient)
24712471
{
24722472
PhysicsClient* cl = (PhysicsClient*)physClient;
24732473
b3Assert(cl);
24742474
b3Assert(cl->canSubmitCommand());
24752475
struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand();
24762476
b3Assert(command);
24772477

2478-
command->m_type = CMD_ROBOT_LOGGING;
2478+
command->m_type = CMD_STATE_LOGGING;
24792479
command->m_updateFlags = 0;
2480+
command->m_stateLoggingArguments.m_numBodyUniqueIds = 0;
24802481

24812482
return (b3SharedMemoryCommandHandle)command;
24822483

24832484
}
24842485

2485-
int b3RobotLoggingStartMinitaurLog(b3SharedMemoryCommandHandle commandHandle, const char* fileName, int objectUniqueId)
2486+
int b3StateLoggingStart(b3SharedMemoryCommandHandle commandHandle, int loggingType, const char* fileName)
24862487
{
24872488
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
24882489
b3Assert(command);
2489-
b3Assert(command->m_type == CMD_ROBOT_LOGGING);
2490-
if (command->m_type == CMD_ROBOT_LOGGING)
2490+
b3Assert(command->m_type == CMD_STATE_LOGGING);
2491+
if (command->m_type == CMD_STATE_LOGGING)
24912492
{
2492-
command->m_updateFlags |= ROBOT_LOGGING_START_MINITAUR_LOG;
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;
24932504
}
24942505
return 0;
24952506
}
24962507

2497-
int b3RobotLoggingStopMinitaurLog(b3SharedMemoryCommandHandle commandHandle)
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)
24982536
{
24992537
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
25002538
b3Assert(command);
2501-
b3Assert(command->m_type == CMD_ROBOT_LOGGING);
2502-
if (command->m_type == CMD_ROBOT_LOGGING)
2539+
b3Assert(command->m_type == CMD_STATE_LOGGING);
2540+
if (command->m_type == CMD_STATE_LOGGING)
25032541
{
2504-
command->m_updateFlags |= ROBOT_LOGGING_STOP_MINITAUR_LOG;
2542+
command->m_updateFlags |= STATE_LOGGING_STOP_LOG;
2543+
command->m_stateLoggingArguments.m_loggingUniqueId = loggingUid;
25052544
}
25062545
return 0;
25072546
}

examples/SharedMemory/PhysicsClientC_API.h

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

346-
b3SharedMemoryCommandHandle b3RobotLoggingCommandInit(b3PhysicsClientHandle physClient);
347-
int b3RobotLoggingStart(b3SharedMemoryCommandHandle commandHandle, int loggingType, const char* fileName);
348-
int b3RobotLoggingAddLoggingObjectUniqueId(b3SharedMemoryCommandHandle commandHandle, int loggingType, const char* fileName);
349-
int b3RobotLoggingStop(b3SharedMemoryCommandHandle commandHandle);
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);
350351

351352
#ifdef __cplusplus
352353
}

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)