[python] Convert physics calls to double precision.

In order to feed Bullet the correct values when
compiled with double precision the pybullet interface
needs to pass double precision values.
This commit is contained in:
Jeffrey Bingham
2016-09-06 23:27:34 -07:00
parent 4944aca28b
commit edef18e161

View File

@@ -141,13 +141,13 @@ pybullet_loadURDF(PyObject* self, PyObject* args)
int bodyIndex = -1; int bodyIndex = -1;
const char* urdfFileName=""; const char* urdfFileName="";
float startPosX =0; double startPosX = 0.0;
float startPosY =0; double startPosY = 0.0;
float startPosZ = 0; double startPosZ = 0.0;
float startOrnX = 0; double startOrnX = 0.0;
float startOrnY = 0; double startOrnY = 0.0;
float startOrnZ = 0; double startOrnZ = 0.0;
float startOrnW = 1; double startOrnW = 1.0;
if (0==sm) if (0==sm)
{ {
@@ -161,13 +161,13 @@ pybullet_loadURDF(PyObject* self, PyObject* args)
} }
if (size == 4) if (size == 4)
{ {
if (!PyArg_ParseTuple(args, "sfff", &urdfFileName, if (!PyArg_ParseTuple(args, "sddd", &urdfFileName,
&startPosX,&startPosY,&startPosZ)) &startPosX,&startPosY,&startPosZ))
return NULL; return NULL;
} }
if (size==8) if (size==8)
{ {
if (!PyArg_ParseTuple(args, "sfffffff", &urdfFileName, if (!PyArg_ParseTuple(args, "sddddddd", &urdfFileName,
&startPosX,&startPosY,&startPosZ, &startPosX,&startPosY,&startPosZ,
&startOrnX,&startOrnY,&startOrnZ, &startOrnW)) &startOrnX,&startOrnY,&startOrnZ, &startOrnW))
return NULL; return NULL;
@@ -200,9 +200,9 @@ pybullet_loadURDF(PyObject* self, PyObject* args)
return PyLong_FromLong(bodyIndex); return PyLong_FromLong(bodyIndex);
} }
static float pybullet_internalGetFloatFromSequence(PyObject* seq, int index) static double pybullet_internalGetFloatFromSequence(PyObject* seq, int index)
{ {
float v = 0.f; double v = 0.f;
PyObject* item; PyObject* item;
if (PyList_Check(seq)) if (PyList_Check(seq))
@@ -540,15 +540,15 @@ pybullet_setGravity(PyObject* self, PyObject* args)
} }
{ {
float gravX=0; double gravX=0;
float gravY=0; double gravY=0;
float gravZ=-10; double gravZ=-10;
int ret; int ret;
b3SharedMemoryCommandHandle command = b3InitPhysicsParamCommand(sm); b3SharedMemoryCommandHandle command = b3InitPhysicsParamCommand(sm);
b3SharedMemoryStatusHandle statusHandle; b3SharedMemoryStatusHandle statusHandle;
if (!PyArg_ParseTuple(args, "fff", &gravX,&gravY,&gravZ)) if (!PyArg_ParseTuple(args, "ddd", &gravX,&gravY,&gravZ))
{ {
PyErr_SetString(SpamError, "setGravity expected (x,y,z) values."); PyErr_SetString(SpamError, "setGravity expected (x,y,z) values.");
return NULL; return NULL;
@@ -1092,7 +1092,7 @@ static int pybullet_internalSetMatrix(PyObject* objMat, float matrix[16])
// a view and projection matrix in renderImage() // a view and projection matrix in renderImage()
// //
// // Args: // // Args:
// matrix - float[16] which will be set by values from objMat // vector - float[3] which will be set by values from objMat
static int pybullet_internalSetVector(PyObject* objMat, float vector[3]) static int pybullet_internalSetVector(PyObject* objMat, float vector[3])
{ {
int i, len; int i, len;