Commit 5c92a22a authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

Merge branch 'devel' into 'devel'

Python 3 & CI

See merge request loco-3d/crocoddyl!164
parents 918a8929 d32aaf5e
Pipeline #4605 passed with stage
in 7 minutes and 37 seconds
variables:
GIT_SUBMODULE_STRATEGY: "recursive"
CTEST_PARALLEL_LEVEL: 4
test:
image: eur0c.laas.fr:5000/loco-3d/crocoddyl
script:
- cmake .
- make
- make test || ctest -VV
format:
image: gepetto/linters
script:
- flake8 .
- yapf -dr .
- check-clang-format.sh
include: http://rainboard.laas.fr/project/crocoddyl/.gitlab-ci.yml
......@@ -13,7 +13,7 @@ SET(PROJECT_URL https://gepgitlab.laas.fr/${PROJECT_NAMESPACE}/${PROJECT_NAME})
SETUP_PROJECT()
ADD_REQUIRED_DEPENDENCY("pinocchio >= 2.1.0")
ADD_OPTIONAL_DEPENDENCY("multicontact-api >= 1.0.0")
ADD_OPTIONAL_DEPENDENCY("multicontact-api >= 1.1.0")
ADD_OPTIONAL_DEPENDENCY("quadprog")
ADD_OPTIONAL_DEPENDENCY("scipy")
......
FROM eur0c.laas.fr:5000/gepetto/buildfarm/robotpkg:16.04
RUN apt-get update -qqy \
&& apt-get install -qqy \
cython \
flake8 \
isort \
python-pip \
python-scipy \
robotpkg-example-robot-data \
robotpkg-py27-pinocchio \
robotpkg-py27-multicontact-api \
&& rm -rf /var/lib/apt/lists/* \
&& pip install \
quadprog \
yapf
......@@ -2,12 +2,12 @@ SET(${PROJECT_NAME}_PYTHON_FILES
action.py
activation.py
actuation.py
box_ddp.py
box_kkt.py
callbacks.py
contact.py
cost.py
ddp.py
box_ddp.py
diagnostic.py
differential_action.py
fddp.py
......@@ -15,8 +15,8 @@ SET(${PROJECT_NAME}_PYTHON_FILES
impact.py
__init__.py
integrated_action.py
qpsolvers.py
kkt.py
qpsolvers.py
robots.py
shooting.py
solver.py
......@@ -40,5 +40,5 @@ SET(${PROJECT_NAME}_LOCOMOTION_PYTHON_FILES
FOREACH(python ${${PROJECT_NAME}_LOCOMOTION_PYTHON_FILES})
PYTHON_BUILD(locomotion ${python})
INSTALL(FILES ${python} DESTINATION ${PYTHON_SITELIB}/${PROJECT_NAME}/locomotion)
INSTALL(FILES locomotion/${python} DESTINATION ${PYTHON_SITELIB}/${PROJECT_NAME}/locomotion)
ENDFOREACH(python ${${PROJECT_NAME}_LOCOMOTION_PYTHON_FILES})
......@@ -3,7 +3,7 @@ import numpy as np
from .cost import CostModelState, CostModelSum
from .floating_contact import DifferentialActionModelFloatingInContact
from .state import StateVector
from .utils import EPS
from .utils import EPS, randomOrthonormalMatrix
class ActionModelAbstract:
......@@ -128,7 +128,6 @@ class ActionModelLQR(ActionModelAbstract):
ActionModelAbstract.__init__(self, StateVector(nx), nu)
self.ActionDataType = ActionDataLQR
from utils import randomOrthonormalMatrix
self.Fx = randomOrthonormalMatrix(self.ndx)
self.Fu = randomOrthonormalMatrix(self.ndx)[:, :self.nu]
self.f0 = np.zeros(self.ndx) if driftFree else np.random.rand(self.ndx)
......@@ -257,7 +256,7 @@ class ActionModelNumDiff(ActionModelAbstract):
assert (~np.isclose(model.State.diff(mc.ref, x)[3:6], np.ones(3) * np.pi, atol=1e-6).any())
assert (~np.isclose(model.State.diff(mc.ref, x)[3:6], -np.ones(3) * np.pi, atol=1e-6).any())
elif isinstance(mc, CostModelSum):
for (key, cost) in mc.costs.iteritems():
for (key, cost) in mc.costs.items():
if isinstance(cost.cost, CostModelState):
assert (~np.isclose(
model.State.diff(cost.cost.ref, x)[3:6], np.ones(3) * np.pi, atol=1e-6).any())
......
from collections import OrderedDict
from exceptions import RuntimeError
import numpy as np
......
......@@ -10,7 +10,7 @@ SET(${PROJECT_NAME}_PYTHON_TESTS
dse3
dynamic_derivatives
impact
#locomotion
locomotion
quadruped
rk4
robots
......
......@@ -132,7 +132,7 @@ ddp.solve(maxiter=1,
init_xs=[rmodel.defaultState] * len(ddp.models()),
init_us=[
_m.differential.quasiStatic(_d.differential, rmodel.defaultState)
for _m, _d in zip(ddp.models(), ddp.datas())[:-1]
for _m, _d in list(zip(ddp.models(), ddp.datas()))[:-1]
])
assert (ddp.cost < 1e5)
......
import numpy as np
from crocoddyl import (DifferentialActionModelLQR, IntegratedActionModelEuler, ShootingProblem, SolverBoxDDP,
SolverBoxKKT, SolverDDP, SolverKKT)
from crocoddyl.qpsolvers import quadprogWrapper
......@@ -81,13 +82,13 @@ xddp_box, uddp_box, costddp_box = ddpbox.forwardPass(stepLength=1)
# Check that all other values of uddp_box are the same as the previous uddp
if limit_lower:
assert (uddp_box[0][limit_id] == ddpbox.ul[limit_id])
ok_range = range(nu)
ok_range.pop(limit_id)
ok_range = list(range(nu))
ok_range.pop(limit_id[0])
assert (np.allclose(uddp[0][ok_range], uddp_box[0][ok_range], atol=1e-9))
else:
assert (uddp_box[0][limit_id] == ddpbox.uu[limit_id])
ok_range = range(nu)
ok_range.pop(limit_id)
ok_range = list(range(nu))
ok_range.pop(limit_id[0])
assert (np.allclose(uddp[0][ok_range], uddp_box[0][ok_range], atol=1e-9))
# KKT vs Box KKT
......
import numpy as np
from numpy.linalg import eig, norm, pinv
import pinocchio
from crocoddyl import (ActionModelNumDiff, ActuationModelFreeFloating, CallbackDDPLogger, ContactModel3D,
ContactModel6D, ContactModelMultiple, CostModelControl, CostModelForce,
......@@ -7,7 +9,6 @@ from crocoddyl import (ActionModelNumDiff, ActuationModelFreeFloating, CallbackD
IntegratedActionModelEuler, ShootingProblem, SolverDDP, SolverKKT, StatePinocchio, a2m, absmax,
loadTalosArm, m2a)
from crocoddyl.utils import EPS
from numpy.linalg import eig, norm, pinv
from pinocchio.utils import rand, zero
from testutils import NUMDIFF_MODIFIER, assertNumDiff, df_dq, df_dx
......@@ -150,8 +151,8 @@ model = DifferentialActionModelFloatingInContact(rmodel, actModel, contactModel,
data = model.createData()
model.calc(data, x, u)
assert (len(filter(lambda x: x > 0, eig(data.K)[0])) == model.nv)
assert (len(filter(lambda x: x < 0, eig(data.K)[0])) == model.ncontact)
assert (len(list(filter(lambda x: x > 0, eig(data.K)[0]))) == model.nv)
assert (len(list(filter(lambda x: x < 0, eig(data.K)[0]))) == model.ncontact)
_taucheck = pinocchio.rnea(rmodel, rdata, q, v, a2m(data.a), data.contact.forces)
_taucheck.flat[:] += rmodel.armature.flat * data.a
assert (absmax(_taucheck[:6]) < 1e-6)
......@@ -186,8 +187,8 @@ model = DifferentialActionModelFloatingInContact(rmodel, actModel, contactModel,
data = model.createData()
model.calc(data, x, u)
assert (len(filter(lambda x: x > 0, eig(data.K)[0])) == model.nv)
assert (len(filter(lambda x: x < 0, eig(data.K)[0])) == model.ncontact)
assert (len(list(filter(lambda x: x > 0, eig(data.K)[0]))) == model.nv)
assert (len(list(filter(lambda x: x < 0, eig(data.K)[0]))) == model.ncontact)
_taucheck = pinocchio.rnea(rmodel, rdata, q, v, a2m(data.a), data.contact.forces)
if hasattr(rmodel, 'armature'):
_taucheck.flat += rmodel.armature.flat * data.a
......
......@@ -2,9 +2,10 @@ import copy
import unittest
import numpy as np
from numpy.linalg import eig, inv, norm
from crocoddyl import (ActionModelLQR, ActionModelUnicycle, ActionModelUnicycleVar, ShootingProblem, SolverDDP,
SolverFDDP, SolverKKT)
from numpy.linalg import eig, inv, norm
class ShootingProblemTest(unittest.TestCase):
......@@ -61,8 +62,8 @@ class SolverKKTTest(unittest.TestCase):
self.kkt.calc()
# Getting the dimension of the KKT problem
nxu = len(filter(lambda x: x > 0, eig(self.kkt.kkt)[0]))
nx = len(filter(lambda x: x < 0, eig(self.kkt.kkt)[0]))
nxu = len(list(filter(lambda x: x > 0, eig(self.kkt.kkt)[0])))
nx = len(list(filter(lambda x: x < 0, eig(self.kkt.kkt)[0])))
# Checking the dimension of the KKT problem
self.assertTrue(nxu == self.kkt.nx + self.kkt.nu, "Dimension of decision variables is wrong.")
......
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