Allow to configure Y=up, default is Z=up, using pybullet.configureDebugVisualizer(COV_ENABLE_Y_AXIS_UP,0/1)

Implement pybullet.getConnectionInfo, returns [isConnected, connectionMethod], where isConnected=0 or 1
This commit is contained in:
erwincoumans
2017-10-05 09:02:33 -07:00
parent f467f325f7
commit 9303891468
4 changed files with 55 additions and 8 deletions

View File

@@ -503,6 +503,36 @@ void b3pybulletExitFunc(void)
}
static PyObject* pybullet_getConnectionInfo(PyObject* self, PyObject* args, PyObject* keywds)
{
int physicsClientId = 0;
int isConnected=0;
int method=0;
PyObject* pylist = 0;
b3PhysicsClientHandle sm = 0;
static char* kwlist[] = {"physicsClientId", NULL};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|i", kwlist, &physicsClientId))
{
return NULL;
}
sm = getPhysicsClient(physicsClientId);
if (sm != 0)
{
if (b3CanSubmitCommand(sm))
{
isConnected = 1;
method = sPhysicsClientsGUI[physicsClientId];
}
}
pylist = PyTuple_New(2);
PyTuple_SetItem(pylist, 0, PyInt_FromLong(isConnected));
PyTuple_SetItem(pylist, 1, PyInt_FromLong(method));
return pylist;
}
static PyObject* pybullet_saveWorld(PyObject* self, PyObject* args, PyObject* keywds)
{
const char* worldFileName = "";
@@ -7314,13 +7344,14 @@ static PyObject* pybullet_calculateMassMatrix(PyObject* self, PyObject* args, Py
if (statusType == CMD_CALCULATED_MASS_MATRIX_COMPLETED)
{
int dofCount;
b3GetStatusMassMatrix(statusHandle, &dofCount, NULL);
b3GetStatusMassMatrix(sm, statusHandle, &dofCount, NULL);
if (dofCount)
{
pyResultList = PyTuple_New(dofCount);
int byteSizeDofCount = sizeof(double) * dofCount;
pyResultList = PyTuple_New(dofCount);
massMatrix = (double*)malloc(dofCount * byteSizeDofCount);
b3GetStatusMassMatrix(statusHandle, NULL, massMatrix);
b3GetStatusMassMatrix(sm, statusHandle, NULL, massMatrix);
if (massMatrix)
{
int r;
@@ -7372,6 +7403,10 @@ static PyMethodDef SpamMethods[] = {
"disconnect(physicsClientId=0)\n"
"Disconnect from the physics server."},
{"getConnectionInfo", (PyCFunction)pybullet_getConnectionInfo, METH_VARARGS | METH_KEYWORDS,
"getConnectionInfo(physicsClientId=0)\n"
"Return if a given client id is connected, and using what method."},
{"resetSimulation", (PyCFunction)pybullet_resetSimulation, METH_VARARGS | METH_KEYWORDS,
"resetSimulation(physicsClientId=0)\n"
"Reset the simulation: remove all objects and start from an empty world."},