diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ecbba24a..112aab2ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - gar : fix missing move assignment operator in `LqrProblemTpl` +- Fix C++20 support. Fix `consteval` compilation errors related to fmt ### Changed diff --git a/include/aligator/modelling/centroidal/angular-acceleration.hpp b/include/aligator/modelling/centroidal/angular-acceleration.hpp index 98e421f53..46c369c1c 100644 --- a/include/aligator/modelling/centroidal/angular-acceleration.hpp +++ b/include/aligator/modelling/centroidal/angular-acceleration.hpp @@ -41,9 +41,8 @@ struct AngularAccelerationResidualTpl : StageFunctionTpl<_Scalar> { , force_size_(force_size) { if (contact_map.size_ != nk_) { ALIGATOR_DOMAIN_ERROR( - fmt::format("Contact ids and nk should be the same: now " - "({} and {}).", - contact_map.size_, nk_)); + "Contact ids and nk should be the same ({:d} and {:d}).", + contact_map.size_, nk_); } } diff --git a/include/aligator/modelling/centroidal/centroidal-acceleration.hpp b/include/aligator/modelling/centroidal/centroidal-acceleration.hpp index ab566a45b..09e4c4118 100644 --- a/include/aligator/modelling/centroidal/centroidal-acceleration.hpp +++ b/include/aligator/modelling/centroidal/centroidal-acceleration.hpp @@ -41,9 +41,8 @@ struct CentroidalAccelerationResidualTpl : StageFunctionTpl<_Scalar> { , force_size_(force_size) { if (contact_map.size_ != nk_) { ALIGATOR_DOMAIN_ERROR( - fmt::format("Contact ids and nk should be the same: now " - "({} and {}).", - contact_map.size_, nk_)); + "Contact ids and nk should be the same ({:d} and {:d}).", + contact_map.size_, nk_); } } diff --git a/include/aligator/modelling/contact-map.hpp b/include/aligator/modelling/contact-map.hpp index c0f69d307..1471be5cf 100644 --- a/include/aligator/modelling/contact-map.hpp +++ b/include/aligator/modelling/contact-map.hpp @@ -18,9 +18,9 @@ template struct ContactMapTpl { , contact_poses_(contact_poses) { if (contact_states.size() != contact_poses.size()) { ALIGATOR_DOMAIN_ERROR( - fmt::format("contact_states and contact_poses should have same size, " - "currently ({} and {}).", - contact_states.size(), contact_poses.size())); + "Contact_states and contact_poses should have same size, " + "currently ({:d} and {:d}).", + contact_states.size(), contact_poses.size()); } size_ = contact_states_.size(); } diff --git a/include/aligator/modelling/costs/sum-of-costs.hxx b/include/aligator/modelling/costs/sum-of-costs.hxx index 86760ed71..624bd726c 100644 --- a/include/aligator/modelling/costs/sum-of-costs.hxx +++ b/include/aligator/modelling/costs/sum-of-costs.hxx @@ -10,19 +10,16 @@ CostStackTpl::CostStackTpl(xyz::polymorphic space, const std::vector &weights) : CostBase(space, nu) { if (comps.size() != weights.size()) { - auto msg = fmt::format( + ALIGATOR_RUNTIME_ERROR( "Inconsistent number of components ({:d}) and weights ({:d}).", comps.size(), weights.size()); - ALIGATOR_RUNTIME_ERROR(msg); } else { for (std::size_t i = 0; i < comps.size(); i++) { if (!this->checkDimension(*comps[i])) { - auto msg = fmt::format("Component #{:d} has wrong input dimensions " - "({:d}, {:d}) (expected " - "({:d}, {:d}))", + ALIGATOR_RUNTIME_ERROR("Component #{:d} has wrong input dimensions " + "({:d}, {:d}) (expected ({:d}, {:d}))", i, comps[i]->ndx(), comps[i]->nu, this->ndx(), this->nu); - ALIGATOR_RUNTIME_ERROR(msg); } } diff --git a/include/aligator/modelling/dynamics/multibody-constraint-fwd.hxx b/include/aligator/modelling/dynamics/multibody-constraint-fwd.hxx index 31f56f250..832c69ebb 100644 --- a/include/aligator/modelling/dynamics/multibody-constraint-fwd.hxx +++ b/include/aligator/modelling/dynamics/multibody-constraint-fwd.hxx @@ -21,9 +21,9 @@ MultibodyConstraintFwdDynamicsTpl::MultibodyConstraintFwdDynamicsTpl( const int nv = state.getModel().nv; if (nv != actuation.rows()) { ALIGATOR_DOMAIN_ERROR( - fmt::format("actuation matrix should have number of rows = pinocchio " - "model nv ({} and {}).", - actuation.rows(), nv)); + "Actuation matrix should have number of rows = pinocchio " + "model nv ({} and {}).", + actuation.rows(), nv); } } diff --git a/include/aligator/modelling/dynamics/multibody-free-fwd.hxx b/include/aligator/modelling/dynamics/multibody-free-fwd.hxx index 514e6bd3a..05d11b670 100644 --- a/include/aligator/modelling/dynamics/multibody-free-fwd.hxx +++ b/include/aligator/modelling/dynamics/multibody-free-fwd.hxx @@ -20,9 +20,9 @@ MultibodyFreeFwdDynamicsTpl::MultibodyFreeFwdDynamicsTpl( const int nv = space().getModel().nv; if (nv != actuation.rows()) { ALIGATOR_DOMAIN_ERROR( - fmt::format("actuation matrix should have number of rows = pinocchio " - "model nv ({} and {}).", - actuation.rows(), nv)); + "Actuation matrix should have number of rows = pinocchio " + "model nv ({} and {}).", + actuation.rows(), nv); } act_matrix_rank = lu_decomp_.rank(); } diff --git a/include/aligator/modelling/multibody/centroidal-momentum-derivative.hxx b/include/aligator/modelling/multibody/centroidal-momentum-derivative.hxx index 911b6c6e5..1bf907cd7 100644 --- a/include/aligator/modelling/multibody/centroidal-momentum-derivative.hxx +++ b/include/aligator/modelling/multibody/centroidal-momentum-derivative.hxx @@ -25,9 +25,8 @@ CentroidalMomentumDerivativeResidualTpl:: mass_ = pinocchio::computeTotalMass(model); if (contact_ids_.size() != contact_states_.size()) { ALIGATOR_DOMAIN_ERROR( - fmt::format("contact_ids and contact_states should have same size: " - "now ({} and {}).", - contact_ids_.size(), contact_states_.size())); + "contact_ids and contact_states should have same size ({:d} and {:d}).", + contact_ids_.size(), contact_states_.size()); } } diff --git a/include/aligator/modelling/multibody/contact-force.hpp b/include/aligator/modelling/multibody/contact-force.hpp index 1b2eba86f..c5bba05cc 100644 --- a/include/aligator/modelling/multibody/contact-force.hpp +++ b/include/aligator/modelling/multibody/contact-force.hpp @@ -54,10 +54,9 @@ struct ContactForceResidualTpl : StageFunctionTpl<_Scalar> { , fref_(fref) , force_size_(fref.size()) { if (model.nv != actuation.rows()) { - ALIGATOR_DOMAIN_ERROR( - fmt::format("actuation matrix should have number of rows = pinocchio " - "model nv ({} and {}).", - actuation.rows(), model.nv)); + ALIGATOR_DOMAIN_ERROR("Actuation matrix should have number of rows = " + "model.nv ({:d} and {:d}).", + actuation.rows(), model.nv); } contact_id_ = -1; for (std::size_t i = 0; i < constraint_models.size(); i++) { diff --git a/include/aligator/modelling/multibody/multibody-friction-cone.hpp b/include/aligator/modelling/multibody/multibody-friction-cone.hpp index b36c14041..db18a7f9a 100644 --- a/include/aligator/modelling/multibody/multibody-friction-cone.hpp +++ b/include/aligator/modelling/multibody/multibody-friction-cone.hpp @@ -50,10 +50,9 @@ struct MultibodyFrictionConeResidualTpl : StageFunctionTpl<_Scalar> { , prox_settings_(prox_settings) , mu_(mu) { if (model.nv != actuation.rows()) { - ALIGATOR_DOMAIN_ERROR( - fmt::format("actuation matrix should have number of rows = pinocchio " - "model nv ({} and {}).", - actuation.rows(), model.nv)); + ALIGATOR_DOMAIN_ERROR("Actuation matrix should have number of rows = " + "model.nv ({:d} and {:d}).", + actuation.rows(), model.nv); } contact_id_ = -1; for (std::size_t i = 0; i < constraint_models.size(); i++) { diff --git a/include/aligator/modelling/multibody/multibody-wrench-cone.hpp b/include/aligator/modelling/multibody/multibody-wrench-cone.hpp index 15c8fa3ac..e157c71b7 100644 --- a/include/aligator/modelling/multibody/multibody-wrench-cone.hpp +++ b/include/aligator/modelling/multibody/multibody-wrench-cone.hpp @@ -57,10 +57,9 @@ struct MultibodyWrenchConeResidualTpl : StageFunctionTpl<_Scalar> { , hL_(half_length) , hW_(half_width) { if (model.nv != actuation.rows()) { - ALIGATOR_DOMAIN_ERROR( - fmt::format("actuation matrix should have number of rows = pinocchio " - "model nv ({} and {}).", - actuation.rows(), model.nv)); + ALIGATOR_DOMAIN_ERROR("Actuation matrix should have number of rows = " + "model.nv ({:d} and {:d}).", + actuation.rows(), model.nv); } contact_id_ = -1; for (std::size_t i = 0; i < constraint_models.size(); i++) { diff --git a/src/utils/logger.cpp b/src/utils/logger.cpp index 73b41e63c..cbd2b1d05 100644 --- a/src/utils/logger.cpp +++ b/src/utils/logger.cpp @@ -40,10 +40,13 @@ void Logger::finish(bool conv) { if (!active) return; - auto ts = fmt::fg(conv ? fmt::color::dodger_blue : fmt::color::red); - const char *msg = conv ? "Successfully converged." : "Convergence failure."; - fmt::print(ts, msg); - fmt::print("\n"); + fmt::text_style ts = + fmt::fg(conv ? fmt::color::dodger_blue : fmt::color::red); + if (conv) { + fmt::print(ts, "Successfully converged\n"); + } else { + fmt::print(ts, "Convergence failure\n"); + } } void Logger::addColumn(std::string_view name, uint width, @@ -55,12 +58,12 @@ void Logger::addColumn(std::string_view name, uint width, void Logger::addEntry(std::string_view name, double val) { const auto spec = m_colSpecs[name]; - m_currentLine[name] = fmt::format(spec.second, val, spec.first); + m_currentLine[name] = fmt::format(fmt::runtime(spec.second), val, spec.first); } void Logger::addEntry(std::string_view name, size_t val) { const auto spec = m_colSpecs[name]; - m_currentLine[name] = fmt::format(spec.second, val, spec.first); + m_currentLine[name] = fmt::format(fmt::runtime(spec.second), val, spec.first); } } // namespace aligator