mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
apply the deviceTypeFilter also to VR state logging.
This commit is contained in:
parent
2e47310e76
commit
82b6bc8770
@ -2648,6 +2648,7 @@ b3SharedMemoryCommandHandle b3StateLoggingCommandInit(b3PhysicsClientHandle phys
|
|||||||
command->m_type = CMD_STATE_LOGGING;
|
command->m_type = CMD_STATE_LOGGING;
|
||||||
command->m_updateFlags = 0;
|
command->m_updateFlags = 0;
|
||||||
command->m_stateLoggingArguments.m_numBodyUniqueIds = 0;
|
command->m_stateLoggingArguments.m_numBodyUniqueIds = 0;
|
||||||
|
command->m_stateLoggingArguments.m_deviceFilterType = VR_DEVICE_CONTROLLER;
|
||||||
|
|
||||||
return (b3SharedMemoryCommandHandle)command;
|
return (b3SharedMemoryCommandHandle)command;
|
||||||
|
|
||||||
@ -2768,6 +2769,20 @@ int b3StateLoggingSetMaxLogDof(b3SharedMemoryCommandHandle commandHandle, int ma
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int b3StateLoggingSetDeviceTypeFilter(b3SharedMemoryCommandHandle commandHandle, int deviceTypeFilter)
|
||||||
|
{
|
||||||
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
|
b3Assert(command);
|
||||||
|
b3Assert(command->m_type == CMD_STATE_LOGGING);
|
||||||
|
if (command->m_type == CMD_STATE_LOGGING)
|
||||||
|
{
|
||||||
|
command->m_updateFlags |= STATE_LOGGING_FILTER_DEVICE_TYPE;
|
||||||
|
command->m_stateLoggingArguments.m_deviceFilterType = deviceTypeFilter;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int b3StateLoggingStop(b3SharedMemoryCommandHandle commandHandle, int loggingUid)
|
int b3StateLoggingStop(b3SharedMemoryCommandHandle commandHandle, int loggingUid)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
|
@ -372,6 +372,7 @@ int b3StateLoggingSetLinkIndexA(b3SharedMemoryCommandHandle commandHandle, int l
|
|||||||
int b3StateLoggingSetLinkIndexB(b3SharedMemoryCommandHandle commandHandle, int linkIndexB);
|
int b3StateLoggingSetLinkIndexB(b3SharedMemoryCommandHandle commandHandle, int linkIndexB);
|
||||||
int b3StateLoggingSetBodyAUniqueId(b3SharedMemoryCommandHandle commandHandle, int bodyAUniqueId);
|
int b3StateLoggingSetBodyAUniqueId(b3SharedMemoryCommandHandle commandHandle, int bodyAUniqueId);
|
||||||
int b3StateLoggingSetBodyBUniqueId(b3SharedMemoryCommandHandle commandHandle, int bodyBUniqueId);
|
int b3StateLoggingSetBodyBUniqueId(b3SharedMemoryCommandHandle commandHandle, int bodyBUniqueId);
|
||||||
|
int b3StateLoggingSetDeviceTypeFilter(b3SharedMemoryCommandHandle commandHandle, int deviceTypeFilter);
|
||||||
|
|
||||||
int b3GetStatusLoggingUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
int b3GetStatusLoggingUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
||||||
int b3StateLoggingStop(b3SharedMemoryCommandHandle commandHandle, int loggingUniqueId);
|
int b3StateLoggingStop(b3SharedMemoryCommandHandle commandHandle, int loggingUniqueId);
|
||||||
|
@ -661,13 +661,14 @@ struct VRControllerStateLogger : public InternalStateLogger
|
|||||||
{
|
{
|
||||||
b3VRControllerEvents m_vrEvents;
|
b3VRControllerEvents m_vrEvents;
|
||||||
int m_loggingTimeStamp;
|
int m_loggingTimeStamp;
|
||||||
|
int m_deviceTypeFilter;
|
||||||
std::string m_fileName;
|
std::string m_fileName;
|
||||||
FILE* m_logFileHandle;
|
FILE* m_logFileHandle;
|
||||||
std::string m_structTypes;
|
std::string m_structTypes;
|
||||||
|
|
||||||
VRControllerStateLogger(int loggingUniqueId, const std::string& fileName)
|
VRControllerStateLogger(int loggingUniqueId, int deviceTypeFilter, const std::string& fileName)
|
||||||
:m_loggingTimeStamp(0),
|
:m_loggingTimeStamp(0),
|
||||||
|
m_deviceTypeFilter(deviceTypeFilter),
|
||||||
m_fileName(fileName),
|
m_fileName(fileName),
|
||||||
m_logFileHandle(0)
|
m_logFileHandle(0)
|
||||||
{
|
{
|
||||||
@ -716,66 +717,68 @@ struct VRControllerStateLogger : public InternalStateLogger
|
|||||||
|
|
||||||
int stepCount = m_loggingTimeStamp;
|
int stepCount = m_loggingTimeStamp;
|
||||||
float timeStamp = m_loggingTimeStamp*timeStep;
|
float timeStamp = m_loggingTimeStamp*timeStep;
|
||||||
|
|
||||||
for (int i=0;i<MAX_VR_CONTROLLERS;i++)
|
for (int i=0;i<MAX_VR_CONTROLLERS;i++)
|
||||||
{
|
{
|
||||||
b3VRControllerEvent& event = m_vrEvents.m_vrEvents[i];
|
b3VRControllerEvent& event = m_vrEvents.m_vrEvents[i];
|
||||||
|
if (m_deviceTypeFilter & event.m_deviceType)
|
||||||
if (event.m_numButtonEvents + event.m_numMoveEvents)
|
|
||||||
{
|
{
|
||||||
MinitaurLogRecord logData;
|
if (event.m_numButtonEvents + event.m_numMoveEvents)
|
||||||
|
|
||||||
//serverStatusOut.m_sendVREvents.m_controllerEvents[serverStatusOut.m_sendVREvents.m_numVRControllerEvents++] = event;
|
|
||||||
//log the event
|
|
||||||
logData.m_values.push_back(stepCount);
|
|
||||||
logData.m_values.push_back(timeStamp);
|
|
||||||
logData.m_values.push_back(event.m_controllerId);
|
|
||||||
logData.m_values.push_back(event.m_numMoveEvents);
|
|
||||||
logData.m_values.push_back(event.m_numButtonEvents);
|
|
||||||
logData.m_values.push_back(event.m_pos[0]);
|
|
||||||
logData.m_values.push_back(event.m_pos[1]);
|
|
||||||
logData.m_values.push_back(event.m_pos[2]);
|
|
||||||
logData.m_values.push_back(event.m_orn[0]);
|
|
||||||
logData.m_values.push_back(event.m_orn[1]);
|
|
||||||
logData.m_values.push_back(event.m_orn[2]);
|
|
||||||
logData.m_values.push_back(event.m_orn[3]);
|
|
||||||
logData.m_values.push_back(event.m_analogAxis);
|
|
||||||
int packedButtons[7]={0,0,0,0,0,0,0};
|
|
||||||
|
|
||||||
int packedButtonIndex = 0;
|
|
||||||
int packedButtonShift = 0;
|
|
||||||
//encode the 64 buttons into 7 int (3 bits each), each int stores 10 buttons
|
|
||||||
for (int b=0;b<MAX_VR_BUTTONS;b++)
|
|
||||||
{
|
{
|
||||||
int buttonMask = event.m_buttons[b];
|
MinitaurLogRecord logData;
|
||||||
buttonMask = buttonMask << (packedButtonShift*3);
|
|
||||||
packedButtons[packedButtonIndex] |= buttonMask;
|
|
||||||
packedButtonShift++;
|
|
||||||
|
|
||||||
if (packedButtonShift>=10)
|
//serverStatusOut.m_sendVREvents.m_controllerEvents[serverStatusOut.m_sendVREvents.m_numVRControllerEvents++] = event;
|
||||||
|
//log the event
|
||||||
|
logData.m_values.push_back(stepCount);
|
||||||
|
logData.m_values.push_back(timeStamp);
|
||||||
|
logData.m_values.push_back(event.m_controllerId);
|
||||||
|
logData.m_values.push_back(event.m_numMoveEvents);
|
||||||
|
logData.m_values.push_back(event.m_numButtonEvents);
|
||||||
|
logData.m_values.push_back(event.m_pos[0]);
|
||||||
|
logData.m_values.push_back(event.m_pos[1]);
|
||||||
|
logData.m_values.push_back(event.m_pos[2]);
|
||||||
|
logData.m_values.push_back(event.m_orn[0]);
|
||||||
|
logData.m_values.push_back(event.m_orn[1]);
|
||||||
|
logData.m_values.push_back(event.m_orn[2]);
|
||||||
|
logData.m_values.push_back(event.m_orn[3]);
|
||||||
|
logData.m_values.push_back(event.m_analogAxis);
|
||||||
|
int packedButtons[7]={0,0,0,0,0,0,0};
|
||||||
|
|
||||||
|
int packedButtonIndex = 0;
|
||||||
|
int packedButtonShift = 0;
|
||||||
|
//encode the 64 buttons into 7 int (3 bits each), each int stores 10 buttons
|
||||||
|
for (int b=0;b<MAX_VR_BUTTONS;b++)
|
||||||
{
|
{
|
||||||
packedButtonShift=0;
|
int buttonMask = event.m_buttons[b];
|
||||||
packedButtonIndex++;
|
buttonMask = buttonMask << (packedButtonShift*3);
|
||||||
if (packedButtonIndex>=7)
|
packedButtons[packedButtonIndex] |= buttonMask;
|
||||||
|
packedButtonShift++;
|
||||||
|
|
||||||
|
if (packedButtonShift>=10)
|
||||||
{
|
{
|
||||||
btAssert(0);
|
packedButtonShift=0;
|
||||||
break;
|
packedButtonIndex++;
|
||||||
|
if (packedButtonIndex>=7)
|
||||||
|
{
|
||||||
|
btAssert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (int b=0;b<7;b++)
|
for (int b=0;b<7;b++)
|
||||||
{
|
{
|
||||||
logData.m_values.push_back(packedButtons[b]);
|
logData.m_values.push_back(packedButtons[b]);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendMinitaurLogData(m_logFileHandle, m_structTypes, logData);
|
appendMinitaurLogData(m_logFileHandle, m_structTypes, logData);
|
||||||
|
|
||||||
event.m_numButtonEvents = 0;
|
event.m_numButtonEvents = 0;
|
||||||
event.m_numMoveEvents = 0;
|
event.m_numMoveEvents = 0;
|
||||||
for (int b=0;b<MAX_VR_BUTTONS;b++)
|
for (int b=0;b<MAX_VR_BUTTONS;b++)
|
||||||
{
|
{
|
||||||
event.m_buttons[b] = 0;
|
event.m_buttons[b] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2314,7 +2317,12 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
{
|
{
|
||||||
std::string fileName = clientCmd.m_stateLoggingArguments.m_fileName;
|
std::string fileName = clientCmd.m_stateLoggingArguments.m_fileName;
|
||||||
int loggerUid = m_data->m_stateLoggersUniqueId++;
|
int loggerUid = m_data->m_stateLoggersUniqueId++;
|
||||||
VRControllerStateLogger* logger = new VRControllerStateLogger(loggerUid,fileName);
|
int deviceFilterType = VR_DEVICE_CONTROLLER;
|
||||||
|
if (clientCmd.m_updateFlags & STATE_LOGGING_FILTER_DEVICE_TYPE)
|
||||||
|
{
|
||||||
|
deviceFilterType = clientCmd.m_stateLoggingArguments.m_deviceFilterType;
|
||||||
|
}
|
||||||
|
VRControllerStateLogger* logger = new VRControllerStateLogger(loggerUid,deviceFilterType, fileName);
|
||||||
m_data->m_stateLoggers.push_back(logger);
|
m_data->m_stateLoggers.push_back(logger);
|
||||||
serverStatusOut.m_type = CMD_STATE_LOGGING_START_COMPLETED;
|
serverStatusOut.m_type = CMD_STATE_LOGGING_START_COMPLETED;
|
||||||
serverStatusOut.m_stateLoggingResultArgs.m_loggingUniqueId = loggerUid;
|
serverStatusOut.m_stateLoggingResultArgs.m_loggingUniqueId = loggerUid;
|
||||||
|
@ -618,6 +618,7 @@ struct SendKeyboardEvents
|
|||||||
b3KeyboardEvent m_keyboardEvents[MAX_KEYBOARD_EVENTS];
|
b3KeyboardEvent m_keyboardEvents[MAX_KEYBOARD_EVENTS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum eVRCameraEnums
|
enum eVRCameraEnums
|
||||||
{
|
{
|
||||||
VR_CAMERA_ROOT_POSITION=1,
|
VR_CAMERA_ROOT_POSITION=1,
|
||||||
@ -635,6 +636,7 @@ enum eStateLoggingEnums
|
|||||||
STATE_LOGGING_FILTER_LINK_INDEX_B=32,
|
STATE_LOGGING_FILTER_LINK_INDEX_B=32,
|
||||||
STATE_LOGGING_FILTER_BODY_UNIQUE_ID_A=64,
|
STATE_LOGGING_FILTER_BODY_UNIQUE_ID_A=64,
|
||||||
STATE_LOGGING_FILTER_BODY_UNIQUE_ID_B=128,
|
STATE_LOGGING_FILTER_BODY_UNIQUE_ID_B=128,
|
||||||
|
STATE_LOGGING_FILTER_DEVICE_TYPE=256
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VRCameraState
|
struct VRCameraState
|
||||||
@ -658,6 +660,7 @@ struct StateLoggingRequest
|
|||||||
int m_linkIndexB; // only if STATE_LOGGING_FILTER_LINK_INDEX_B flag is set
|
int m_linkIndexB; // only if STATE_LOGGING_FILTER_LINK_INDEX_B flag is set
|
||||||
int m_bodyUniqueIdA; // only if STATE_LOGGING_FILTER_BODY_UNIQUE_ID_A flag is set
|
int m_bodyUniqueIdA; // only if STATE_LOGGING_FILTER_BODY_UNIQUE_ID_A flag is set
|
||||||
int m_bodyUniqueIdB; // only if STATE_LOGGING_FILTER_BODY_UNIQUE_ID_B flag is set
|
int m_bodyUniqueIdB; // only if STATE_LOGGING_FILTER_BODY_UNIQUE_ID_B flag is set
|
||||||
|
int m_deviceFilterType; //user to select (filter) which VR devices to log
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StateLoggingResultArgs
|
struct StateLoggingResultArgs
|
||||||
|
@ -2683,8 +2683,9 @@ static PyObject* pybullet_startStateLogging(PyObject* self, PyObject* args, PyOb
|
|||||||
int bodyUniqueIdB = -1;
|
int bodyUniqueIdB = -1;
|
||||||
int linkIndexA = -2;
|
int linkIndexA = -2;
|
||||||
int linkIndexB = -2;
|
int linkIndexB = -2;
|
||||||
|
int deviceTypeFilter = -1;
|
||||||
|
|
||||||
static char* kwlist[] = {"loggingType", "fileName", "objectUniqueIds", "maxLogDof", "bodyUniqueIdA", "bodyUniqueIdB", "linkIndexA", "linkIndexB", "physicsClientId", NULL};
|
static char* kwlist[] = {"loggingType", "fileName", "objectUniqueIds", "maxLogDof", "bodyUniqueIdA", "bodyUniqueIdB", "linkIndexA", "linkIndexB", "deviceTypeFilter", "physicsClientId", NULL};
|
||||||
int physicsClientId = 0;
|
int physicsClientId = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "is|Oiiiiii", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, keywds, "is|Oiiiiii", kwlist,
|
||||||
@ -2741,6 +2742,11 @@ static PyObject* pybullet_startStateLogging(PyObject* self, PyObject* args, PyOb
|
|||||||
b3StateLoggingSetLinkIndexB(commandHandle, linkIndexB);
|
b3StateLoggingSetLinkIndexB(commandHandle, linkIndexB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deviceTypeFilter>=0)
|
||||||
|
{
|
||||||
|
b3StateLoggingSetDeviceTypeFilter(commandHandle,deviceTypeFilter);
|
||||||
|
}
|
||||||
|
|
||||||
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle);
|
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle);
|
||||||
statusType = b3GetStatusType(statusHandle);
|
statusType = b3GetStatusType(statusHandle);
|
||||||
if (statusType == CMD_STATE_LOGGING_START_COMPLETED)
|
if (statusType == CMD_STATE_LOGGING_START_COMPLETED)
|
||||||
|
Loading…
Reference in New Issue
Block a user