Skip to content

Commit

Permalink
[python] Supported default arguments in control's multiplyByJacobian …
Browse files Browse the repository at this point in the history
…and multiplyJacobianTransposeBy
  • Loading branch information
cmastalli committed Feb 4, 2025
1 parent efbcca8 commit c0348fb
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 75 deletions.
7 changes: 7 additions & 0 deletions bindings/python/crocoddyl/core/control-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ControlParametrizationModelAbstract> {
Expand Down
56 changes: 31 additions & 25 deletions bindings/python/crocoddyl/core/controls/poly-one.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,37 @@ void exposeControlParametrizationPolyOne() {
"parameters (dim control.nu).")
.def("multiplyByJacobian",
&ControlParametrizationModelPolyOne::multiplyByJacobian_J,
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,
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)")
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<ControlParametrizationModelPolyOne>());

boost::python::register_ptr_to_python<
Expand Down
55 changes: 30 additions & 25 deletions bindings/python/crocoddyl/core/controls/poly-two-rk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,36 @@ void exposeControlParametrizationPolyTwoRK() {
"parameters (dim control.nu)")
.def("multiplyByJacobian",
&ControlParametrizationModelPolyTwoRK::multiplyByJacobian_J,
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,
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)")
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<ControlParametrizationModelPolyTwoRK>());

boost::python::register_ptr_to_python<
Expand Down
56 changes: 31 additions & 25 deletions bindings/python/crocoddyl/core/controls/poly-zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,37 @@ void exposeControlParametrizationPolyZero() {
"parameters (dim control.nu)")
.def("multiplyByJacobian",
&ControlParametrizationModelPolyZero::multiplyByJacobian_J,
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,
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)")
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<ControlParametrizationModelPolyZero>());
}

Expand Down

0 comments on commit c0348fb

Please sign in to comment.