示例#1
0
This module models the oscillator and operators of the CPG.

"""


from __future__ import division
from math import cos, sin, pi
# from flut import loadFlut
import numpy as np
import flut as fl
# from scipy.integrate import odeint
from projectSettings import __DEBUG__, __OP_FLUT__, __OP_CPG__, __FLUT__, __OP_BETA__
from globalSettingsNew import projDir

if __OP_FLUT__ == False and __FLUT__ == True:
    influt = fl.loadFlut()


def oscillatorAllDOF(qList, dqList, flut=False, comVel=[0, 0, 0], timestep=1/24):
    """Integrate the oscillator in all DOFs
    
    the function to call the oscillator and operators
    dt is the time interval for integration, normally 1/24 second     
    """
    qList_o = []
    dqList_o = []
    indDOF = 0
    y_Unit = oscillatorUnit(y0, timestep=timestep)
    q_Unit = y_Unit[0]
    dq_Unit = y_Unit[1]
    opList = readOperators(flut, comVel)
示例#2
0
"""This is for the test of the FLUT module

"""

import unittest
import flut
import numpy
import random


lflut = flut.loadFlut(True)
rflut = flut.loadFlut(False)

class TestFlut(unittest.TestCase):
    def setUp(self):
        # self.left = True
        self.indArray = [int(2000*random.random()) for i in xrange(10)]
        self.targetPosArray = [x[0:3] for x in lflut[self.indArray]]
        self.paramArray = [x[3:9] for x in lflut[self.indArray]]


    def tearDown(self):
        pass

    def test_lookupFlut(self):        
        resArray = []
        for targetPos, targetParams in zip(self.targetPosArray, self.paramArray):
            params = flut.lookupFlut(lflut, targetPos)                        
            res = numpy.array_equal(params, targetParams)
            resArray.append(res)
        self.assertTrue(all(resArray))