diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml
index 23b488af86..cb24af71c1 100644
--- a/.github/workflows/changelog.yaml
+++ b/.github/workflows/changelog.yaml
@@ -11,6 +11,6 @@ jobs:
name: Check changelog action
runs-on: ubuntu-latest
steps:
- - uses: tarides/changelog-check-action@v2
+ - uses: tarides/changelog-check-action@v3
with:
changelog: CHANGELOG.md
diff --git a/.github/workflows/nix-ci.yml b/.github/workflows/nix-ci.yml
new file mode 100644
index 0000000000..d2f11d36be
--- /dev/null
+++ b/.github/workflows/nix-ci.yml
@@ -0,0 +1,32 @@
+name: "NIX"
+
+# This determines when this workflow is run
+on:
+ push:
+ branches:
+ - master
+ - devel
+ pull_request:
+ branches:
+ - master
+ - devel
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ nix:
+ runs-on: "${{ matrix.os }}-latest"
+ strategy:
+ matrix:
+ os: [ubuntu, macos]
+ name: (${{ matrix.os }})
+ steps:
+ - uses: actions/checkout@v4
+ - uses: cachix/install-nix-action@v30
+ - uses: cachix/cachix-action@v15
+ with:
+ name: gepetto
+ authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
+ - run: nix build -L
diff --git a/.github/workflows/ros1-ci.yaml b/.github/workflows/ros1-ci.yaml
index 96d9449a0a..11317b9cb4 100644
--- a/.github/workflows/ros1-ci.yaml
+++ b/.github/workflows/ros1-ci.yaml
@@ -30,6 +30,7 @@ concurrency:
jobs:
CI:
+ if: github.event_name == 'push' || (github.event_name == 'pull_request' && !contains(join(github.event.pull_request.labels.*.name, ','), 'no ros'))
strategy:
fail-fast: false
matrix:
diff --git a/.github/workflows/ros2-ci.yaml b/.github/workflows/ros2-ci.yaml
index 9c67d80dcb..3531ef9014 100644
--- a/.github/workflows/ros2-ci.yaml
+++ b/.github/workflows/ros2-ci.yaml
@@ -30,6 +30,7 @@ concurrency:
jobs:
CI:
+ if: github.event_name == 'push' || (github.event_name == 'pull_request' && !contains(join(github.event.pull_request.labels.*.name, ','), 'no ros'))
strategy:
fail-fast: false
matrix:
@@ -50,7 +51,7 @@ jobs:
BUILDER: colcon
# This by-passes issues on importing example_robot_data module when running examples and unit tests.
# It seems target_ws is unable to properly overlay upstream_ws.
- AFTER_SETUP_UPSTREAM_WORKSPACE: 'pip install example-robot-data --break-system-packages'
+ AFTER_SETUP_UPSTREAM_WORKSPACE: 'pip install example-robot-data'
runs-on: ubuntu-latest
continue-on-error: true
steps:
diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml
new file mode 100644
index 0000000000..83f0269048
--- /dev/null
+++ b/.github/workflows/update-flake-lock.yml
@@ -0,0 +1,20 @@
+name: update-flake-lock
+
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: '0 21 12 * *'
+
+jobs:
+ lockfile:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@main
+ - name: Update flake.lock
+ uses: DeterminateSystems/update-flake-lock@main
+ with:
+ pr-title: "Update flake.lock"
+ token: ${{ secrets.GH_TOKEN_FOR_UPDATES }}
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 700c2adceb..9cc1b2fecb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1 +1 @@
-include: http://rainboard.laas.fr/project/crocoddyl/.gitlab-ci.yml
+include: https://rainboard.laas.fr/project/crocoddyl/.gitlab-ci.yml
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e974afb467..c7c3e18588 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,31 +2,30 @@ ci:
autoupdate_branch: devel
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.4.6
+ rev: v0.9.6
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
- - --ignore
- - UP036
- id: ruff-format
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- repo: https://github.com/pappasam/toml-sort
- rev: v0.23.1
+ rev: v0.24.2
hooks:
- id: toml-sort-fix
- repo: https://github.com/pre-commit/mirrors-clang-format
- rev: v18.1.5
+ rev: v19.1.7
hooks:
- id: clang-format
args:
- --style=Google
+ exclude: '^.*\.ipynb$'
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.6.0
+ rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4bb45a6bcd..d8fadacc42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
+## [2.2.0] - 1980-01-01
+
+* Changed return policy in std::vector of Eigen's vector and matrices to be compliant with Pinocchio in https://github.com/loco-3d/crocoddyl/pull/1338
+* Prevent users to improperly setting residual references in https://github.com/loco-3d/crocoddyl/pull/1332
+* Fixed the inequality constraints' feasibility computation by incorporating bounds into the calculation in https://github.com/loco-3d/crocoddyl/pull/1307
+* Improved the action factory used for unit testing in https://github.com/loco-3d/crocoddyl/pull/1300
+* Ignore ruff issues in ipython notebook files in https://github.com/loco-3d/crocoddyl/pull/1297
+* Improved efficiency for computing impulse-dynamics derivatives in https://github.com/loco-3d/crocoddyl/pull/1294
+* Fixed bug of wrench cone fields not being updated with setters in https://github.com/loco-3d/crocoddyl/pull/1274
+* Replaced parent by parentJoint (which was introduced in Pinocchio 3) in https://github.com/loco-3d/crocoddyl/pull/1271
+* Introduced the notion of terminal dimension, residuals and constraints in https://github.com/loco-3d/crocoddyl/pull/1269
+* General clean ups about std::size_t in https://github.com/loco-3d/crocoddyl/pull/1265
+* Fixed issues in LQR extensions in https://github.com/loco-3d/crocoddyl/pull/1263
+* Computed dynamic feasibility everytime in https://github.com/loco-3d/crocoddyl/pull/1262
+* Extend LQR actions in https://github.com/loco-3d/crocoddyl/pull/1261
+* Print log with grad absolute + updated logs with Pinocchio 3 in https://github.com/loco-3d/crocoddyl/pull/1260
+
## [2.1.0] - 2024-05-31
* Updated black + isort + flake8 to ruff in https://github.com/loco-3d/crocoddyl/pull/1256
@@ -296,7 +313,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
Initial release
-[Unreleased]: https://github.com/loco-3d/crocoddyl/compare/v2.1.0...HEAD
+[Unreleased]: https://github.com/loco-3d/crocoddyl/compare/v2.2.0...HEAD
+[2.2.0]: https://github.com/loco-3d/crocoddyl/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/loco-3d/crocoddyl/compare/v2.0.2...v2.1.0
[2.0.2]: https://github.com/loco-3d/crocoddyl/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/loco-3d/crocoddyl/compare/v2.0.0...v2.0.1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a764a02a4b..c3908d0e90 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -91,8 +91,8 @@ if(APPLE) # Use the handmade approach
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/find-external/OpenMP
${CMAKE_MODULE_PATH})
elseif(UNIX)
- if(${CMAKE_VERSION} VERSION_GREATER "3.20.0" OR ${CMAKE_VERSION}
- VERSION_EQUAL "3.20.0")
+ if(${CMAKE_VERSION} VERSION_GREATER "3.25.0" OR ${CMAKE_VERSION}
+ VERSION_EQUAL "3.25.0")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/find-external/OpenMP
${CMAKE_MODULE_PATH})
endif()
diff --git a/README.md b/README.md
index 1ba508aa55..10c7cd3b20 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,10 @@
+
+
+
@@ -52,6 +55,13 @@ If you want to learn more about **Crocoddyl** and its solvers, we suggest readin
**Crocoddyl** can be easily installed on various Linux (Ubuntu, Fedora, etc.) and Unix distributions (Mac OS X, BSD, etc.). Below, there are different ways to install Crocoddyl.
+###
On ArchLinux
+
+With your favorite AUR helper, eg. paru:
+```bash
+ paru -Syu crocoddyl
+```
+
### :dragon: From
Just run the following command in the terminal:
@@ -60,6 +70,16 @@ Just run the following command in the terminal:
```
Conda installation supports [](https://anaconda.org/conda-forge/crocoddyl).
+###
From Nix
+
+`crocoddyl` & `python3Packages.crocoddyl` are available in [nixpkgs](https://github.com/NixOS/nixpkgs/).
+
+This repository is also a flake, so you may:
+- run a python shell with crocoddyl: `nix run github:loco-3d/crocoddyl`
+- use it in your own flake: `crocoddyl.url = "github:loco-3d/crocoddyl";`
+
+The build cache use by CI and developers is [gepetto.cachix.org](https://app.cachix.org/cache/gepetto)
+
### :snake: From
Just run the following command in the terminal:
diff --git a/bindings/python/crocoddyl/__init__.py b/bindings/python/crocoddyl/__init__.py
index b2f6e17e09..4e0cf29f85 100644
--- a/bindings/python/crocoddyl/__init__.py
+++ b/bindings/python/crocoddyl/__init__.py
@@ -6,6 +6,7 @@
import numpy as np
import pinocchio
+from pinocchio.visualize import MeshcatVisualizer
from .libcrocoddyl_pywrap import * # noqa: F403
from .libcrocoddyl_pywrap import __raw_version__, __version__ # noqa: F401
@@ -129,7 +130,10 @@ def init(self, solver):
thrusters.append(model.differential.actuation.thrusters)
for n in frameNames:
frameId = self.robot.model.getFrameId(n)
- parentId = self.robot.model.frames[frameId].parent
+ if tuple(int(i) for i in pinocchio.__version__.split(".")) >= (3, 0, 0):
+ parentId = self.robot.model.frames[frameId].parentJoint
+ else:
+ parentId = self.robot.model.frames[frameId].parent
self.activeContacts[str(parentId)] = True
self.frictionMu[str(parentId)] = 0.7
self.frameTrajNames.append(str(frameId))
@@ -339,7 +343,10 @@ def _getForceInformation(self, state, contact_model, contact_data, cost_model):
fc = []
for key, contact in contact_data.todict().items():
if contact_model[key].active:
- joint = state.pinocchio.frames[contact.frame].parent
+ if tuple(map(int, pinocchio.__version__.split("."))) >= (3, 0, 0):
+ joint = state.pinocchio.frames[contact.frame].parentJoint
+ else:
+ joint = state.pinocchio.frames[contact.frame].parent
oMf = contact.pinocchio.oMi[joint] * contact.jMf
fiMo = pinocchio.SE3(
contact.pinocchio.oMi[joint].rotation.T,
@@ -558,7 +565,7 @@ def __init__(
if frameNames is not None:
print("Deprecated. Do not pass frameNames")
robot.setVisualizer(
- pinocchio.visualize.MeshcatVisualizer(
+ MeshcatVisualizer(
model=self.robot.model,
collision_model=self.robot.collision_model,
visual_model=self.robot.visual_model,
diff --git a/bindings/python/crocoddyl/core/action-base.cpp b/bindings/python/crocoddyl/core/action-base.cpp
index 6dc4718cff..ed19a05eb4 100644
--- a/bindings/python/crocoddyl/core/action-base.cpp
+++ b/bindings/python/crocoddyl/core/action-base.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh,
// University of Oxford, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -40,15 +40,18 @@ void exposeActionAbstract() {
"and calcDiff(),\n"
"respectively.",
bp::init, std::size_t,
- bp::optional >(
- bp::args("self", "state", "nu", "nr", "ng", "nh"),
+ bp::optional >(
+ bp::args("self", "state", "nu", "nr", "ng", "nh", "ng_T", "nh_T"),
"Initialize the action model.\n\n"
"We can also describe autonomous systems by setting nu = 0.\n"
":param state: state description,\n"
":param nu: dimension of control vector,\n"
":param nr: dimension of the cost-residual vector (default 1)\n"
":param ng: number of inequality constraints (default 0)\n"
- ":param nh: number of equality constraints (default 0)\n"))
+ ":param nh: number of equality constraints (default 0)\n"
+ ":param ng_T: number of inequality terminal constraints (default 0)\n"
+ ":param nh_T: number of equality terminal constraints (default 0)"))
.def("calc", pure_virtual(&ActionModelAbstract_wrap::calc),
bp::args("self", "data", "x", "u"),
"Compute the next state and cost value.\n\n"
@@ -130,6 +133,16 @@ void exposeActionAbstract() {
bp::make_setter(&ActionModelAbstract_wrap::nh_,
bp::return_internal_reference<>()),
"number of equality constraints")
+ .add_property("ng_T",
+ bp::make_function(&ActionModelAbstract_wrap::get_ng_T),
+ bp::make_setter(&ActionModelAbstract_wrap::ng_T_,
+ bp::return_internal_reference<>()),
+ "number of inequality terminal constraints")
+ .add_property("nh_T",
+ bp::make_function(&ActionModelAbstract_wrap::get_nh_T),
+ bp::make_setter(&ActionModelAbstract_wrap::nh_T_,
+ bp::return_internal_reference<>()),
+ "number of equality terminal constraints")
.add_property(
"state",
bp::make_function(&ActionModelAbstract_wrap::get_state,
diff --git a/bindings/python/crocoddyl/core/action-base.hpp b/bindings/python/crocoddyl/core/action-base.hpp
index 1f2abe826c..241677c223 100644
--- a/bindings/python/crocoddyl/core/action-base.hpp
+++ b/bindings/python/crocoddyl/core/action-base.hpp
@@ -22,14 +22,18 @@ class ActionModelAbstract_wrap : public ActionModelAbstract,
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
using ActionModelAbstract::ng_;
+ using ActionModelAbstract::ng_T_;
using ActionModelAbstract::nh_;
+ using ActionModelAbstract::nh_T_;
using ActionModelAbstract::nu_;
using ActionModelAbstract::unone_;
ActionModelAbstract_wrap(boost::shared_ptr state,
const std::size_t nu, const std::size_t nr = 1,
- const std::size_t ng = 0, const std::size_t nh = 0)
- : ActionModelAbstract(state, nu, nr, ng, nh),
+ const std::size_t ng = 0, const std::size_t nh = 0,
+ const std::size_t ng_T = 0,
+ const std::size_t nh_T = 0)
+ : ActionModelAbstract(state, nu, nr, ng, nh, ng_T, nh_T),
bp::wrapper() {
unone_ = NAN * MathBase::VectorXs::Ones(nu);
}
@@ -38,14 +42,14 @@ class ActionModelAbstract_wrap : public ActionModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calc").ptr(), data,
@@ -60,14 +64,14 @@ class ActionModelAbstract_wrap : public ActionModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calcDiff").ptr(), data,
@@ -99,9 +103,9 @@ class ActionModelAbstract_wrap : public ActionModelAbstract,
u = bp::call(quasiStatic.ptr(), data, (Eigen::VectorXd)x,
maxiter, tol);
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return;
}
diff --git a/bindings/python/crocoddyl/core/actions/diff-lqr.cpp b/bindings/python/crocoddyl/core/actions/diff-lqr.cpp
index 802f621a31..c9fcc613e0 100644
--- a/bindings/python/crocoddyl/core/actions/diff-lqr.cpp
+++ b/bindings/python/crocoddyl/core/actions/diff-lqr.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -12,11 +12,20 @@
#include "python/crocoddyl/core/core.hpp"
#include "python/crocoddyl/core/diff-action-base.hpp"
#include "python/crocoddyl/utils/copyable.hpp"
+#include "python/crocoddyl/utils/deprecate.hpp"
namespace crocoddyl {
namespace python {
+BOOST_PYTHON_FUNCTION_OVERLOADS(DifferentialActionModelLQR_Random_wrap,
+ DifferentialActionModelLQR::Random, 2, 4)
+
void exposeDifferentialActionLQR() {
+// TODO: Remove once the deprecated update call has been removed in a future
+// release
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
boost::python::register_ptr_to_python<
boost::shared_ptr >();
@@ -24,18 +33,65 @@ void exposeDifferentialActionLQR() {
bp::bases >(
"DifferentialActionModelLQR",
"Differential action model for linear dynamics and quadratic cost.\n\n"
- "This class implements a linear dynamics, and quadratic costs (i.e.\n"
- "LQR action). Since the DAM is a second order system, and the "
- "integrated\n"
- "action models are implemented as being second order integrators. This\n"
- "class implements a second order linear system given by\n"
+ "This class implements a linear dynamics, quadratic costs, and linear "
+ "constraints (i.e. LQR action). Since the DAM is a second order system, "
+ "and the integrated action models are implemented as being second order "
+ "integrators. This class implements a second order linear system given "
+ "by\n"
" x = [q, v]\n"
" dv = Fq q + Fv v + Fu u + f0\n"
- "where Fq, Fv, Fu and f0 are randomly chosen constant terms. On the "
- "other\n"
- "hand the cost function is given by\n"
- " l(x,u) = 1/2 [x,u].T [Lxx Lxu; Lxu.T Luu] [x,u] + [lx,lu].T [x,u].",
- bp::init >(
+ "where Fq, Fv, Fu and f are randomly chosen constant terms. On the other "
+ "hand, the cost function is given by\n"
+ " l(x,u) = 1/2 [x,u].T [Q N; N.T R] [x,u] + [q,r].T [x,u],\n"
+ "and the linear equality and inequality constraints has the form:\n"
+ " g(x,u) = G [x,u] + g<=0\n"
+ " h(x,u) = H [x,u] + h.",
+ bp::init(
+ bp::args("self", "Aq", "Av", "B", "Q", "R", "N"),
+ "Initialize the differential LQR action model.\n\n"
+ ":param Aq: position matrix\n"
+ ":param Av: velocity matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix"))
+ .def(bp::init(
+ bp::args("self", "Aq", "Av", "B", "Q", "R", "N", "f", "q", "r"),
+ "Initialize the differential LQR action model.\n\n"
+ ":param Aq: position matrix\n"
+ ":param Av: velocity matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix\n"
+ ":param f: dynamics drift\n"
+ ":param q: state weight vector\n"
+ ":param r: input weight vector"))
+ .def(bp::init(
+ bp::args("self", "Aq", "Av", "B", "Q", "R", "N", "G", "H", "f", "q",
+ "r", "g", "h"),
+ "Initialize the differential LQR action model.\n\n"
+ ":param Aq: position matrix\n"
+ ":param Av: velocity matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix\n"
+ ":param G: state-input inequality constraint matrix\n"
+ ":param H: state-input equality constraint matrix\n"
+ ":param f: dynamics drift\n"
+ ":param q: state weight vector\n"
+ ":param r: input weight vector\n"
+ ":param g: state-input inequality constraint bias\n"
+ ":param h: state-input equality constraint bias"))
+ .def(bp::init >(
bp::args("self", "nq", "nu", "driftFree"),
"Initialize the differential LQR action model.\n\n"
":param nx: dimension of the state vector\n"
@@ -84,46 +140,152 @@ void exposeDifferentialActionLQR() {
bp::args("self", "data", "x"))
.def("createData", &DifferentialActionModelLQR::createData,
bp::args("self"), "Create the differential LQR action data.")
- .add_property("Fq",
- bp::make_function(&DifferentialActionModelLQR::get_Fq,
+ .def("Random", &DifferentialActionModelLQR::Random,
+ DifferentialActionModelLQR_Random_wrap(
+ bp::args("nq", "nu", "ng", "nh"),
+ "Create a random LQR model.\n\n"
+ ":param: nq: position dimension\n"
+ ":param nu: control dimension\n"
+ ":param ng: inequality constraint dimension (default 0)\n"
+ ":param nh: equality constraint dimension (default 0)"))
+ .staticmethod("Random")
+ .def("setLQR", &DifferentialActionModelLQR::set_LQR,
+ bp::args("self", "Aq", "Av", "B", "Q", "R", "N", "f", "q", "r"),
+ "Modify the LQR action model.\n\n"
+ ":param Aq: position matrix\n"
+ ":param Av: velocity matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix\n"
+ ":param f: dynamics drift\n"
+ ":param q: state weight vector\n"
+ ":param r: input weight vector")
+ .add_property("Aq",
+ bp::make_function(&DifferentialActionModelLQR::get_Aq,
+ bp::return_internal_reference<>()),
+ "position matrix")
+ .add_property("Av",
+ bp::make_function(&DifferentialActionModelLQR::get_Av,
+ bp::return_internal_reference<>()),
+ "velocity matrix")
+ .add_property("B",
+ bp::make_function(&DifferentialActionModelLQR::get_B,
+ bp::return_internal_reference<>()),
+ "input matrix")
+ .add_property("f",
+ bp::make_function(&DifferentialActionModelLQR::get_f,
+ bp::return_internal_reference<>()),
+ "dynamics drift")
+ .add_property("Q",
+ bp::make_function(&DifferentialActionModelLQR::get_Q,
+ bp::return_internal_reference<>()),
+ "state weight matrix")
+ .add_property("R",
+ bp::make_function(&DifferentialActionModelLQR::get_R,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_Fq,
- "Jacobian of the dynamics")
- .add_property("Fv",
- bp::make_function(&DifferentialActionModelLQR::get_Fv,
+ "input weight matrix")
+ .add_property("N",
+ bp::make_function(&DifferentialActionModelLQR::get_N,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_Fv,
- "Jacobian of the dynamics")
- .add_property("Fu",
- bp::make_function(&DifferentialActionModelLQR::get_Fu,
+ "state-input weight matrix")
+ .add_property("G",
+ bp::make_function(&DifferentialActionModelLQR::get_G,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_Fu,
- "Jacobian of the dynamics")
- .add_property("f0",
- bp::make_function(&DifferentialActionModelLQR::get_f0,
+ "state-input inequality constraint matrix")
+ .add_property("H",
+ bp::make_function(&DifferentialActionModelLQR::get_H,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_f0, "dynamics drift")
- .add_property("lx",
- bp::make_function(&DifferentialActionModelLQR::get_lx,
+ "state-input equality constraint matrix")
+ .add_property("q",
+ bp::make_function(&DifferentialActionModelLQR::get_q,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_lx, "Jacobian of the cost")
- .add_property("lu",
- bp::make_function(&DifferentialActionModelLQR::get_lu,
+ "state weight vector")
+ .add_property("r",
+ bp::make_function(&DifferentialActionModelLQR::get_r,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_lu, "Jacobian of the cost")
- .add_property("Lxx",
- bp::make_function(&DifferentialActionModelLQR::get_Lxx,
+ "input weight vector")
+ .add_property("g",
+ bp::make_function(&DifferentialActionModelLQR::get_g,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_Lxx, "Hessian of the cost")
- .add_property("Lxu",
- bp::make_function(&DifferentialActionModelLQR::get_Lxu,
+ "state-input inequality constraint bias")
+ .add_property("h",
+ bp::make_function(&DifferentialActionModelLQR::get_h,
bp::return_internal_reference<>()),
- &DifferentialActionModelLQR::set_Lxu, "Hessian of the cost")
+ "state-input equality constraint bias")
+ // deprecated function
+ .add_property(
+ "Fq",
+ bp::make_function(&DifferentialActionModelLQR::get_Aq,
+ deprecated >(
+ "Deprecated. Use Aq.")),
+ bp::make_function(&DifferentialActionModelLQR::set_Fq,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "position matrix")
+ .add_property(
+ "Fv",
+ bp::make_function(&DifferentialActionModelLQR::get_Av,
+ deprecated >(
+ "Deprecated. Use Av.")),
+ bp::make_function(&DifferentialActionModelLQR::set_Fv,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "position matrix")
+ .add_property(
+ "Fu",
+ bp::make_function(&DifferentialActionModelLQR::get_B,
+ deprecated >(
+ "Deprecated. Use B.")),
+ bp::make_function(&DifferentialActionModelLQR::set_Fu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "input matrix")
+ .add_property(
+ "f0",
+ bp::make_function(&DifferentialActionModelLQR::get_f,
+ deprecated >(
+ "Deprecated. Use f.")),
+ bp::make_function(&DifferentialActionModelLQR::set_f0,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "dynamics drift")
+ .add_property(
+ "lx",
+ bp::make_function(&DifferentialActionModelLQR::get_q,
+ deprecated >(
+ "Deprecated. Use q.")),
+ bp::make_function(&DifferentialActionModelLQR::set_lx,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "state weight vector")
+ .add_property(
+ "lu",
+ bp::make_function(&DifferentialActionModelLQR::get_r,
+ deprecated >(
+ "Deprecated. Use r.")),
+ bp::make_function(&DifferentialActionModelLQR::set_lu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "input weight vector")
+ .add_property(
+ "Lxx",
+ bp::make_function(&DifferentialActionModelLQR::get_Q,
+ deprecated >(
+ "Deprecated. Use Q.")),
+ bp::make_function(&DifferentialActionModelLQR::set_Lxx,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "state weight matrix")
+ .add_property(
+ "Lxu",
+ bp::make_function(&DifferentialActionModelLQR::get_N,
+ deprecated >(
+ "Deprecated. Use N.")),
+ bp::make_function(&DifferentialActionModelLQR::set_Lxu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "state-input weight matrix")
.add_property(
"Luu",
- bp::make_function(&DifferentialActionModelLQR::get_Luu,
- bp::return_value_policy()),
- &DifferentialActionModelLQR::set_Luu, "Hessian of the cost")
+ bp::make_function(&DifferentialActionModelLQR::get_R,
+ deprecated >(
+ "Deprecated. Use R.")),
+ bp::make_function(&DifferentialActionModelLQR::set_Luu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "input weight matrix")
.def(CopyableVisitor());
boost::python::register_ptr_to_python<
@@ -138,6 +300,8 @@ void exposeDifferentialActionLQR() {
"Create differential LQR data.\n\n"
":param model: differential LQR action model"))
.def(CopyableVisitor());
+
+#pragma GCC diagnostic pop
}
} // namespace python
diff --git a/bindings/python/crocoddyl/core/actions/lqr.cpp b/bindings/python/crocoddyl/core/actions/lqr.cpp
index 02f211702d..b8c950e26f 100644
--- a/bindings/python/crocoddyl/core/actions/lqr.cpp
+++ b/bindings/python/crocoddyl/core/actions/lqr.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -12,21 +12,75 @@
#include "python/crocoddyl/core/action-base.hpp"
#include "python/crocoddyl/core/core.hpp"
#include "python/crocoddyl/utils/copyable.hpp"
+#include "python/crocoddyl/utils/deprecate.hpp"
namespace crocoddyl {
namespace python {
+BOOST_PYTHON_FUNCTION_OVERLOADS(ActionModelLQR_Random_wrap,
+ ActionModelLQR::Random, 2, 4)
+
void exposeActionLQR() {
+// TODO: Remove once the deprecated update call has been removed in a future
+// release
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
boost::python::register_ptr_to_python >();
bp::class_ >(
"ActionModelLQR",
"LQR action model.\n\n"
- "A Linear-Quadratic Regulator problem has a transition model of the "
+ "A linear-quadratic regulator (LQR) action has a transition model of the "
"form\n"
- "xnext(x,u) = Fx*x + Fu*u + f0. Its cost function is quadratic of the\n"
- "form: 1/2 [x,u].T [Lxx Lxu; Lxu.T Luu] [x,u] + [lx,lu].T [x,u].",
- bp::init >(
+ " xnext(x,u) = A x + B u + f.\n"
+ "Its cost function is quadratic of the form:\n"
+ " 1/2 [x,u].T [Q N; N.T R] [x,u] + [q,r].T [x,u],\n"
+ "and the linear equality and inequality constraints has the form:\n"
+ " g(x,u) = G [x,u] + g<=0\n"
+ " h(x,u) = H [x,u] + h.",
+ bp::init(
+ bp::args("self", "A", "B", "Q", "R", "N"),
+ "Initialize the LQR action model.\n\n"
+ ":param A: state matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix"))
+ .def(bp::init(
+ bp::args("self", "A", "B", "Q", "R", "N", "f", "q", "r"),
+ "Initialize the differential LQR action model.\n\n"
+ ":param A: state matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix\n"
+ ":param f: dynamics drift\n"
+ ":param q: state weight vector\n"
+ ":param r: input weight vector"))
+ .def(bp::init(
+ bp::args("self", "A", "B", "Q", "R", "N", "G", "H", "f", "q", "r",
+ "g", "h"),
+ "Initialize the LQR action model.\n\n"
+ ":param A: state matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix\n"
+ ":param G: state-input inequality constraint matrix\n"
+ ":param H: state-input equality constraint matrix\n"
+ ":param f: dynamics drift\n"
+ ":param q: state weight vector\n"
+ ":param r: input weight vector\n"
+ ":param g: state-input equality constraint bias\n"
+ ":param h: state-input inequality constraint bias"))
+ .def(bp::init >(
bp::args("self", "nx", "nu", "driftFree"),
"Initialize the LQR action model.\n\n"
":param nx: dimension of the state vector\n"
@@ -71,38 +125,142 @@ void exposeActionLQR() {
bp::args("self", "data", "x"))
.def("createData", &ActionModelLQR::createData, bp::args("self"),
"Create the LQR action data.")
- .add_property("Fx",
- bp::make_function(&ActionModelLQR::get_Fx,
+ .def("Random", &ActionModelLQR::Random,
+ ActionModelLQR_Random_wrap(
+ bp::args("nx", "nu", "ng", "nh"),
+ "Create a random LQR model.\n\n"
+ ":param nx: state dimension\n"
+ ":param nu: control dimension\n"
+ ":param ng: inequality constraint dimension (default 0)\n"
+ ":param nh: equality constraint dimension (default 0)"))
+ .staticmethod("Random")
+ .def("setLQR", &ActionModelLQR::set_LQR,
+ bp::args("self", "A", "B", "Q", "R", "N", "G", "H", "f", "q", "r",
+ "g", "h"),
+ "Modify the LQR action model.\n\n"
+ ":param A: state matrix\n"
+ ":param B: input matrix\n"
+ ":param Q: state weight matrix\n"
+ ":param R: input weight matrix\n"
+ ":param N: state-input weight matrix\n"
+ ":param G: state-input inequality constraint matrix\n"
+ ":param H: state-input equality constraint matrix\n"
+ ":param f: dynamics drift\n"
+ ":param q: state weight vector\n"
+ ":param r: input weight vector\n"
+ ":param g: state-input inequality constraint bias\n"
+ ":param h: state-input equality constraint bias")
+ .add_property("A",
+ bp::make_function(&ActionModelLQR::get_A,
+ bp::return_internal_reference<>()),
+ "state matrix")
+ .add_property("B",
+ bp::make_function(&ActionModelLQR::get_B,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_Fx, "Jacobian of the dynamics")
- .add_property("Fu",
- bp::make_function(&ActionModelLQR::get_Fu,
+ "input matrix")
+ .add_property("f",
+ bp::make_function(&ActionModelLQR::get_f,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_Fu, "Jacobian of the dynamics")
- .add_property("f0",
- bp::make_function(&ActionModelLQR::get_f0,
+ "dynamics drift")
+ .add_property("Q",
+ bp::make_function(&ActionModelLQR::get_Q,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_f0, "dynamics drift")
- .add_property("lx",
- bp::make_function(&ActionModelLQR::get_lx,
+ "state weight matrix")
+ .add_property("R",
+ bp::make_function(&ActionModelLQR::get_R,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_lx, "Jacobian of the cost")
- .add_property("lu",
- bp::make_function(&ActionModelLQR::get_lu,
+ "input weight matrix")
+ .add_property("N",
+ bp::make_function(&ActionModelLQR::get_N,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_lu, "Jacobian of the cost")
- .add_property("Lxx",
- bp::make_function(&ActionModelLQR::get_Lxx,
+ "state-input weight matrix")
+ .add_property("G",
+ bp::make_function(&ActionModelLQR::get_G,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_Lxx, "Hessian of the cost")
- .add_property("Lxu",
- bp::make_function(&ActionModelLQR::get_Lxu,
+ "state-input inequality constraint matrix")
+ .add_property("H",
+ bp::make_function(&ActionModelLQR::get_H,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_Lxu, "Hessian of the cost")
- .add_property("Luu",
- bp::make_function(&ActionModelLQR::get_Luu,
+ "state-input equality constraint matrix")
+ .add_property("q",
+ bp::make_function(&ActionModelLQR::get_q,
bp::return_internal_reference<>()),
- &ActionModelLQR::set_Luu, "Hessian of the cost")
+ "state weight vector")
+ .add_property("r",
+ bp::make_function(&ActionModelLQR::get_r,
+ bp::return_internal_reference<>()),
+ "input weight vector")
+ .add_property("g",
+ bp::make_function(&ActionModelLQR::get_g,
+ bp::return_internal_reference<>()),
+ "state-input inequality constraint bias")
+ .add_property("h",
+ bp::make_function(&ActionModelLQR::get_h,
+ bp::return_internal_reference<>()),
+ "state-input equality constraint bias")
+ // deprecated function
+ .add_property(
+ "Fx",
+ bp::make_function(&ActionModelLQR::get_A,
+ deprecated >(
+ "Deprecated. Use set_LQR.")),
+ &ActionModelLQR::set_Fx, "state matrix")
+ .add_property(
+ "Fu",
+ bp::make_function(&ActionModelLQR::get_B,
+ deprecated >(
+ "Deprecated. Use B.")),
+ bp::make_function(&ActionModelLQR::set_Fu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "input matrix")
+ .add_property(
+ "f0",
+ bp::make_function(&ActionModelLQR::get_f,
+ deprecated >(
+ "Deprecated. Use f.")),
+ bp::make_function(&ActionModelLQR::set_f0,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "dynamics drift")
+ .add_property(
+ "lx",
+ bp::make_function(&ActionModelLQR::get_q,
+ deprecated >(
+ "Deprecated. Use q.")),
+ bp::make_function(&ActionModelLQR::set_lx,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "state weight vector")
+ .add_property(
+ "lu",
+ bp::make_function(&ActionModelLQR::get_r,
+ deprecated >(
+ "Deprecated. Use r.")),
+ bp::make_function(&ActionModelLQR::set_lu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "input weight vector")
+ .add_property(
+ "Lxx",
+ bp::make_function(&ActionModelLQR::get_Q,
+ deprecated >(
+ "Deprecated. Use Q.")),
+ bp::make_function(&ActionModelLQR::set_Lxx,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "state weight matrix")
+ .add_property(
+ "Lxu",
+ bp::make_function(&ActionModelLQR::get_N,
+ deprecated >(
+ "Deprecated. Use N.")),
+ bp::make_function(&ActionModelLQR::set_Lxu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "state-input weight matrix")
+ .add_property(
+ "Luu",
+ bp::make_function(&ActionModelLQR::get_R,
+ deprecated >(
+ "Deprecated. Use R.")),
+ bp::make_function(&ActionModelLQR::set_Luu,
+ deprecated<>("Deprecated. Use set_LQR.")),
+ "input weight matrix")
.def(CopyableVisitor());
boost::python::register_ptr_to_python >();
@@ -113,6 +271,8 @@ void exposeActionLQR() {
"Create LQR data.\n\n"
":param model: LQR action model"))
.def(CopyableVisitor());
+
+#pragma GCC diagnostic pop
}
} // namespace python
diff --git a/bindings/python/crocoddyl/core/activation-base.cpp b/bindings/python/crocoddyl/core/activation-base.cpp
index 683a3a624b..2af98d1296 100644
--- a/bindings/python/crocoddyl/core/activation-base.cpp
+++ b/bindings/python/crocoddyl/core/activation-base.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -26,9 +26,9 @@ void exposeActivationAbstract() {
"value and its derivatives from it. Activation value and its derivatives "
"are computed by\n"
"calc() and calcDiff(), respectively.",
- bp::init(bp::args("self", "nr"),
- "Initialize the activation model.\n\n"
- ":param nr: dimension of the cost-residual vector"))
+ bp::init(bp::args("self", "nr"),
+ "Initialize the activation model.\n\n"
+ ":param nr: dimension of the cost-residual vector"))
.def("calc", pure_virtual(&ActivationModelAbstract_wrap::calc),
bp::args("self", "data", "r"),
"Compute the activation value.\n\n"
diff --git a/bindings/python/crocoddyl/core/activation-base.hpp b/bindings/python/crocoddyl/core/activation-base.hpp
index a586387785..05d18653dc 100644
--- a/bindings/python/crocoddyl/core/activation-base.hpp
+++ b/bindings/python/crocoddyl/core/activation-base.hpp
@@ -26,9 +26,9 @@ class ActivationModelAbstract_wrap
void calc(const boost::shared_ptr& data,
const Eigen::Ref& r) {
if (static_cast(r.size()) != nr_) {
- throw_pretty("Invalid argument: "
- << "r has wrong dimension (it should be " +
- std::to_string(nr_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "r has wrong dimension (it should be " +
+ std::to_string(nr_) + ")");
}
return bp::call(this->get_override("calc").ptr(), data,
(Eigen::VectorXd)r);
@@ -37,9 +37,9 @@ class ActivationModelAbstract_wrap
void calcDiff(const boost::shared_ptr& data,
const Eigen::Ref& r) {
if (static_cast(r.size()) != nr_) {
- throw_pretty("Invalid argument: "
- << "r has wrong dimension (it should be " +
- std::to_string(nr_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "r has wrong dimension (it should be " +
+ std::to_string(nr_) + ")");
}
return bp::call(this->get_override("calcDiff").ptr(), data,
(Eigen::VectorXd)r);
diff --git a/bindings/python/crocoddyl/core/activations/quadratic-flat-exp.cpp b/bindings/python/crocoddyl/core/activations/quadratic-flat-exp.cpp
index 21c23179bb..b371ffcbb4 100644
--- a/bindings/python/crocoddyl/core/activations/quadratic-flat-exp.cpp
+++ b/bindings/python/crocoddyl/core/activations/quadratic-flat-exp.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2020-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2020-2024, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -26,10 +26,11 @@ void exposeActivationQuadFlatExp() {
"A quadratic flat action describes a quadratic flat function that "
"depends on the residual, i.e.\n"
"1 - exp(-||r||^2 / alpha).",
- bp::init(bp::args("self", "nr", "alpha"),
- "Initialize the activation model.\n\n"
- ":param nr: dimension of the cost-residual vector"
- "param alpha: width of quadratic basin near zero"))
+ bp::init(
+ bp::args("self", "nr", "alpha"),
+ "Initialize the activation model.\n\n"
+ ":param nr: dimension of the cost-residual vector"
+ "param alpha: width of quadratic basin near zero"))
.def("calc", &ActivationModelQuadFlatExp::calc,
bp::args("self", "data", "r"),
"Compute the 1 - exp(-||r||^2 / alpha).\n\n"
diff --git a/bindings/python/crocoddyl/core/activations/quadratic-flat-log.cpp b/bindings/python/crocoddyl/core/activations/quadratic-flat-log.cpp
index 090b359c06..5c8979f459 100644
--- a/bindings/python/crocoddyl/core/activations/quadratic-flat-log.cpp
+++ b/bindings/python/crocoddyl/core/activations/quadratic-flat-log.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2020-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2020-2024, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -25,10 +25,11 @@ void exposeActivationQuadFlatLog() {
"A quadratic flat action describes a quadratic flat function that "
"depends on the residual, i.e.\n"
"log(1 + ||r||^2 / alpha).",
- bp::init(bp::args("self", "nr", "alpha"),
- "Initialize the activation model.\n\n"
- ":param nr: dimension of the cost-residual vector"
- "param alpha: width of quadratic basin near zero"))
+ bp::init(
+ bp::args("self", "nr", "alpha"),
+ "Initialize the activation model.\n\n"
+ ":param nr: dimension of the cost-residual vector"
+ "param alpha: width of quadratic basin near zero"))
.def("calc", &ActivationModelQuadFlatLog::calc,
bp::args("self", "data", "r"),
"Compute the log(1 + ||r||^2 / alpha).\n"
diff --git a/bindings/python/crocoddyl/core/activations/quadratic.cpp b/bindings/python/crocoddyl/core/activations/quadratic.cpp
index 1dc8d5389e..62c2654c7a 100644
--- a/bindings/python/crocoddyl/core/activations/quadratic.cpp
+++ b/bindings/python/crocoddyl/core/activations/quadratic.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -26,9 +26,9 @@ void exposeActivationQuad() {
"A quadratic action describes a quadratic function that depends on the "
"residual, i.e.\n"
"0.5 *||r||^2.",
- bp::init(bp::args("self", "nr"),
- "Initialize the activation model.\n\n"
- ":param nr: dimension of the cost-residual vector"))
+ bp::init(bp::args("self", "nr"),
+ "Initialize the activation model.\n\n"
+ ":param nr: dimension of the cost-residual vector"))
.def("calc", &ActivationModelQuad::calc, bp::args("self", "data", "r"),
"Compute the 0.5 * ||r||^2.\n\n"
":param data: activation data\n"
diff --git a/bindings/python/crocoddyl/core/activations/smooth-1norm.cpp b/bindings/python/crocoddyl/core/activations/smooth-1norm.cpp
index 07ba2fa581..7477f0c269 100644
--- a/bindings/python/crocoddyl/core/activations/smooth-1norm.cpp
+++ b/bindings/python/crocoddyl/core/activations/smooth-1norm.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -28,7 +28,7 @@ void exposeActivationSmooth1Norm() {
"sum^nr_{i=0} sqrt{eps + ||ri||^2}, where ri is the scalar residual for "
"the i constraints,\n."
"and nr is the dimension of the residual vector.",
- bp::init >(
+ bp::init >(
bp::args("self", "nr", "eps"),
"Initialize the activation model.\n\n"
":param nr: dimension of the residual vector\n"
diff --git a/bindings/python/crocoddyl/core/activations/smooth-2norm.cpp b/bindings/python/crocoddyl/core/activations/smooth-2norm.cpp
index 0fd6f16706..90e1769e71 100644
--- a/bindings/python/crocoddyl/core/activations/smooth-2norm.cpp
+++ b/bindings/python/crocoddyl/core/activations/smooth-2norm.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2020-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2020-2024, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -27,7 +27,7 @@ void exposeActivationSmooth2Norm() {
"sqrt{eps + sum^nr_{i=0} ||ri||^2}, where ri is the scalar residual for "
"the i constraints,\n."
"and nr is the dimension of the residual vector.",
- bp::init >(
+ bp::init >(
bp::args("self", "nr", "eps"),
"Initialize the activation model.\n\n"
":param nr: dimension of the residual vector\n"
diff --git a/bindings/python/crocoddyl/core/actuation-base.cpp b/bindings/python/crocoddyl/core/actuation-base.cpp
index 8726990351..6471fa08df 100644
--- a/bindings/python/crocoddyl/core/actuation-base.cpp
+++ b/bindings/python/crocoddyl/core/actuation-base.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -28,7 +28,7 @@ void exposeActuationAbstract() {
"The computation of the actuation signal and its partial derivatives are "
"mainly carried out\n"
"inside calc() and calcDiff(), respectively.",
- bp::init, int>(
+ bp::init, std::size_t>(
bp::args("self", "state", "nu"),
"Initialize the actuation model.\n\n"
":param state: state description,\n"
diff --git a/bindings/python/crocoddyl/core/actuation-base.hpp b/bindings/python/crocoddyl/core/actuation-base.hpp
index 9bbd73c256..f0775e39c9 100644
--- a/bindings/python/crocoddyl/core/actuation-base.hpp
+++ b/bindings/python/crocoddyl/core/actuation-base.hpp
@@ -29,14 +29,14 @@ class ActuationModelAbstract_wrap : public ActuationModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return bp::call(this->get_override("calc").ptr(), data,
(Eigen::VectorXd)x, (Eigen::VectorXd)u);
@@ -46,14 +46,14 @@ class ActuationModelAbstract_wrap : public ActuationModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return bp::call(this->get_override("calcDiff").ptr(), data,
(Eigen::VectorXd)x, (Eigen::VectorXd)u);
@@ -63,14 +63,14 @@ class ActuationModelAbstract_wrap : public ActuationModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& tau) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(tau.size()) != state_->get_nv()) {
- throw_pretty("Invalid argument: "
- << "tau has wrong dimension (it should be " +
- std::to_string(state_->get_nv()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "tau has wrong dimension (it should be " +
+ std::to_string(state_->get_nv()) + ")");
}
return bp::call(this->get_override("commands").ptr(), data,
(Eigen::VectorXd)x, (Eigen::VectorXd)tau);
@@ -82,14 +82,14 @@ class ActuationModelAbstract_wrap : public ActuationModelAbstract,
if (boost::python::override torqueTransform =
this->get_override("torqueTransform")) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return bp::call(torqueTransform.ptr(), data, (Eigen::VectorXd)x,
(Eigen::VectorXd)u);
diff --git a/bindings/python/crocoddyl/core/actuation/actuation-squashing.cpp b/bindings/python/crocoddyl/core/actuation/actuation-squashing.cpp
index a5991bdd0c..febb8d234b 100644
--- a/bindings/python/crocoddyl/core/actuation/actuation-squashing.cpp
+++ b/bindings/python/crocoddyl/core/actuation/actuation-squashing.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, University of Edinburgh, IRI: CSIC-UPC
+// Copyright (C) 2019-2024, University of Edinburgh, IRI: CSIC-UPC
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -22,7 +22,7 @@ void exposeActuationSquashing() {
bp::class_ >(
"ActuationSquashingModel", "Class for squashing an actuation model.\n\n",
bp::init,
- boost::shared_ptr, int>(
+ boost::shared_ptr, std::size_t>(
bp::args("self", "actuation", "squashing", "nu"),
"Initialize the actuation model with squashing function.\n\n"
":param actuation: actuation model to be squashed,\n"
diff --git a/bindings/python/crocoddyl/core/actuation/squashing-base.cpp b/bindings/python/crocoddyl/core/actuation/squashing-base.cpp
index 654a2deb25..4b7eb8e6e7 100644
--- a/bindings/python/crocoddyl/core/actuation/squashing-base.cpp
+++ b/bindings/python/crocoddyl/core/actuation/squashing-base.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, University of Edinburgh, IRI: CSIC-UPC,
+// Copyright (C) 2019-2024, University of Edinburgh, IRI: CSIC-UPC,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -27,9 +27,9 @@ void exposeSquashingAbstract() {
"The computation of the output value is done using calc() while its "
"derivative is computed using calcDiff(), "
"respectively.",
- bp::init(bp::args("self", "ns"),
- "Initialize the squashing model. \n\n"
- ":param ns: dimension of the input vector"))
+ bp::init(bp::args("self", "ns"),
+ "Initialize the squashing model. \n\n"
+ ":param ns: dimension of the input vector"))
.def("calc", pure_virtual(&SquashingModelAbstract_wrap::calc),
bp::args("self", "data", "s"),
"Compute the squashing value for a given value of u, "
diff --git a/bindings/python/crocoddyl/core/actuation/squashing/smooth-sat.cpp b/bindings/python/crocoddyl/core/actuation/squashing/smooth-sat.cpp
index 6dbb971f24..79ea76a5f9 100644
--- a/bindings/python/crocoddyl/core/actuation/squashing/smooth-sat.cpp
+++ b/bindings/python/crocoddyl/core/actuation/squashing/smooth-sat.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, University of Edinburgh, IRI: CSIC-UPC
+// Copyright (C) 2019-2024, University of Edinburgh, IRI: CSIC-UPC
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -21,7 +21,7 @@ void exposeSquashingSmoothSat() {
bp::class_ >(
"SquashingModelSmoothSat", "Smooth Sat squashing model",
- bp::init(
+ bp::init(
bp::args("self", "u_lb", "u_ub", "ns"),
"Initialize the squashing model. \n\n"
":param u_lb: output lower bound"
diff --git a/bindings/python/crocoddyl/core/constraint-base.cpp b/bindings/python/crocoddyl/core/constraint-base.cpp
index dda1e0ceae..f7c1404a00 100644
--- a/bindings/python/crocoddyl/core/constraint-base.cpp
+++ b/bindings/python/crocoddyl/core/constraint-base.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2020-2023, University of Edinburgh, Heriot-Watt University
+// Copyright (C) 2020-2024, University of Edinburgh, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
@@ -42,19 +42,28 @@ void exposeConstraintAbstract() {
":param ng: number of inequality constraints\n"
":param nh: number of equality constraints"))
.def(bp::init, std::size_t, std::size_t,
- std::size_t>(
- bp::args("self", "state", "nu", "ng", "nh"),
+ std::size_t, bp::optional >(
+ bp::args("self", "state", "nu", "ng", "nh", "T_const"),
"Initialize the constraint model.\n\n"
":param state: state description\n"
":param nu: dimension of control vector (default state.nv)\n"
":param ng: number of inequality constraints\n"
- ":param nh: number of equality constraints"))
- .def(bp::init, std::size_t, std::size_t>(
- bp::args("self", "state", "ng", "nh"),
+ ":param nh: number of equality constraints\n"
+ ":param T_const: True if this is a constraint in both running and "
+ "terminal nodes.\n"
+ " False if it is a constraint on running nodes only "
+ "(default true)"))
+ .def(bp::init, std::size_t, std::size_t,
+ bp::optional >(
+ bp::args("self", "state", "ng", "nh", "T_const"),
"Initialize the constraint model.\n\n"
":param state: state description\n"
":param ng: number of inequality constraints\n"
- ":param nh: number of equality constraints"))
+ ":param nh: number of equality constraints\n"
+ ":param T_const: True if this is a constraint in both running and "
+ "terminal nodes.\n"
+ " False if it is a constraint on running nodes only "
+ "(default true)"))
.def("calc", pure_virtual(&ConstraintModelAbstract_wrap::calc),
bp::args("self", "data", "x", "u"),
"Compute the constraint value.\n\n"
@@ -141,6 +150,10 @@ void exposeConstraintAbstract() {
.add_property("nh",
bp::make_function(&ConstraintModelAbstract_wrap::get_nh),
"number of equality constraints")
+ .add_property(
+ "T_constraint",
+ bp::make_function(&ConstraintModelAbstract_wrap::get_T_constraint),
+ "True if the constraint is imposed in terminal nodes as well")
.def(PrintableVisitor());
bp::register_ptr_to_python >();
diff --git a/bindings/python/crocoddyl/core/constraint-base.hpp b/bindings/python/crocoddyl/core/constraint-base.hpp
index aba1010d14..0ffa0aaa83 100644
--- a/bindings/python/crocoddyl/core/constraint-base.hpp
+++ b/bindings/python/crocoddyl/core/constraint-base.hpp
@@ -35,15 +35,16 @@ class ConstraintModelAbstract_wrap
ConstraintModelAbstract_wrap(boost::shared_ptr state,
const std::size_t nu, const std::size_t ng,
- const std::size_t nh)
- : ConstraintModelAbstract(state, nu, ng, nh),
+ const std::size_t nh, const bool T_const = true)
+ : ConstraintModelAbstract(state, nu, ng, nh, T_const),
bp::wrapper() {
unone_ = NAN * MathBase::VectorXs::Ones(nu);
}
ConstraintModelAbstract_wrap(boost::shared_ptr state,
- const std::size_t ng, const std::size_t nh)
- : ConstraintModelAbstract(state, ng, nh) {
+ const std::size_t ng, const std::size_t nh,
+ const bool T_const = true)
+ : ConstraintModelAbstract(state, ng, nh, T_const) {
unone_ = NAN * MathBase::VectorXs::Ones(nu_);
}
@@ -51,14 +52,14 @@ class ConstraintModelAbstract_wrap
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calc").ptr(), data,
@@ -73,14 +74,14 @@ class ConstraintModelAbstract_wrap
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calcDiff").ptr(), data,
diff --git a/bindings/python/crocoddyl/core/constraints/constraint-manager.cpp b/bindings/python/crocoddyl/core/constraints/constraint-manager.cpp
index ae64765664..ed51ab6fc7 100644
--- a/bindings/python/crocoddyl/core/constraints/constraint-manager.cpp
+++ b/bindings/python/crocoddyl/core/constraints/constraint-manager.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2020-2023, University of Edinburgh, Heriot-Watt University
+// Copyright (C) 2020-2024, University of Edinburgh, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
@@ -28,6 +28,10 @@ namespace python {
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
ConstraintModelManager_addConstraint_wrap,
ConstraintModelManager::addConstraint, 2, 3)
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(ConstraintDataManager_resizeConst_wrap,
+ ConstraintDataManager::resize, 1, 2)
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(ConstraintDataManager_resize_wrap,
+ ConstraintDataManager::resize, 2, 3)
void exposeConstraintManager() {
// Register custom converters between std::map and Python dict
@@ -169,6 +173,12 @@ void exposeConstraintManager() {
"number of active inequality constraints")
.add_property("nh", bp::make_function(&ConstraintModelManager::get_nh),
"number of active equality constraints")
+ .add_property("ng_T",
+ bp::make_function(&ConstraintModelManager::get_ng_T),
+ "number of active inequality terminal constraints")
+ .add_property("nh_T",
+ bp::make_function(&ConstraintModelManager::get_nh_T),
+ "number of active equality terminal constraints")
.add_property(
"active_set",
bp::make_function(&ConstraintModelManager::get_active_set,
@@ -214,23 +224,41 @@ void exposeConstraintManager() {
bp::args("self", "data"),
"Share memory with a given action data\n\n"
":param model: action data that we want to share memory")
+ .def("resize", &ConstraintDataManager::resize,
+ bp::with_custodian_and_ward_postcall<0, 1>(),
+ ConstraintDataManager_resizeConst_wrap(
+ bp::args("self", "model", "running_node"),
+ "Resize the data given differential action data\n\n"
+ ":param model: constraint manager model that defines how to "
+ "resize "
+ "the data\n"
+ ":param running_node: true if we are resizing for a running "
+ "node, false for terminal ones (default true)"))
.def("resize",
&ConstraintDataManager::resize,
bp::with_custodian_and_ward_postcall<0, 2>(),
- bp::args("self", "model", "data"),
- "Resize the data given differential action data\n\n"
- ":param model: differential action model that defines how to resize "
- "the data\n"
- ":param data: differential action data that we want to resize")
- .def("resize",
- &ConstraintDataManager::resize,
- bp::with_custodian_and_ward_postcall<0, 2>(),
- bp::args("self", "model", "data"),
- "Resize the data given action data\n\n"
- ":param model: action model that defines how to resize the data\n"
- ":param data: action data that we want to resize")
+ ConstraintDataManager_resize_wrap(
+ bp::args("self", "model", "data", "running_node"),
+ "Resize the data given differential action data\n\n"
+ ":param model: differential action model that defines how to "
+ "resize "
+ "the data\n"
+ ":param data: differential action data that we want to resize\n"
+ ":param running_node: true if we are resizing for a running "
+ "node, false for terminal ones (default true)"))
+ .def(
+ "resize",
+ &ConstraintDataManager::resize,
+ bp::with_custodian_and_ward_postcall<0, 2>(),
+ ConstraintDataManager_resize_wrap(
+ bp::args("self", "model", "data", "running_node"),
+ "Resize the data given action data\n\n"
+ ":param model: action model that defines how to resize the data\n"
+ ":param data: action data that we want to resize\n"
+ ":param running_node: true if we are resizing for a running "
+ "node, false for terminal ones (default true)"))
.add_property(
"constraints",
bp::make_getter(&ConstraintDataManager::constraints,
diff --git a/bindings/python/crocoddyl/core/constraints/residual.cpp b/bindings/python/crocoddyl/core/constraints/residual.cpp
index ee80df1446..cfea9f6bce 100644
--- a/bindings/python/crocoddyl/core/constraints/residual.cpp
+++ b/bindings/python/crocoddyl/core/constraints/residual.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2021-2023, University of Edinburgh, Heriot-Watt University
+// Copyright (C) 2021-2024, University of Edinburgh, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
@@ -23,21 +23,26 @@ void exposeConstraintResidual() {
"vector and its bounds.",
bp::init,
boost::shared_ptr, Eigen::VectorXd,
- Eigen::VectorXd>(
- bp::args("self", "state", "residual", "lower", "upper"),
+ Eigen::VectorXd, bp::optional >(
+ bp::args("self", "state", "residual", "lower", "upper", "T_act"),
"Initialize the residual constraint model as an inequality "
"constraint.\n\n"
":param state: state description\n"
":param residual: residual model\n"
":param lower: lower bound\n"
- ":param upper: upper bound"))
+ ":param upper: upper bound\n"
+ ":param T_act: false if we want to deactivate the residual at the "
+ "terminal node (default true)"))
.def(bp::init,
- boost::shared_ptr >(
- bp::args("self", "state", "residual"),
+ boost::shared_ptr,
+ bp::optional >(
+ bp::args("self", "state", "residual", "T_act"),
"Initialize the residual constraint model as an equality "
"constraint.\n\n"
":param state: state description\n"
- ":param residual: residual model"))
+ ":param residual: residual model\n"
+ ":param T_act: false if we want to deactivate the residual at the "
+ "terminal node (default true)"))
.def&,
const Eigen::Ref&,
diff --git a/bindings/python/crocoddyl/core/control-base.hpp b/bindings/python/crocoddyl/core/control-base.hpp
index 3231009996..8b54b54200 100644
--- a/bindings/python/crocoddyl/core/control-base.hpp
+++ b/bindings/python/crocoddyl/core/control-base.hpp
@@ -17,6 +17,13 @@
namespace crocoddyl {
namespace python {
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
+ ControlParametrizationModelAbstract_multiplyByJacobian_J_wrap,
+ ControlParametrizationModelAbstract::multiplyByJacobian_J, 2, 3)
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
+ ControlParametrizationModelAbstract_multiplyJacobianTransposeBy_J_wrap,
+ ControlParametrizationModelAbstract::multiplyJacobianTransposeBy_J, 2, 3)
+
class ControlParametrizationModelAbstract_wrap
: public ControlParametrizationModelAbstract,
public bp::wrapper {
@@ -28,9 +35,9 @@ class ControlParametrizationModelAbstract_wrap
void calc(const boost::shared_ptr& data,
double t, const Eigen::Ref& u) const {
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return bp::call(this->get_override("calc").ptr(), data, t,
(Eigen::VectorXd)u);
@@ -40,9 +47,9 @@ class ControlParametrizationModelAbstract_wrap
const boost::shared_ptr& data,
double t, const Eigen::Ref& u) const {
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return bp::call(this->get_override("calcDiff").ptr(), data, t,
(Eigen::VectorXd)u);
@@ -51,9 +58,9 @@ class ControlParametrizationModelAbstract_wrap
void params(const boost::shared_ptr& data,
double t, const Eigen::Ref& w) const {
if (static_cast(w.size()) != nw_) {
- throw_pretty("Invalid argument: "
- << "w has wrong dimension (it should be " +
- std::to_string(nw_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "w has wrong dimension (it should be " +
+ std::to_string(nw_) + ")");
}
return bp::call(this->get_override("params").ptr(), data, t,
(Eigen::VectorXd)w);
diff --git a/bindings/python/crocoddyl/core/controls/poly-one.cpp b/bindings/python/crocoddyl/core/controls/poly-one.cpp
index d335fafb25..033423e767 100644
--- a/bindings/python/crocoddyl/core/controls/poly-one.cpp
+++ b/bindings/python/crocoddyl/core/controls/poly-one.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2021-2023, University of Edinburgh, University of Trento
+// Copyright (C) 2021-2025, University of Edinburgh, University of Trento
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -73,27 +73,37 @@ void exposeControlParametrizationPolyOne() {
"parameters (dim control.nu).")
.def("multiplyByJacobian",
&ControlParametrizationModelPolyOne::multiplyByJacobian_J,
- bp::args("self", "data", "A"),
- "Compute the product between the given matrix A and the derivative "
- "of the control with respect to the "
- "parameters.\n\n"
- "It assumes that calc has been run first.\n"
- ":param data: control-parametrization data\n"
- ":param A: matrix to multiply (dim na x control.nw)\n"
- ":return Product between A and the partial derivative of the value "
- "function (dim na x control.nu)")
- .def("multiplyJacobianTransposeBy",
- &ControlParametrizationModelPolyOne::multiplyJacobianTransposeBy_J,
- bp::args("self", "data", "A"),
- "Compute the product between the transpose of the derivative of the "
- "control with respect to the parameters\n"
- "and a given matrix A.\n\n"
- "It assumes that calc has been run first.\n"
- ":param data: control-parametrization data\n"
- ":param A: matrix to multiply (dim control.nw x na)\n"
- ":return Product between the partial derivative of the value "
- "function (transposed) and A (dim control.nu x "
- "na)")
+ ControlParametrizationModelAbstract_multiplyByJacobian_J_wrap(
+ bp::args("self", "data", "A", "op"),
+ "Compute the product between the given matrix A and the "
+ "derivative "
+ "of the control with respect to the "
+ "parameters.\n\n"
+ "It assumes that calc has been run first.\n"
+ ":param data: control-parametrization data\n"
+ ":param A: matrix to multiply (dim na x control.nw)\n"
+ ":op assignment operator which sets, adds, or removes the given "
+ "results\n"
+ ":return Product between A and the partial derivative of the "
+ "value "
+ "function (dim na x control.nu)"))
+ .def(
+ "multiplyJacobianTransposeBy",
+ &ControlParametrizationModelPolyOne::multiplyJacobianTransposeBy_J,
+ ControlParametrizationModelAbstract_multiplyJacobianTransposeBy_J_wrap(
+ bp::args("self", "data", "A", "op"),
+ "Compute the product between the transpose of the derivative of "
+ "the "
+ "control with respect to the parameters\n"
+ "and a given matrix A.\n\n"
+ "It assumes that calc has been run first.\n"
+ ":param data: control-parametrization data\n"
+ ":param A: matrix to multiply (dim control.nw x na)\n"
+ ":op assignment operator which sets, adds, or removes the given "
+ "results\n"
+ ":return Product between the partial derivative of the value "
+ "function (transposed) and A (dim control.nu x "
+ "na)"))
.def(CopyableVisitor());
boost::python::register_ptr_to_python<
diff --git a/bindings/python/crocoddyl/core/controls/poly-two-rk.cpp b/bindings/python/crocoddyl/core/controls/poly-two-rk.cpp
index 29043c864d..b9e96f6886 100644
--- a/bindings/python/crocoddyl/core/controls/poly-two-rk.cpp
+++ b/bindings/python/crocoddyl/core/controls/poly-two-rk.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2021-2023, University of Edinburgh, University of Trento
+// Copyright (C) 2021-2025, University of Edinburgh, University of Trento
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -79,27 +79,36 @@ void exposeControlParametrizationPolyTwoRK() {
"parameters (dim control.nu)")
.def("multiplyByJacobian",
&ControlParametrizationModelPolyTwoRK::multiplyByJacobian_J,
- bp::args("self", "data", "A"),
- "Compute the product between the given matrix A and the derivative "
- "of the control with respect to the "
- "parameters.\n\n"
- "It assumes that calc has been run first.\n"
- ":param data: poly-two-rk data\n"
- ":param A: matrix to multiply (dim na x control.nw)\n"
- ":return Product between A and the partial derivative of the "
- "control (dim na x control.nu)")
- .def("multiplyJacobianTransposeBy",
- &ControlParametrizationModelPolyTwoRK::multiplyJacobianTransposeBy_J,
- bp::args("self", "data", "A"),
- "Compute the product between the transpose of the derivative of the "
- "control with respect to the parameters\n"
- "and a given matrix A.\n\n"
- "It assumes that calc has been run first.\n"
- ":param data: poly-two-rk data\n"
- ":param A: matrix to multiply (dim control.nw x na)\n"
- ":return Product between the partial derivative of the control "
- "(transposed) and A (dim control.nu x "
- "na)")
+ ControlParametrizationModelAbstract_multiplyByJacobian_J_wrap(
+ bp::args("self", "data", "A", "op"),
+ "Compute the product between the given matrix A and the "
+ "derivative "
+ "of the control with respect to the "
+ "parameters.\n\n"
+ "It assumes that calc has been run first.\n"
+ ":param data: poly-two-rk data\n"
+ ":param A: matrix to multiply (dim na x control.nw)\n"
+ ":op assignment operator which sets, adds, or removes the given "
+ "results\n"
+ ":return Product between A and the partial derivative of the "
+ "control (dim na x control.nu)"))
+ .def(
+ "multiplyJacobianTransposeBy",
+ &ControlParametrizationModelPolyTwoRK::multiplyJacobianTransposeBy_J,
+ ControlParametrizationModelAbstract_multiplyJacobianTransposeBy_J_wrap(
+ bp::args("self", "data", "A", "op"),
+ "Compute the product between the transpose of the derivative of "
+ "the "
+ "control with respect to the parameters\n"
+ "and a given matrix A.\n\n"
+ "It assumes that calc has been run first.\n"
+ ":param data: poly-two-rk data\n"
+ ":param A: matrix to multiply (dim control.nw x na)\n"
+ ":op assignment operator which sets, adds, or removes the given "
+ "results\n"
+ ":return Product between the partial derivative of the control "
+ "(transposed) and A (dim control.nu x "
+ "na)"))
.def(CopyableVisitor());
boost::python::register_ptr_to_python<
diff --git a/bindings/python/crocoddyl/core/controls/poly-zero.cpp b/bindings/python/crocoddyl/core/controls/poly-zero.cpp
index 0a22e1ca64..a5ae2fe306 100644
--- a/bindings/python/crocoddyl/core/controls/poly-zero.cpp
+++ b/bindings/python/crocoddyl/core/controls/poly-zero.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2021-2023, University of Edinburgh, University of Trento
+// Copyright (C) 2021-2025, University of Edinburgh, University of Trento
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -72,27 +72,37 @@ void exposeControlParametrizationPolyZero() {
"parameters (dim control.nu)")
.def("multiplyByJacobian",
&ControlParametrizationModelPolyZero::multiplyByJacobian_J,
- bp::args("self", "data", "A"),
- "Compute the product between the given matrix A and the derivative "
- "of the control with respect to the "
- "parameters.\n\n"
- "It assumes that calc has been run first.\n"
- ":param data: control-parametrization data\n"
- ":param A: matrix to multiply (dim na x control.nw)\n"
- ":return Product between A and the partial derivative of the value "
- "function (dim na x control.nu)")
- .def("multiplyJacobianTransposeBy",
- &ControlParametrizationModelPolyZero::multiplyJacobianTransposeBy_J,
- bp::args("self", "data", "A"),
- "Compute the product between the transpose of the derivative of the "
- "control with respect to the parameters\n"
- "and a given matrix A.\n\n"
- "It assumes that calc has been run first.\n"
- ":param data: control-parametrization data\n"
- ":param A: matrix to multiply (dim control.nw x na)\n"
- ":return Product between the partial derivative of the value "
- "function (transposed) and A (dim control.nu x "
- "na)")
+ ControlParametrizationModelAbstract_multiplyByJacobian_J_wrap(
+ bp::args("self", "data", "A", "op"),
+ "Compute the product between the given matrix A and the "
+ "derivative "
+ "of the control with respect to the "
+ "parameters.\n\n"
+ "It assumes that calc has been run first.\n"
+ ":param data: control-parametrization data\n"
+ ":param A: matrix to multiply (dim na x control.nw)\n"
+ ":op assignment operator which sets, adds, or removes the given "
+ "results\n"
+ ":return Product between A and the partial derivative of the "
+ "value "
+ "function (dim na x control.nu)"))
+ .def(
+ "multiplyJacobianTransposeBy",
+ &ControlParametrizationModelPolyZero::multiplyJacobianTransposeBy_J,
+ ControlParametrizationModelAbstract_multiplyJacobianTransposeBy_J_wrap(
+ bp::args("self", "data", "A", "op"),
+ "Compute the product between the transpose of the derivative of "
+ "the "
+ "control with respect to the parameters\n"
+ "and a given matrix A.\n\n"
+ "It assumes that calc has been run first.\n"
+ ":param data: control-parametrization data\n"
+ ":param A: matrix to multiply (dim control.nw x na)\n"
+ ":op assignment operator which sets, adds, or removes the given "
+ "results\n"
+ ":return Product between the partial derivative of the value "
+ "function (transposed) and A (dim control.nu x "
+ "na)"))
.def(CopyableVisitor());
}
diff --git a/bindings/python/crocoddyl/core/cost-base.hpp b/bindings/python/crocoddyl/core/cost-base.hpp
index 6cda2e1db7..540d71e81c 100644
--- a/bindings/python/crocoddyl/core/cost-base.hpp
+++ b/bindings/python/crocoddyl/core/cost-base.hpp
@@ -66,14 +66,14 @@ class CostModelAbstract_wrap : public CostModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calc").ptr(), data,
@@ -88,14 +88,14 @@ class CostModelAbstract_wrap : public CostModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calcDiff").ptr(), data,
diff --git a/bindings/python/crocoddyl/core/diff-action-base.cpp b/bindings/python/crocoddyl/core/diff-action-base.cpp
index ce1ce07b39..0a3bddc050 100644
--- a/bindings/python/crocoddyl/core/diff-action-base.cpp
+++ b/bindings/python/crocoddyl/core/diff-action-base.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
+// Copyright (C) 2019-2024, LAAS-CNRS, University of Edinburgh,
// University of Oxford, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -44,15 +44,18 @@ void exposeDifferentialActionAbstract() {
"computations are\n"
"mainly carried out inside calc() and calcDiff(), respectively.",
bp::init, std::size_t,
- bp::optional >(
- bp::args("self", "state", "nu", "nr", "ng", "nh"),
+ bp::optional >(
+ bp::args("self", "state", "nu", "nr", "ng", "nh", "ng_T", "nh_T"),
"Initialize the differential action model.\n\n"
"We can also describe autonomous systems by setting nu = 0.\n"
":param state: state\n"
":param nu: dimension of control vector\n"
":param nr: dimension of cost-residual vector (default 1)\n"
":param ng: number of inequality constraints (default 0)\n"
- ":param nh: number of equality constraints (default 0)"))
+ ":param nh: number of equality constraints (default 0)\n"
+ ":param ng_T: number of inequality terminal constraints (default 0)\n"
+ ":param nh_T: number of equality terminal constraints (default 0)"))
.def("calc", pure_virtual(&DifferentialActionModelAbstract_wrap::calc),
bp::args("self", "data", "x", "u"),
"Compute the system acceleration and cost value.\n\n"
@@ -139,6 +142,14 @@ void exposeDifferentialActionAbstract() {
"nh",
bp::make_function(&DifferentialActionModelAbstract_wrap::get_nh),
"number of equality constraints")
+ .add_property(
+ "ng_T",
+ bp::make_function(&DifferentialActionModelAbstract_wrap::get_ng_T),
+ "number of inequality terminal constraints")
+ .add_property(
+ "nh_T",
+ bp::make_function(&DifferentialActionModelAbstract_wrap::get_nh_T),
+ "number of equality terminal constraints")
.add_property(
"state",
bp::make_function(&DifferentialActionModelAbstract_wrap::get_state,
diff --git a/bindings/python/crocoddyl/core/diff-action-base.hpp b/bindings/python/crocoddyl/core/diff-action-base.hpp
index f9e67beb42..3ed5acec4c 100644
--- a/bindings/python/crocoddyl/core/diff-action-base.hpp
+++ b/bindings/python/crocoddyl/core/diff-action-base.hpp
@@ -28,8 +28,10 @@ class DifferentialActionModelAbstract_wrap
const std::size_t nu,
const std::size_t nr = 1,
const std::size_t ng = 0,
- const std::size_t nh = 0)
- : DifferentialActionModelAbstract(state, nu, nr, ng, nh),
+ const std::size_t nh = 0,
+ const std::size_t ng_T = 0,
+ const std::size_t nh_T = 0)
+ : DifferentialActionModelAbstract(state, nu, nr, ng, nh, ng_T, nh_T),
bp::wrapper() {
unone_ = NAN * MathBase::VectorXs::Ones(nu);
}
@@ -38,14 +40,14 @@ class DifferentialActionModelAbstract_wrap
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calc").ptr(), data,
@@ -60,14 +62,14 @@ class DifferentialActionModelAbstract_wrap
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calcDiff").ptr(), data,
@@ -100,9 +102,9 @@ class DifferentialActionModelAbstract_wrap
u = bp::call(quasiStatic.ptr(), data, (Eigen::VectorXd)x,
maxiter, tol);
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return;
}
diff --git a/bindings/python/crocoddyl/core/integ-action-base.hpp b/bindings/python/crocoddyl/core/integ-action-base.hpp
index 65385235b3..c221d43bac 100644
--- a/bindings/python/crocoddyl/core/integ-action-base.hpp
+++ b/bindings/python/crocoddyl/core/integ-action-base.hpp
@@ -38,14 +38,14 @@ class IntegratedActionModelAbstract_wrap
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return bp::call(this->get_override("calc").ptr(), data,
(Eigen::VectorXd)x, (Eigen::VectorXd)u);
@@ -55,14 +55,14 @@ class IntegratedActionModelAbstract_wrap
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
return bp::call(this->get_override("calcDiff").ptr(), data,
(Eigen::VectorXd)x, (Eigen::VectorXd)u);
diff --git a/bindings/python/crocoddyl/core/residual-base.hpp b/bindings/python/crocoddyl/core/residual-base.hpp
index 26efacd239..ecab0b1d54 100644
--- a/bindings/python/crocoddyl/core/residual-base.hpp
+++ b/bindings/python/crocoddyl/core/residual-base.hpp
@@ -48,14 +48,14 @@ class ResidualModelAbstract_wrap : public ResidualModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calc").ptr(), data,
@@ -70,14 +70,14 @@ class ResidualModelAbstract_wrap : public ResidualModelAbstract,
const Eigen::Ref& x,
const Eigen::Ref& u) {
if (static_cast(x.size()) != state_->get_nx()) {
- throw_pretty("Invalid argument: "
- << "x has wrong dimension (it should be " +
- std::to_string(state_->get_nx()) + ")");
+ throw_pretty(
+ "Invalid argument: " << "x has wrong dimension (it should be " +
+ std::to_string(state_->get_nx()) + ")");
}
if (static_cast(u.size()) != nu_) {
- throw_pretty("Invalid argument: "
- << "u has wrong dimension (it should be " +
- std::to_string(nu_) + ")");
+ throw_pretty(
+ "Invalid argument: " << "u has wrong dimension (it should be " +
+ std::to_string(nu_) + ")");
}
if (std::isnan(u.lpNorm())) {
return bp::call(this->get_override("calcDiff").ptr(), data,
diff --git a/bindings/python/crocoddyl/core/solvers/box-ddp.cpp b/bindings/python/crocoddyl/core/solvers/box-ddp.cpp
index 1d66603dd8..8d21e38861 100644
--- a/bindings/python/crocoddyl/core/solvers/box-ddp.cpp
+++ b/bindings/python/crocoddyl/core/solvers/box-ddp.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh
+// Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -27,10 +27,12 @@ void exposeSolverBoxDDP() {
bp::args("self", "problem"),
"Initialize the vector dimension.\n\n"
":param problem: shooting problem."))
- .add_property("Quu_inv",
- make_function(&SolverBoxDDP::get_Quu_inv,
- bp::return_internal_reference<>()),
- "inverse of the Quu computed by the box QP")
+ .add_property(
+ "Quu_inv",
+ make_function(
+ &SolverBoxDDP::get_Quu_inv,
+ bp::return_value_policy()),
+ "inverse of the Quu computed by the box QP")
.def(CopyableVisitor());
}
diff --git a/bindings/python/crocoddyl/core/solvers/box-fddp.cpp b/bindings/python/crocoddyl/core/solvers/box-fddp.cpp
index c69ba5b27e..bb557a579b 100644
--- a/bindings/python/crocoddyl/core/solvers/box-fddp.cpp
+++ b/bindings/python/crocoddyl/core/solvers/box-fddp.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, University of Edinburgh, Heriot-Watt University
+// Copyright (C) 2019-2025, University of Edinburgh, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
@@ -26,10 +26,12 @@ void exposeSolverBoxFDDP() {
bp::args("self", "problem"),
"Initialize the vector dimension.\n\n"
":param problem: shooting problem."))
- .add_property("Quu_inv",
- make_function(&SolverBoxFDDP::get_Quu_inv,
- bp::return_internal_reference<>()),
- "inverse of the Quu computed by the box QP")
+ .add_property(
+ "Quu_inv",
+ make_function(
+ &SolverBoxFDDP::get_Quu_inv,
+ bp::return_value_policy()),
+ "inverse of the Quu computed by the box QP")
.def(CopyableVisitor());
}
diff --git a/bindings/python/crocoddyl/core/solvers/ddp.cpp b/bindings/python/crocoddyl/core/solvers/ddp.cpp
index f7458e2f26..986ad7a0ee 100644
--- a/bindings/python/crocoddyl/core/solvers/ddp.cpp
+++ b/bindings/python/crocoddyl/core/solvers/ddp.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
+// Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -92,7 +92,7 @@ void exposeSolverDDP() {
"Return a sum of positive parameters whose sum quantifies the DDP "
"termination.")
.def("expectedImprovement", &SolverDDP::expectedImprovement,
- bp::return_value_policy(),
+ bp::return_value_policy(),
bp::args("self"),
"Return two scalars denoting the quadratic improvement model\n\n"
"For computing the expected improvement, you need to compute first\n"
@@ -131,48 +131,57 @@ void exposeSolverDDP() {
":param model: action model in the given time instance")
.add_property(
"Vxx",
- make_function(&SolverDDP::get_Vxx,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_Vxx,
+ bp::return_value_policy()),
"Vxx")
.add_property(
"Vx",
- make_function(&SolverDDP::get_Vx,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_Vx,
+ bp::return_value_policy()),
"Vx")
.add_property(
"Qxx",
- make_function(&SolverDDP::get_Qxx,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_Qxx,
+ bp::return_value_policy()),
"Qxx")
.add_property(
"Qxu",
- make_function(&SolverDDP::get_Qxu,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_Qxu,
+ bp::return_value_policy()),
"Qxu")
.add_property(
"Quu",
- make_function(&SolverDDP::get_Quu,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_Quu,
+ bp::return_value_policy()),
"Quu")
.add_property(
"Qx",
- make_function(&SolverDDP::get_Qx,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_Qx,
+ bp::return_value_policy()),
"Qx")
.add_property(
"Qu",
- make_function(&SolverDDP::get_Qu,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_Qu,
+ bp::return_value_policy()),
"Qu")
.add_property(
"K",
- make_function(&SolverDDP::get_K,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_K,
+ bp::return_value_policy()),
"K")
.add_property(
"k",
- make_function(&SolverDDP::get_k,
- bp::return_value_policy()),
+ make_function(
+ &SolverDDP::get_k,
+ bp::return_value_policy()),
"k")
.add_property(
"reg_incFactor", bp::make_function(&SolverDDP::get_reg_incfactor),
@@ -231,12 +240,13 @@ void exposeSolverDDP() {
bp::make_function(&SolverDDP::set_th_gaptol,
deprecated<>("Deprecated. Use th_gapTol")),
"threshold for accepting a gap as non-zero")
- .add_property("alphas",
- bp::make_function(
- &SolverDDP::get_alphas,
- bp::return_value_policy()),
- bp::make_function(&SolverDDP::set_alphas),
- "list of step length (alpha) values")
+ .add_property(
+ "alphas",
+ bp::make_function(
+ &SolverDDP::get_alphas,
+ bp::return_value_policy()),
+ bp::make_function(&SolverDDP::set_alphas),
+ "list of step length (alpha) values")
.def(CopyableVisitor());
}
diff --git a/bindings/python/crocoddyl/core/solvers/fddp.cpp b/bindings/python/crocoddyl/core/solvers/fddp.cpp
index 923d7655cf..d0c871ecb0 100644
--- a/bindings/python/crocoddyl/core/solvers/fddp.cpp
+++ b/bindings/python/crocoddyl/core/solvers/fddp.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
+// Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
@@ -68,7 +68,7 @@ void exposeSolverFDDP() {
":returns the optimal trajectory xopt, uopt and a boolean that "
"describes if convergence was reached."))
.def("updateExpectedImprovement", &SolverFDDP::updateExpectedImprovement,
- bp::return_value_policy(),
+ bp::return_value_policy(),
bp::args("self"), "Update the expected improvement model\n\n")
.add_property("th_acceptNegStep",
bp::make_function(&SolverFDDP::get_th_acceptnegstep),
diff --git a/bindings/python/crocoddyl/core/solvers/intro.cpp b/bindings/python/crocoddyl/core/solvers/intro.cpp
index 195e11190e..8e54cffa41 100644
--- a/bindings/python/crocoddyl/core/solvers/intro.cpp
+++ b/bindings/python/crocoddyl/core/solvers/intro.cpp
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
-// Copyright (C) 2021-2023, Heriot-Watt University, University of Edinburgh
+// Copyright (C) 2021-2025, Heriot-Watt University, University of Edinburgh
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
@@ -88,58 +88,69 @@ void exposeSolverIntro() {
"zero when solve is called.")
.add_property(
"Hu_rank",
- make_function(&SolverIntro::get_Hu_rank,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_Hu_rank,
+ bp::return_value_policy()),
"rank of Hu")
.add_property(
"YZ",
- make_function(&SolverIntro::get_YZ,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_YZ,
+ bp::return_value_policy()),
"span and kernel of Hu")
.add_property(
"Qzz",
- make_function(&SolverIntro::get_Qzz,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_Qzz,
+ bp::return_value_policy()),
"Qzz")
.add_property(
"Qxz",
- make_function(&SolverIntro::get_Qxz,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_Qxz,
+ bp::return_value_policy()),
"Qxz")
.add_property(
"Quz",
- make_function(&SolverIntro::get_Quz,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_Quz,
+ bp::return_value_policy()),
"Quz")
.add_property(
"Qz",
- make_function(&SolverIntro::get_Qz,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_Qz,
+ bp::return_value_policy()),
"Qz")
.add_property(
"Hy",
- make_function(&SolverIntro::get_Hy,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_Hy,
+ bp::return_value_policy()),
"Hy")
.add_property(
"Kz",
- make_function(&SolverIntro::get_Kz,
- bp::return_value_policy()),
+ make_function(
+ &SolverIntro::get_Kz,
+ bp::return_value_policy()),
"Kz")
.add_property(
"kz",
- make_function(&SolverIntro::get_kz,
- bp::return_value_policy