Commit 747ac089 authored by Carlos Mastalli's avatar Carlos Mastalli
Browse files

Merge branch 'unittest' into 'unittest'

Unittest standardization

See merge request !4
parents da6012b8 e42751ec
Pipeline #3241 passed with stage
in 57 seconds
image: gepgitlab.laas.fr:4567/Gepetto/example-robot-data include: http://rainboard.laas.fr/project/example-robot-data/.gitlab-ci.yml
test:
script:
- cd unittest && python test_load.py
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
INCLUDE(cmake/base.cmake) INCLUDE(cmake/base.cmake)
INCLUDE(cmake/test.cmake)
SET(PROJECT_NAMESPACE gepetto)
SET(PROJECT_NAME example-robot-data) SET(PROJECT_NAME example-robot-data)
SET(PROJECT_DESCRIPTION "Set of robot URDFs for benchmarking and developed examples.") SET(PROJECT_DESCRIPTION "Set of robot URDFs for benchmarking and developed examples.")
SET(PROJECT_URL https://gepgitlab.laas.fr/gepetto/${PROJECT_NAME}) SET(PROJECT_URL https://gepgitlab.laas.fr/${PROJECT_NAMESPACE}/${PROJECT_NAME})
SETUP_PROJECT() SETUP_PROJECT()
INSTALL(DIRECTORY hyq_description DESTINATION share/${PROJECT_NAME}) INSTALL(DIRECTORY hyq_description DESTINATION share/${PROJECT_NAME})
INSTALL(DIRECTORY talos_data DESTINATION share/${PROJECT_NAME}) INSTALL(DIRECTORY talos_data DESTINATION share/${PROJECT_NAME})
ADD_SUBDIRECTORY(unittest)
SETUP_PROJECT_FINALIZE() SETUP_PROJECT_FINALIZE()
FROM eur0c.laas.fr:5000/gepetto/buildfarm/robotpkg:16.04
RUN apt-get update -qqy \
&& apt-get install -qqy \
robotpkg-py27-pinocchio \
&& rm -rf /var/lib/apt/lists/*
SET(${PROJECT_NAME}_PYTHON_TESTS
load
)
FOREACH(TEST ${${PROJECT_NAME}_PYTHON_TESTS})
ADD_PYTHON_UNIT_TEST("py-${TEST}" "unittest/test_${TEST}.py")
ENDFOREACH(TEST ${${PROJECT_NAME}_PYTHON_TESTS})
#!/usr/bin/env python2
import unittest import unittest
from unittest_utils import loadHyQ, loadTalos, loadTalosArm from unittest_utils import loadHyQ, loadTalos, loadTalosArm
......
from os.path import exists, join
import numpy as np import numpy as np
import pinocchio import pinocchio
from pinocchio.robot_wrapper import RobotWrapper from pinocchio.robot_wrapper import RobotWrapper
def getModelPath(subpath):
for path in ['..', '../..', '/opt/openrobots/share/example-robot-data']:
if exists(join(path, subpath.strip('/'))):
print "using %s as modelPath" % path
return path
raise IOError('%s not found' % (subpath))
def readParamsFromSrdf(robot, SRDF_PATH, verbose): def readParamsFromSrdf(robot, SRDF_PATH, verbose):
rmodel = robot.model rmodel = robot.model
...@@ -25,11 +36,12 @@ def readParamsFromSrdf(robot, SRDF_PATH, verbose): ...@@ -25,11 +36,12 @@ def readParamsFromSrdf(robot, SRDF_PATH, verbose):
return return
def loadTalosArm(modelPath='/opt/openrobots/share/example-robot-data'): def loadTalosArm():
URDF_FILENAME = "talos_left_arm.urdf" URDF_FILENAME = "talos_left_arm.urdf"
URDF_SUBPATH = "/talos_data/robots/" + URDF_FILENAME URDF_SUBPATH = "/talos_data/robots/" + URDF_FILENAME
SRDF_FILENAME = "talos.srdf" SRDF_FILENAME = "talos.srdf"
SRDF_SUBPATH = "/talos_data/srdf/" + SRDF_FILENAME SRDF_SUBPATH = "/talos_data/srdf/" + SRDF_FILENAME
modelPath = getModelPath(URDF_SUBPATH)
# Load URDF file # Load URDF file
robot = RobotWrapper.BuildFromURDF(modelPath+URDF_SUBPATH, [modelPath]) robot = RobotWrapper.BuildFromURDF(modelPath+URDF_SUBPATH, [modelPath])
...@@ -38,11 +50,12 @@ def loadTalosArm(modelPath='/opt/openrobots/share/example-robot-data'): ...@@ -38,11 +50,12 @@ def loadTalosArm(modelPath='/opt/openrobots/share/example-robot-data'):
return robot return robot
def loadTalos(modelPath='/opt/openrobots/share/example-robot-data'): def loadTalos():
URDF_FILENAME = "talos_reduced.urdf" URDF_FILENAME = "talos_reduced.urdf"
SRDF_FILENAME = "talos.srdf" SRDF_FILENAME = "talos.srdf"
SRDF_SUBPATH = "/talos_data/srdf/" + SRDF_FILENAME SRDF_SUBPATH = "/talos_data/srdf/" + SRDF_FILENAME
URDF_SUBPATH = "/talos_data/robots/" + URDF_FILENAME URDF_SUBPATH = "/talos_data/robots/" + URDF_FILENAME
modelPath = getModelPath(URDF_SUBPATH)
# Load URDF file # Load URDF file
robot = RobotWrapper.BuildFromURDF(modelPath+URDF_SUBPATH, [modelPath], robot = RobotWrapper.BuildFromURDF(modelPath+URDF_SUBPATH, [modelPath],
pinocchio.JointModelFreeFlyer()) pinocchio.JointModelFreeFlyer())
...@@ -52,9 +65,10 @@ def loadTalos(modelPath='/opt/openrobots/share/example-robot-data'): ...@@ -52,9 +65,10 @@ def loadTalos(modelPath='/opt/openrobots/share/example-robot-data'):
return robot return robot
def loadHyQ(modelPath='/opt/openrobots/share/example-robot-data'): def loadHyQ():
URDF_FILENAME = "hyq_no_sensors.urdf" URDF_FILENAME = "hyq_no_sensors.urdf"
URDF_SUBPATH = "/hyq_description/robots/" + URDF_FILENAME URDF_SUBPATH = "/hyq_description/robots/" + URDF_FILENAME
modelPath = getModelPath(URDF_SUBPATH)
robot = RobotWrapper.BuildFromURDF(modelPath+URDF_SUBPATH, [modelPath], robot = RobotWrapper.BuildFromURDF(modelPath+URDF_SUBPATH, [modelPath],
pinocchio.JointModelFreeFlyer()) pinocchio.JointModelFreeFlyer())
# TODO define default position inside srdf # TODO define default position inside srdf
......
Supports Markdown
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