Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 15, 2024
1 parent aa35073 commit 31b90d3
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 142 deletions.
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
12 changes: 6 additions & 6 deletions include/sobec/crocomplements/activation-quad-ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ class ActivationModelQuadRefTpl : public ActivationModelAbstractTpl<_Scalar> {
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
15 changes: 7 additions & 8 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 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

0 comments on commit 31b90d3

Please sign in to comment.