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

[pre-commit.ci] pre-commit autoupdate #92

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ ci:
autoupdate_branch: 'devel'
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
rev: v19.1.6
hooks:
- id: clang-format
args: [--style=Google]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -25,11 +25,11 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/cheshirekow/cmake-format-precommit
Expand Down
8 changes: 5 additions & 3 deletions examples/walk_without_think/walk_ocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@
q0 = robot.x0[: robot.model.nq]
print(
"Start from q0=",
"half_sitting"
if norm(q0 - robot.model.referenceConfigurations["half_sitting"]) < 1e-9
else q0,
(
"half_sitting"
if norm(q0 - robot.model.referenceConfigurations["half_sitting"]) < 1e-9
else q0
),
)

# #####################################################################################
Expand Down
16 changes: 8 additions & 8 deletions include/sobec/crocomplements/activation-quad-ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ class ActivationModelQuadRefTpl : public ActivationModelAbstractTpl<_Scalar> {
typedef typename MathBase::MatrixXs MatrixXs;

explicit ActivationModelQuadRefTpl(const VectorXs& reference)
: Base(static_cast<std::size_t>(reference.size())), ref(reference){};
virtual ~ActivationModelQuadRefTpl(){};
: Base(static_cast<std::size_t>(reference.size())), ref(reference) {};
virtual ~ActivationModelQuadRefTpl() {};

virtual void calc(const boost::shared_ptr<ActivationDataAbstract>& data,
const Eigen::Ref<const VectorXs>& r) {
if (static_cast<std::size_t>(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_) + ")");
}
data->a_value = (Scalar(0.5) * (r - ref).transpose() * (r - ref))[0];
};

virtual void calcDiff(const boost::shared_ptr<ActivationDataAbstract>& data,
const Eigen::Ref<const VectorXs>& r) {
if (static_cast<std::size_t>(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_) + ")");
}

data->Ar = r - ref;
Expand Down
17 changes: 8 additions & 9 deletions include/sobec/crocomplements/activation-weighted-log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ class ActivationModelWeightedLogTpl
const Scalar &alpha = Scalar(1.))
: Base(weights.size()), weights_(weights), alpha_(alpha) {
if (alpha < Scalar(0.)) {
throw_pretty("Invalid argument: "
<< "alpha should be a positive value");
throw_pretty("Invalid argument: " << "alpha should be a positive value");
}
};
virtual ~ActivationModelWeightedLogTpl(){};
virtual ~ActivationModelWeightedLogTpl() {};

virtual void calc(const boost::shared_ptr<ActivationDataAbstract> &data,
const Eigen::Ref<const VectorXs> &r) {
if (static_cast<std::size_t>(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_) + ")");
}
boost::shared_ptr<Data> d = boost::static_pointer_cast<Data>(data);
d->Wr = weights_.cwiseProduct(r);
Expand All @@ -59,9 +58,9 @@ class ActivationModelWeightedLogTpl
virtual void calcDiff(const boost::shared_ptr<ActivationDataAbstract> &data,
const Eigen::Ref<const VectorXs> &r) {
if (static_cast<std::size_t>(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_) + ")");
}
boost::shared_ptr<Data> d = boost::static_pointer_cast<Data>(data);

Expand Down
6 changes: 3 additions & 3 deletions include/sobec/crocomplements/contact/contact-fwddyn.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ void DifferentialActionModelContactFwdDynamicsTpl<Scalar>::calcDiff(
std::to_string(this->get_state()->get_nx()) + ")");
}
if (static_cast<std::size_t>(u.size()) != this->get_nu()) {
throw_pretty("Invalid argument: "
<< "u has wrong dimension (it should be " +
std::to_string(this->get_nu()) + ")");
throw_pretty(
"Invalid argument: " << "u has wrong dimension (it should be " +
std::to_string(this->get_nu()) + ")");
}

const std::size_t nv = this->get_state()->get_nv();
Expand Down
4 changes: 2 additions & 2 deletions include/sobec/crocomplements/contact/contact1d.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ void ContactModel1DTpl<Scalar>::updateForce(
const boost::shared_ptr<crocoddyl::ContactDataAbstractTpl<Scalar>>& data,
const VectorXs& force) {
if (force.size() != 1) {
throw_pretty("Invalid argument: "
<< "lambda has wrong dimension (it should be 1)");
throw_pretty(
"Invalid argument: " << "lambda has wrong dimension (it should be 1)");
}
Data* d = static_cast<Data*>(data.get());
d->oRf = d->pinocchio->oMf[id_].rotation();
Expand Down
4 changes: 2 additions & 2 deletions include/sobec/crocomplements/contact/contact3d.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ void ContactModel3DTpl<Scalar>::updateForce(
const boost::shared_ptr<crocoddyl::ContactDataAbstractTpl<Scalar>>& data,
const VectorXs& force) {
if (force.size() != 3) {
throw_pretty("Invalid argument: "
<< "lambda has wrong dimension (it should be 3)");
throw_pretty(
"Invalid argument: " << "lambda has wrong dimension (it should be 3)");
}
Data* d = static_cast<Data*>(data.get());
d->oRf = d->pinocchio->oMf[id_].rotation();
Expand Down
4 changes: 2 additions & 2 deletions include/sobec/crocomplements/contact/contact6d.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void ContactModel6DTpl<Scalar>::updateForce(
const boost::shared_ptr<crocoddyl::ContactDataAbstractTpl<Scalar>>& data,
const VectorXs& force) {
if (force.size() != 6) {
throw_pretty("Invalid argument: "
<< "lambda has wrong dimension (it should be 6)");
throw_pretty(
"Invalid argument: " << "lambda has wrong dimension (it should be 6)");
}
Data* d = static_cast<Data*>(data.get());
d->oRf = d->pinocchio->oMf[id_].rotation();
Expand Down
16 changes: 8 additions & 8 deletions include/sobec/crocomplements/contact/multiple-contacts.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ void ContactModelMultipleTpl<Scalar>::updateForceDiff(
const std::size_t ndx = this->get_state()->get_ndx();
if (static_cast<std::size_t>(df_dx->rows()) != this->get_nc() ||
static_cast<std::size_t>(df_dx->cols()) != ndx) {
throw_pretty("Invalid argument: "
<< "df_dx has wrong dimension (it should be " +
std::to_string(this->get_nc()) + "," +
std::to_string(ndx) + ")");
throw_pretty(
"Invalid argument: " << "df_dx has wrong dimension (it should be " +
std::to_string(this->get_nc()) + "," +
std::to_string(ndx) + ")");
}
if (static_cast<std::size_t>(df_du->rows()) != this->get_nc() ||
static_cast<std::size_t>(df_du->cols()) != this->get_nu()) {
throw_pretty("Invalid argument: "
<< "df_du has wrong dimension (it should be " +
std::to_string(this->get_nc()) + "," +
std::to_string(this->get_nu()) + ")");
throw_pretty(
"Invalid argument: " << "df_du has wrong dimension (it should be " +
std::to_string(this->get_nc()) + "," +
std::to_string(this->get_nu()) + ")");
}
if (static_cast<std::size_t>(data->contacts.size()) !=
this->get_contacts().size()) {
Expand Down
83 changes: 40 additions & 43 deletions include/sobec/crocomplements/lowpassfilter/action.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ void IntegratedActionModelLPFTpl<Scalar>::calc(
const std::size_t& nx = differential_->get_state()->get_nx();

if (static_cast<std::size_t>(y.size()) != ny_) {
throw_pretty("Invalid argument: "
<< "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
throw_pretty(
"Invalid argument: " << "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
}
if (static_cast<std::size_t>(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_) + ")");
}

// Static casting the data
Expand All @@ -162,14 +162,14 @@ void IntegratedActionModelLPFTpl<Scalar>::calc(
const Eigen::Ref<const VectorXs>& tau = d->tau_tmp;
// std::cout << "[lpf.calc] tau = " << tau << std::endl;
if (static_cast<std::size_t>(x.size()) != nx) {
throw_pretty("Invalid argument: "
<< "x has wrong dimension (it should be " +
std::to_string(nx) + ")");
throw_pretty(
"Invalid argument: " << "x has wrong dimension (it should be " +
std::to_string(nx) + ")");
}
if (static_cast<std::size_t>(tau.size()) != nw_) {
throw_pretty("Invalid argument: "
<< "tau has wrong dimension (it should be " +
std::to_string(nw_) + ")");
throw_pretty(
"Invalid argument: " << "tau has wrong dimension (it should be " +
std::to_string(nw_) + ")");
}
if (static_cast<std::size_t>(d->Fy.rows()) !=
boost::static_pointer_cast<StateLPF>(state_)->get_ndy()) {
Expand All @@ -190,9 +190,9 @@ void IntegratedActionModelLPFTpl<Scalar>::calc(
")");
}
if (static_cast<std::size_t>(d->Fw.cols()) != nw_) {
throw_pretty("Invalid argument: "
<< "Fw.cols() has wrong dimension (it should be " +
std::to_string(nw_) + ")");
throw_pretty(
"Invalid argument: " << "Fw.cols() has wrong dimension (it should be " +
std::to_string(nw_) + ")");
}
if (static_cast<std::size_t>(d->r.size()) !=
differential_->get_nr() + 2 * ntau_) {
Expand All @@ -211,9 +211,9 @@ void IntegratedActionModelLPFTpl<Scalar>::calc(
")");
}
if (static_cast<std::size_t>(d->Lw.size()) != nw_) {
throw_pretty("Invalid argument: "
<< "Lw has wrong dimension (it should be " +
std::to_string(nw_) + ")");
throw_pretty(
"Invalid argument: " << "Lw has wrong dimension (it should be " +
std::to_string(nw_) + ")");
}

// Compute acceleration and cost (DAM, i.e. CT model)
Expand Down Expand Up @@ -305,9 +305,9 @@ void IntegratedActionModelLPFTpl<Scalar>::calc(
const std::size_t& nx = differential_->get_state()->get_nx();

if (static_cast<std::size_t>(y.size()) != ny_) {
throw_pretty("Invalid argument: "
<< "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
throw_pretty(
"Invalid argument: " << "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
}

// Static casting the data
Expand Down Expand Up @@ -335,14 +335,14 @@ void IntegratedActionModelLPFTpl<Scalar>::calcDiff(
const std::size_t& ndx = differential_->get_state()->get_ndx();

if (static_cast<std::size_t>(y.size()) != ny_) {
throw_pretty("Invalid argument: "
<< "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
throw_pretty(
"Invalid argument: " << "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
}
if (static_cast<std::size_t>(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_) + ")");
}

// Static casting the data
Expand Down Expand Up @@ -541,7 +541,7 @@ void IntegratedActionModelLPFTpl<Scalar>::calcDiff(
}
#endif
} // tauLim !=0
} // tau integration
} // tau integration

// // TAU PLUS INTEGRATION
// else {
Expand Down Expand Up @@ -741,9 +741,9 @@ void IntegratedActionModelLPFTpl<Scalar>::calcDiff(
const std::size_t& ndx = differential_->get_state()->get_ndx();

if (static_cast<std::size_t>(y.size()) != ny_) {
throw_pretty("Invalid argument: "
<< "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
throw_pretty(
"Invalid argument: " << "y has wrong dimension (it should be " +
std::to_string(ny_) + ")");
}
// Static casting the data
boost::shared_ptr<Data> d = boost::static_pointer_cast<Data>(data);
Expand Down Expand Up @@ -820,8 +820,7 @@ const Scalar& IntegratedActionModelLPFTpl<Scalar>::get_fc() const {
template <typename Scalar>
void IntegratedActionModelLPFTpl<Scalar>::set_dt(const Scalar& dt) {
if (dt < 0.) {
throw_pretty("Invalid argument: "
<< "dt has positive value");
throw_pretty("Invalid argument: " << "dt has positive value");
}
time_step_ = dt;
time_step2_ = dt * dt;
Expand All @@ -831,8 +830,7 @@ template <typename Scalar>
void IntegratedActionModelLPFTpl<Scalar>::set_fc(const Scalar& fc) {
// Set the cut-off frequency
if (fc <= 0.) {
throw_pretty("Invalid argument: "
<< "fc must be positive");
throw_pretty("Invalid argument: " << "fc must be positive");
} else {
fc_ = fc;
}
Expand All @@ -842,8 +840,7 @@ template <typename Scalar>
void IntegratedActionModelLPFTpl<Scalar>::set_alpha(const Scalar& alpha) {
// Set the cut-off frequency
if (alpha < 0. || alpha > 1) {
throw_pretty("Invalid argument: "
<< "alpha must be in [0,1]");
throw_pretty("Invalid argument: " << "alpha must be in [0,1]");
} else {
alpha_ = alpha;
}
Expand Down Expand Up @@ -917,14 +914,14 @@ void IntegratedActionModelLPFTpl<Scalar>::quasiStatic(
const Eigen::Ref<const VectorXs>& x, const std::size_t maxiter,
const Scalar tol) {
if (static_cast<std::size_t>(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 (static_cast<std::size_t>(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()) + ")");
}

// Static casting the data
Expand Down
Loading