Commit c2aa8321 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Tests][Format] run yapf on unit tests

parent 2fbf84cd
......@@ -8,7 +8,6 @@ from hpp.corbaserver.rbprm.hyq import Robot
class TestRBPRMstate3D(unittest.TestCase):
def test_contacts_3d(self):
subprocess.run(["killall", "hpp-rbprm-server"])
process = subprocess.Popen("hpp-rbprm-server")
......@@ -16,8 +15,7 @@ class TestRBPRMstate3D(unittest.TestCase):
fullbody = Robot()
fullbody.client.robot.setDimensionExtraConfigSpace(6)
fullbody.setJointBounds("root_joint", [-10, 10, -10, 10, -10, 10])
fullbody.client.robot.setExtraConfigSpaceBounds(
[-10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10])
fullbody.client.robot.setExtraConfigSpaceBounds([-10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10])
fullbody.loadAllLimbs("static", nbSamples=10000)
q = fullbody.referenceConfig[::] + [0] * 6
fullbody.setCurrentConfig(q)
......@@ -51,9 +49,9 @@ class TestRBPRMstate3D(unittest.TestCase):
self.assertTrue(state.isLimbInContact(fullbody.rArmId))
self.assertTrue(state.isLimbInContact(fullbody.lArmId))
self.assertTrue(state2.isBalanced())
process.kill()
if __name__ == '__main__':
unittest.main()
......@@ -8,7 +8,6 @@ from talos_rbprm.talos import Robot
class TestRBPRMstate6D(unittest.TestCase):
def test_contacts_6d(self):
subprocess.run(["killall", "hpp-rbprm-server"])
process = subprocess.Popen("hpp-rbprm-server")
......@@ -16,10 +15,9 @@ class TestRBPRMstate6D(unittest.TestCase):
fullbody = Robot()
fullbody.client.robot.setDimensionExtraConfigSpace(6)
fullbody.setJointBounds("root_joint", [-10, 10, -10, 10, -10, 10])
fullbody.client.robot.setExtraConfigSpaceBounds(
[-10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10])
fullbody.client.robot.setExtraConfigSpaceBounds([-10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10])
fullbody.loadAllLimbs("static", nbSamples=10000)
q = fullbody.referenceConfig[::] + [0]*6
q = fullbody.referenceConfig[::] + [0] * 6
fullbody.setCurrentConfig(q)
com = fullbody.getCenterOfMass()
contacts = [fullbody.rLegId, fullbody.lLegId]
......@@ -77,14 +75,14 @@ class TestRBPRMstate6D(unittest.TestCase):
self.assertTrue(state4.isLimbInContact(fullbody.rLegId))
self.assertTrue(state4.isLimbInContact(fullbody.lLegId))
self.assertTrue(state4.isBalanced())
for i in range(7,13):
for i in range(7, 13):
self.assertAlmostEqual(state.q()[i], state4.q()[i])
for i in range(19, len(q)):
self.assertAlmostEqual(state.q()[i], state4.q()[i])
# try with a rotation
rot = [0.259, 0, 0, 0.966]
state5, success = StateHelper.addNewContact(state, fullbody.rLegId, p, n, rotation = rot)
state5, success = StateHelper.addNewContact(state, fullbody.rLegId, p, n, rotation=rot)
self.assertTrue(success)
self.assertTrue(state5.isLimbInContact(fullbody.rLegId))
self.assertTrue(state5.isLimbInContact(fullbody.lLegId))
......@@ -92,11 +90,10 @@ class TestRBPRMstate6D(unittest.TestCase):
fullbody.setCurrentConfig(state5.q())
rf_pose = fullbody.getJointPosition(fullbody.rfoot)
for i in range(4):
self.assertAlmostEqual(rf_pose[i+3], rot[i], 3)
self.assertAlmostEqual(rf_pose[i + 3], rot[i], 3)
process.kill()
if __name__ == '__main__':
unittest.main()
......@@ -9,12 +9,11 @@ PATH = "hpp.corbaserver.rbprm.scenarios.demos"
class TestTalosWalkContact(unittest.TestCase):
def test_talos_walk_contacts(self):
subprocess.run(["killall", "hpp-rbprm-server"])
process = subprocess.Popen("hpp-rbprm-server")
time.sleep(3)
module_scenario = import_module(PATH+".talos_flatGround")
module_scenario = import_module(PATH + ".talos_flatGround")
if not hasattr(module_scenario, 'ContactGenerator'):
self.assertTrue(False)
ContactGenerator = getattr(module_scenario, 'ContactGenerator')
......
......@@ -10,12 +10,11 @@ PATH = "hpp.corbaserver.rbprm.scenarios.demos"
class TestTalosWalkPath(unittest.TestCase):
def test_talos_walk_path(self):
subprocess.run(["killall", "hpp-rbprm-server"])
process = subprocess.Popen("hpp-rbprm-server")
time.sleep(3)
module_scenario = import_module(PATH+".talos_flatGround_path")
module_scenario = import_module(PATH + ".talos_flatGround_path")
if not hasattr(module_scenario, 'PathPlanner'):
self.assertTrue(False)
PathPlanner = getattr(module_scenario, 'PathPlanner')
......@@ -26,11 +25,10 @@ class TestTalosWalkPath(unittest.TestCase):
self.assertEqual(ps.pathLength(0), ps.pathLength(1))
self.assertTrue(ps.pathLength(1) > 6.)
self.assertTrue(ps.pathLength(1) < 7.)
self.assertEqual(planner.q_init, ps.configAtParam(1,0))
self.assertEqual(planner.q_init, ps.configAtParam(1, 0))
self.assertEqual(planner.q_goal, ps.configAtParam(1, ps.pathLength(1)))
process.kill()
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment