Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploited control-residual structure when computing Lu, Luu #1176

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/python/crocoddyl/multibody/friction-cone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void exposeFrictionCone() {
":param R: rotation matrix that defines the cone orientation w.r.t. "
"the inertial frame\n"
":param mu: friction coefficient\n"
":param nf: number of facets\n"
":param nf: number of facets (default 4)\n"
":param inner_appr: inner or outer approximation (default True)\n"
":param min_nforce: minimum normal force (default 0.)\n"
":param max_nforce: maximum normal force (default "
Expand Down
21 changes: 20 additions & 1 deletion include/crocoddyl/core/residuals/control.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -112,6 +113,24 @@ class ResidualModelControlTpl : public ResidualModelAbstractTpl<_Scalar> {
virtual boost::shared_ptr<ResidualDataAbstract> createData(
DataCollectorAbstract* const data);

/**
* @brief Compute the derivative of the control-cost function
*
* This function assumes that the derivatives of the activation and residual
* are computed via calcDiff functions.
*
* @param cdata Cost data
* @param rdata Residual data
* @param adata Activation data
* @param update_u Update the derivative of the cost function w.r.t. to the
* control if True.
*/
virtual void calcCostDiff(
const boost::shared_ptr<CostDataAbstract>& cdata,
const boost::shared_ptr<ResidualDataAbstract>& rdata,
const boost::shared_ptr<ActivationDataAbstract>& adata,
const bool update_u = true);

/**
* @brief Return the reference control vector
*/
Expand Down
9 changes: 9 additions & 0 deletions include/crocoddyl/core/residuals/control.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ ResidualModelControlTpl<Scalar>::createData(
return data;
}

template <typename Scalar>
void ResidualModelControlTpl<Scalar>::calcCostDiff(
const boost::shared_ptr<CostDataAbstract>& cdata,
const boost::shared_ptr<ResidualDataAbstract>&,
const boost::shared_ptr<ActivationDataAbstract>& adata, const bool) {
cdata->Lu = adata->Ar;
cdata->Luu = adata->Arr;
}

template <typename Scalar>
void ResidualModelControlTpl<Scalar>::print(std::ostream& os) const {
os << "ResidualModelControl";
Expand Down
Loading