diff --git a/.github/workflows/focal_build.yml b/.github/workflows/focal_build.yml index a6e6de52..f3b5aec7 100644 --- a/.github/workflows/focal_build.yml +++ b/.github/workflows/focal_build.yml @@ -26,7 +26,7 @@ jobs: UPSTREAM_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Release" TARGET_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Debug -DTRAJOPT_ENABLE_TESTING=ON -DTRAJOPT_ENABLE_CLANG_TIDY=ON" AFTER_SCRIPT: 'catkin build -w $target_ws --no-deps --verbose trajopt trajopt_ifopt trajopt_sco trajopt_sqp --make-args test' - ADDITIONAL_DEBS: clang-tidy + ADDITIONAL_DEBS: clang-tidy-12 steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/unstable_build.yml b/.github/workflows/unstable_build.yml index a7983231..a3213da4 100644 --- a/.github/workflows/unstable_build.yml +++ b/.github/workflows/unstable_build.yml @@ -26,7 +26,7 @@ jobs: UPSTREAM_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Release" TARGET_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Debug -DTRAJOPT_ENABLE_TESTING=ON -DTRAJOPT_ENABLE_CLANG_TIDY=ON" AFTER_SCRIPT: 'catkin build -w $target_ws --no-deps --verbose trajopt trajopt_ifopt trajopt_sco trajopt_sqp --make-args test' - ADDITIONAL_DEBS: clang-tidy + ADDITIONAL_DEBS: clang-tidy-12 steps: - uses: actions/checkout@v1 diff --git a/trajopt_sco/include/trajopt_sco/solver_interface.hpp b/trajopt_sco/include/trajopt_sco/solver_interface.hpp index e4f4bd24..919c885d 100644 --- a/trajopt_sco/include/trajopt_sco/solver_interface.hpp +++ b/trajopt_sco/include/trajopt_sco/solver_interface.hpp @@ -115,12 +115,12 @@ struct VarRep using Ptr = std::shared_ptr; VarRep(std::size_t _index, std::string _name, void* _creator) - : index(_index), name(std::move(_name)), removed(false), creator(_creator) + : index(_index), name(std::move(_name)), creator(_creator) { } std::size_t index; std::string name; - bool removed; + bool removed{ false }; void* creator; }; @@ -193,10 +193,10 @@ struct AffExpr AffExpr(AffExpr&&) = default; AffExpr& operator=(AffExpr&&) = default; - explicit AffExpr(double a) : constant(a) {} - explicit AffExpr(const Var& v) : coeffs(1, 1), vars(1, v) {} + explicit AffExpr(double a); + explicit AffExpr(const Var& v); - size_t size() const { return coeffs.size(); } + size_t size() const; double value(const double* x) const; double value(const DblVec& x) const; }; @@ -210,10 +210,10 @@ struct QuadExpr VarVector vars1; VarVector vars2; QuadExpr() = default; - explicit QuadExpr(double a) : affexpr(a) {} - explicit QuadExpr(const Var& v) : affexpr(v) {} - explicit QuadExpr(AffExpr aff) : affexpr(std::move(aff)) {} - size_t size() const { return coeffs.size(); } + explicit QuadExpr(double a); + explicit QuadExpr(const Var& v); + explicit QuadExpr(AffExpr aff); + size_t size() const; double value(const double* x) const; double value(const DblVec& x) const; }; @@ -249,7 +249,7 @@ class ModelType friend std::ostream& operator<<(std::ostream& os, const ModelType& cs); private: - Value value_; + Value value_{ Value::AUTO_SOLVER }; }; std::vector availableSolvers(); diff --git a/trajopt_sco/src/modeling.cpp b/trajopt_sco/src/modeling.cpp index a0b6075d..ea017472 100644 --- a/trajopt_sco/src/modeling.cpp +++ b/trajopt_sco/src/modeling.cpp @@ -10,7 +10,6 @@ TRAJOPT_IGNORE_WARNINGS_POP #include #include #include -#include namespace sco { diff --git a/trajopt_sco/src/solver_interface.cpp b/trajopt_sco/src/solver_interface.cpp index aae55ca8..653287d8 100644 --- a/trajopt_sco/src/solver_interface.cpp +++ b/trajopt_sco/src/solver_interface.cpp @@ -8,7 +8,6 @@ TRAJOPT_IGNORE_WARNINGS_PUSH TRAJOPT_IGNORE_WARNINGS_POP #include -#include namespace sco { @@ -62,6 +61,10 @@ void simplify2(IntVec& inds, DblVec& vals) } } +AffExpr::AffExpr(double a) : constant(a) {} +AffExpr::AffExpr(const Var& v) : coeffs(1, 1), vars(1, v) {} +size_t AffExpr::size() const { return coeffs.size(); } + double AffExpr::value(const double* x) const { double out = constant; @@ -80,6 +83,12 @@ double AffExpr::value(const DblVec& x) const } return out; } + +QuadExpr::QuadExpr(double a) : affexpr(a) {} +QuadExpr::QuadExpr(const Var& v) : affexpr(v) {} +QuadExpr::QuadExpr(AffExpr aff) : affexpr(std::move(aff)) {} +size_t QuadExpr::size() const { return coeffs.size(); } + double QuadExpr::value(const DblVec& x) const { double out = affexpr.value(x); @@ -215,9 +224,9 @@ std::ostream& operator<<(std::ostream& os, const ModelType& cs) return os; } -ModelType::ModelType() { value_ = ModelType::AUTO_SOLVER; } -ModelType::ModelType(const ModelType::Value& v) { value_ = v; } -ModelType::ModelType(const int& v) { value_ = static_cast(v); } +ModelType::ModelType() = default; +ModelType::ModelType(const ModelType::Value& v) : value_(v) {} +ModelType::ModelType(const int& v) : value_(static_cast(v)) {} ModelType::ModelType(const std::string& s) { for (unsigned int i = 0; i < ModelType::MODEL_NAMES_.size(); ++i) @@ -351,6 +360,6 @@ Model::Ptr createModel(ModelType model_type, const ModelConfig::ConstPtr& model_ std::stringstream solver_instatiation_error; solver_instatiation_error << "Failed to create solver: unknown solver " << solver << std::endl; PRINT_AND_THROW(solver_instatiation_error.str()); - return Model::Ptr(); + return {}; } } // namespace sco diff --git a/trajopt_sco/test/CMakeLists.txt b/trajopt_sco/test/CMakeLists.txt index 2fc4b66b..3584393a 100644 --- a/trajopt_sco/test/CMakeLists.txt +++ b/trajopt_sco/test/CMakeLists.txt @@ -53,7 +53,7 @@ target_compile_options(${PROJECT_NAME}-test PRIVATE ${TRAJOPT_COMPILE_OPTIONS_PR target_compile_definitions(${PROJECT_NAME}-test PRIVATE ${TRAJOPT_COMPILE_DEFINITIONS} TRAJOPT_IFOPT_DIR="${CMAKE_SOURCE_DIR}") target_cxx_version(${PROJECT_NAME}-test PRIVATE VERSION ${TRAJOPT_CXX_VERSION}) -# target_clang_tidy(${PROJECT_NAME}-test ENABLE ${TRAJOPT_ENABLE_CLANG_TIDY}) +target_clang_tidy(${PROJECT_NAME}-test ENABLE ${TRAJOPT_ENABLE_CLANG_TIDY}) add_gtest_discover_tests(${PROJECT_NAME}-test) if(HAVE_BPMPD) add_dependencies(${PROJECT_NAME}-test bpmpd_caller)