From: brett h. <bha...@ya...> - 2004-03-24 19:40:49
|
Hi Tim, Are you using ode-0.039, if so that is likely the cause of your build problem. I've been making the wrappers around cvs from about 3 days ago. http://sourceforge.net/cvs/?group_id=24884 The thin wrappers are just temporary, for building and testing. To return python lists or tuples would be nice. How do we do that? I looked at some of your code in the CVS and it seemed you were doing something like this already. I aggree, the ode c++ wrappers are a pain in the ass; although they are good becuase they are a standard part of osg. Is there a way we can easily swap them out for your classes? How should we go about merging our code? Maybe we can work with the ODE crew and make their c++ wrappers better? Python's C interface looks too verbose for me. Boost has made me lazy i think. It could be something to fall back on later. I think we are close to having something working well with boost, lets not give up on it now. later, -brett --- Timothy Stranex <ti...@st...> wrote: > Hey, > > On Wed, 2004-03-24 at 06:21, brett hartshorn wrote: > > get the new PyODE 0.1.4 here: > > http://opart.org/pyode/ > > I get these errors when building: > > $ scons > scons: Reading SConscript files ... > WARNING: ODE_ROOT env var not set! > Defaulting to: /usr/local > scons: done reading SConscript files. > scons: Building targets ... > g++ -Wall -ansi -fPIC -DNDEBUG -DBOOST_PYTHON_DYNAMIC_LIB > -I/usr/include/python2.2 -I/usr/local/include -Iinclude -c -o > PyODE/odecpp.os PyODE/odecpp.cpp > PyODE/odecpp.cpp: In function `void pyODE::init_odecpp()': > PyODE/odecpp.cpp:247: error: `setParam' is not a member of type ` > dUniversalJoint' > PyODE/odecpp.cpp:254: error: `getParam' is not a member of type ` > dUniversalJoint' > scons: *** [PyODE/odecpp.os] Error 1 > scons: building terminated because of errors. > > > Tomorrow i will likey have completed doing all of the 'thin wrappers' for the get functions > > returning a dReal. > > Your 'thin wrappers' are just dereferencing dReal pointers but some > methods like dBody's getPosition are returning an arrays of dReal, as > far as I can tell. I'm guessing that these are just temporary to get it > to build? > > > Should we make our own vector and matrix classes and stick those into the thin wrappers, > > or should we subclass all the classes from the ode c++ wrappers and overload them. Or > > should we just scrap the ode c++ wrappers and make our own? > > I think that whether we use the ODE C++ wrapper or write our own, we > should write thin wrappers to convert vectors and matrices in simple > Python lists. This will allow the user to choose whether they want to > manipulate them using Numeric or their own vector and matrix classes. > > I /feel/ that using the ODE's C++ interface is causing too much trouble > and it would be easier to use its C API and wrap it so that it seems > object-orientated to Python. > > > and boost is very picky about things. > > I played around with Python's C interface today. It is actually quite > straightforward albeit verbose. It doesn't compare with Boost's elegance > in the code but it has other advantages: the building system is simple > and well-known by most Python users and dependency requirements (and the > hassles that come with them) are reduced. > > I'm unsure whether these advantages outweigh those of Boost, but I think > we should consider it. I've attached a simple module using the C > interface. You can build it by running 'python setup.py build'. > > -- > Timothy Stranex <ti...@st...> > http://www.stranex.com/~perspex/ > > #include <Python.h> > > int isPrime(int num) > { > int n, prime; > > prime = 1; > for (n=2; n < num; n++) { > if (num % n == 0) { > prime = 0; > break; > } > } > > return prime; > } > > static PyObject *nums_isPrime(PyObject *self, PyObject *args) > { > int num; > > if (!PyArg_ParseTuple(args, "i", &num)) { > return NULL; > } > > return Py_BuildValue("i", isPrime(num)); > } > > static PyObject *nums_factors(PyObject *self, PyObject *args) > { > int num, i; > PyObject *list; > > if (!PyArg_ParseTuple(args, "i", &num)) { > return NULL; > } > > list = PyList_New(0); > if (!list) { > return NULL; > } > > for (i=1; i<=num; i++) { > if (num % i == 0) { > PyList_Append(list, Py_BuildValue("i", i)); > } > } > > return list; > } > > static PyObject *nums_pfactors(PyObject *self, PyObject *args) > { > int num, i; > PyObject *f; > PyObject *pf; > PyObject *n; > > f = nums_factors(self, args); > if (!f) { > return NULL; > } > > pf = PyList_New(0); > for (i=0; i<PyList_Size(f); i++) { > n = PyList_GetItem(f, i); > if (isPrime((int) PyInt_AsLong(n))) { > PyList_Append(pf, n); > } > } > > Py_DECREF(f); > > return pf; > } > > void initnums(void) > { > static PyMethodDef NumsMethods[] = { > {"isPrime", nums_isPrime, METH_VARARGS, "Check if an integer is prime."}, > {"factors", nums_factors, METH_VARARGS, "Find the factors or an integer."}, > {"pfactors", nums_pfactors, METH_VARARGS, > "Find the prime factors of an integer."}, > {NULL, NULL, 0, NULL} > }; > > (void) Py_InitModule("nums", NumsMethods); > } > > #!/usr/bin/env python > > from distutils.core import setup, Extension > > numsModule = Extension('nums', sources=['numsmodule.c']) > > setup(name='Nums', > version='0.1', > description='Numbers', > ext_modules=[numsModule]) > > ATTACHMENT part 2 application/pgp-signature name=signature.asc __________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html |