Commit 750cf576 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Tests][Python] add unit test for guide & contact for talos

parent 6694918d
...@@ -72,5 +72,6 @@ endif() ...@@ -72,5 +72,6 @@ endif()
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME}) PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
CONFIG_FILES (include/${CUSTOM_HEADER_DIR}/doc.hh) CONFIG_FILES (include/${CUSTOM_HEADER_DIR}/doc.hh)
ADD_SUBDIRECTORY(python)
SET(${PROJECT_NAME}_PYTHON_TESTS
test_talos_walk_contacts
test_talos_walk_path
)
FOREACH(TEST ${${PROJECT_NAME}_PYTHON_TESTS})
ADD_PYTHON_UNIT_TEST("py-${TEST}" "tests/python/${TEST}.py")
ENDFOREACH(TEST ${${PROJECT_NAME}_PYTHON_TESTS})
# Copyright (c) 20120, CNRS
# Authors: Pierre Fernbach <pfernbac@laas.fr>
# Copyright (c) 2020, CNRS
# Authors: Pierre Fernbach <pfernbac@laas.fr>
import subprocess
from importlib import import_module
import os
import unittest
import time
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")
if not hasattr(module_scenario, 'ContactGenerator'):
self.assertTrue(False)
ContactGenerator = getattr(module_scenario, 'ContactGenerator')
cg = ContactGenerator()
cg.run()
self.assertTrue(len(cg.configs) > 5)
self.assertTrue(len(cg.configs) < 10)
self.assertEqual(cg.q_init, cg.configs[0])
self.assertEqual(cg.q_goal, cg.configs[-1])
process.kill()
if __name__ == '__main__':
unittest.main()
# Copyright (c) 2020, CNRS
# Authors: Pierre Fernbach <pfernbac@laas.fr>
import subprocess
from importlib import import_module
import os
import unittest
import time
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")
if not hasattr(module_scenario, 'PathPlanner'):
self.assertTrue(False)
PathPlanner = getattr(module_scenario, 'PathPlanner')
planner = PathPlanner()
planner.run()
ps = planner.ps
self.assertEqual(ps.numberPaths(), 2)
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_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