Add an option for a plugin to report return data after calling executePluginCommand. Also add python binding.

Currently the return data has to fit in shared memory, 8MB (Linux, Windows) or 1MB (Apple)
Preparation for streaming is added (to allow unlimited return data, see CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA)

New C-API: b3GetStatusPluginCommandReturnData
PyBullet reports return data if available, in pybullet_executePluginCommand

For the plugin developer:
plugin can provide additional return data for executePluginCommand in the b3PluginContext, during executePluginCommand.
Lifetime of this m_returnData pointer is minimum of next call to the next executePluginCommand or plugin termination.
This commit is contained in:
Erwin Coumans
2020-10-06 20:19:39 -07:00
parent 7a6c90409f
commit 954ceff2ec
14 changed files with 182 additions and 9 deletions

View File

@@ -69,6 +69,9 @@ struct PhysicsClientSharedMemoryInternalData
btHashMap<btHashInt, SharedMemoryUserData> m_userDataMap;
btHashMap<SharedMemoryUserDataHashKey, int> m_userDataHandleLookup;
btAlignedObjectArray<char> m_cachedReturnData;
b3UserDataValue m_cachedReturnDataValue;
SharedMemoryStatus m_tempBackupServerStatus;
SharedMemoryStatus m_lastServerStatus;
@@ -1350,8 +1353,21 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus()
b3Warning("Request getCollisionInfo failed");
break;
}
case CMD_CUSTOM_COMMAND_COMPLETED:
{
m_data->m_cachedReturnData.resize(serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes);
m_data->m_cachedReturnDataValue.m_length = serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes;
if (serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes)
{
m_data->m_cachedReturnDataValue.m_type = serverCmd.m_customCommandResultArgs.m_returnDataType;
m_data->m_cachedReturnDataValue.m_data1 = &m_data->m_cachedReturnData[0];
for (int i = 0; i < serverCmd.m_numDataStreamBytes; i++)
{
m_data->m_cachedReturnData[i] = m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor[i];
}
}
break;
}
case CMD_CALCULATED_JACOBIAN_COMPLETED:
@@ -2006,6 +2022,16 @@ void PhysicsClientSharedMemory::getCachedMassMatrix(int dofCountCheck, double* m
}
}
bool PhysicsClientSharedMemory::getCachedReturnData(b3UserDataValue* returnData)
{
if (m_data->m_cachedReturnDataValue.m_length)
{
*returnData = m_data->m_cachedReturnDataValue;
return true;
}
return false;
}
void PhysicsClientSharedMemory::getCachedVisualShapeInformation(struct b3VisualShapeInformation* visualShapesInfo)
{
visualShapesInfo->m_numVisualShapes = m_data->m_cachedVisualShapes.size();