Esempio n. 1
0
# coding=utf-8
"""Run all the unit tests."""
import unittest
import arboristest

_loader = unittest.defaultTestLoader
suite = unittest.TestSuite()
suite.addTest(_loader.loadTestsFromName('test_doctests.suite'))
suite.addTest(_loader.loadTestsFromName('test_joints'))
suite.addTest(_loader.loadTestsFromName('test_update_dynamic'))
suite.addTest(_loader.loadTestsFromName('test_constraints'))
suite.addTest(_loader.loadTestsFromName('test_visu_collada'))

if __name__ == "__main__":
    arboristest.main(defaultTest='suite')
Esempio n. 2
0
    if False:
        # save result to a file
        g = h5py.File(h5file, 'a')
        if is_fixed:
            name = 'fixed_'
        else:
            name = 'free_'
        if with_weight:
            name += 'with_weight'
        else:
            name += 'without_weight'
        g[name] = nrj.kinetic_energy
        g.close()
    #nrj.plot()
    return nrj


class EnergyDriftTestCase(arboristest.TestCase):
    def test_free_with_weight(self):
        nrj = run_simulation(False, True)
        g = h5py.File(h5file, 'r')
        try:
            self.assertListsAlmostEqual(g['free_with_weight'],
                                        nrj.kinetic_energy)
        finally:
            g.close()


if __name__ == '__main__':
    arboristest.main()
        # add weight
        self.world.register(controllers.WeightController())

        # add a (single) PD Controller to all the simple joints
        ljoints = [x for x in self.world.iterjoints()
                           if isinstance(x, core.LinearConfigurationSpaceJoint)]
        n = len(JointsList(ljoints).dof)
        kp = 0.1*numpy.eye(n)
        c = ProportionalDerivativeController(ljoints, kp=kp, kd=2.*numpy.sqrt(kp))
        # add contacts
        shapes = self.world.getshapes()
        self.contact_frames = []
        for c in constraints.get_all_contacts(self.world, friction_coeff=.6):
            self.world.register(c)
            # find the contact frame attached to the foot (and not the ground)
            if c._frames[0].body.name.startswith('Foot'):
                self.contact_frames.append(c._frames[0])
            else:
                self.contact_frames.append(c._frames[1])
        # run the simulation
        timeline = arange(0., t_end, dt)
        simulate(self.world, timeline, observers)

    def runTest(self):
        # ensure contact points are still above the ground
        for f in self.contact_frames:
            self.assertTrue(f.pose[1,3] >= 0.)

if __name__ == '__main__':
    arboristest.main()