hi,
thanks gays for your help and patience.but i sill have a problem
even when i follow Stefan recommendations.in fact some of my cython
classes inherits from other pure python classes(no multiple
inheritance) and i wonder if it causes problem when using methods from
it(i was thinking about rewriting *.pxd header for parent classes and
cimport methods from it or something like...).back to property
problem...here is my code:


from numpy import array, zeros, eye, dot, sin, cos          #no more need of 
sin, cos
from abc import ABCMeta, abstractmethod
import homogeneousmatrix
from misc import NamedObject
from arboris import Joint

#mes modifs....
cimport numpy as np
DTYPE = np.float 
ctypedef np.float_t DTYPE_t
cdef extern from "math.h":
    float cosf(float theta)
    float sinf(float theta)


#must see Joint class to enhance this one...
class LinearConfigurationSpaceJoint(Joint):
    """
    joints whose space is diffeomorph to the real set.
    """

    def integrate(self, dt):
        self.gpos += dt * self.gvel



cdef class FreeJoint(Joint):

    """Free joint (6-dof)
    """
    def __init__(self, gpos=None, gvel=None, name=None):
        """
        example:
        >>> j = FreeJoint()
        >>> j.gpos
        array([[ 1.,  0.,  0.,  0.],
               [ 0.,  1.,  0.,  0.],
               [ 0.,  0.,  1.,  0.],
               [ 0.,  0.,  0.,  1.]])
        >>> j.gvel
        array([ 0.,  0.,  0.,  0.,  0.,  0.])
        """
        if gpos is None:
            gpos = eye(4)
        if gvel is None:
            gvel = zeros((6))
        self.gpos = array(gpos).reshape((4,4))
        self.gvel = array(gvel).reshape((6))
        Joint.__init__(self, name)

    property ndof:
        def __get__(self):   # This is called when the property is read.
            return 6
    
    property pose:
        def __get__(self):
            return self.gpos.copy()

    property twist:
        def __get__(self):
            return self.gvel.copy()

    property jacobian:
        def __get__(self):
            return eye(6)

    property djacobian:
        def __get__(self):
            return zeros((6,6))

    def integrate(self, dt):         #must see twistvector, exp dot to enhance 
this methode
        from twistvector import exp  #twistvector must be declared 'cdef exter 
class tewistsvector'
        self.gpos = dot(self.gpos, exp( dt*self.gvel))

#class PivotJoint(Joint):
#
#    """Pivot (2-dof)
#    """
#
#class BallJoint(Joint):
#
#    """Ball and socket (3-dof)
#    """



cdef class RzRyRxJoint(LinearConfigurationSpaceJoint):
    """Ball and socket (3-dof) implemented with 3 serial hinges

    the resulting homogeneous matrix is given by H = Rz*Ry*Rx
    """
    def __init__(self, gpos=[0.,0.,0.], gvel=[0.,0.,0.], name=None):
        self.gpos = array(gpos).reshape((3))
        self.gvel = array(gvel).reshape((3))
        Joint.__init__(self, name)

    property ndof:  #mes modifs.......
        def __get__(self):
            return 3

    property pose:
        def __get__(self):
            return homogeneousmatrix.rotzyx(self.gpos)
    
    cdef _getjacobian(self):
    
        """
        T_n/r = 
        """   
        cdef float sx = sinf(self.gpos[0])
        cdef float cx = cosf(self.gpos[0])
        cdef float sy = sinf(self.gpos[1])
        cdef float cy = cosf(self.gpos[1])
        cdef np.ndarray[DTYPE_t, ndim=2] value = np.array (
            ([ 1.   ,  0. , -sy    ],
             [ 0.   , cx  ,  sx*sy ],
             [ 0.   ,-sx  ,  cx*cy ],
             [ 0.   ,  0. ,  0.    ],
             [ 0.   ,  0. ,  0.    ],
             [ 0.   ,  0. ,  0.    ]),   dtype=DTYPE)
        return value
    #we used this method to preserve the use of proprety:(
    #eventally look further if we could write cpdef jacobian.... and at the 
same time preserve proprety
    #pay attention about names...
    property jacobian:
        def __get__(self):
            return self._getjacobian()         
    #sam thing for djacobian
    cdef _getdjacobian(self):
        cdef float sx = sinf(self.gpos[0])
        cdef float cx = cosf(self.gpos[0])
        cdef float sy = sinf(self.gpos[1])
        cdef float cy = cosf(self.gpos[1])
        cdef float dx = self.gvel[0]
        cdef float dy = self.gvel[1]
        cdef np.ndarray[DTYPE_t, ndim=2] value = np.array (
            ([ 0.   , 0.    ,-dy*cy             ],
             [ 0.   ,-dx*sx , dx*cx*sy+dy*sx*cy ],
             [ 0.   ,-dx*cx ,-dx*sx*cy-dy*cx*sy ],
             [ 0.   ,  0. ,  0.    ],
             [ 0.   ,  0. ,  0.    ],
             [ 0.   ,  0. ,  0.    ]), dtype=DTYPE)
        return value

    property djacobian:
        def __get__(self):
            return self._getdjacobian()         

and here is the compilation error messages:

tenni...@tenninos-laptop:~/stage/arboris-python/src$ python setup.py build_ext 
--inplace
running build_ext
cythoning joints_c.pyx to joints_c.c

Error converting Pyrex file to C:
------------------------------------------------------------
...
    def integrate(self, dt):
        self.gpos += dt * self.gvel



cdef class FreeJoint(Joint):
    ^
------------------------------------------------------------

/home/tenninos/stage/arboris-python/src/joints_c.pyx:31:5: 'Joint' is not a 
type name

Error converting Pyrex file to C:
------------------------------------------------------------
...
#    """Ball and socket (3-dof)
#    """



cdef class RzRyRxJoint(LinearConfigurationSpaceJoint):
    ^
------------------------------------------------------------

/home/tenninos/stage/arboris-python/src/joints_c.pyx:91:5: 
'LinearConfigurationSpaceJoint' is not a type name

Error converting Pyrex file to C:
------------------------------------------------------------
...

    property djacobian:
        def __get__(self):
            return self._getdjacobian()         

cdef class RzRyJoint(LinearConfigurationSpaceJoint):
    ^
------------------------------------------------------------

/home/tenninos/stage/arboris-python/src/joints_c.pyx:153:5: 
'LinearConfigurationSpaceJoint' is not a type name

Error converting Pyrex file to C:
------------------------------------------------------------
...
        return value
    property djacobian:
        def __get__(self):
            return self._getdjacobian()

cdef class RzRxJoint(LinearConfigurationSpaceJoint):
    ^
------------------------------------------------------------


_________________________________________________________________
Téléphonez gratuitement à tous vos proches avec Windows Live Messenger  !  
Téléchargez-le maintenant ! 
http://www.windowslive.fr/messenger/1.asp
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to