From 8ce66abe85b414a06b6bb659dd20f86e3d51afa7 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Fri, 23 Sep 2022 10:54:14 +0200 Subject: [PATCH 01/14] (problib) Add -Wall and -Wextra as errors --- problib/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/problib/CMakeLists.txt b/problib/CMakeLists.txt index eac1491..0018c4f 100644 --- a/problib/CMakeLists.txt +++ b/problib/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.0.2) project(problib) +add_compile_options(-Wall -Werror=all) +add_compile_options(-Wextra -Werror=extra) + ## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages From 911561f995d3bdbd043b512f0a17a1f771711341 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 09:45:24 +0200 Subject: [PATCH 02/14] (problib) Mark external includes as system --- problib/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/problib/CMakeLists.txt b/problib/CMakeLists.txt index 0018c4f..295d942 100644 --- a/problib/CMakeLists.txt +++ b/problib/CMakeLists.txt @@ -31,9 +31,10 @@ catkin_package( ########### include_directories( - ${ARMADILLO_INCLUDE_DIRS} - ${catkin_INCLUDE_DIRS} - include + include + SYSTEM + ${catkin_INCLUDE_DIRS} + ${ARMADILLO_INCLUDE_DIRS} ) ########## feature extraction ########### From ddccfff33cfdfbb78545650323504fb2218f103c Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 09:45:56 +0200 Subject: [PATCH 03/14] (problib) remove circular include --- problib/include/problib/globals.h | 1 - 1 file changed, 1 deletion(-) diff --git a/problib/include/problib/globals.h b/problib/include/problib/globals.h index d75468b..355ba15 100644 --- a/problib/include/problib/globals.h +++ b/problib/include/problib/globals.h @@ -46,7 +46,6 @@ #include #include -#include "problib/pdfs/PDF.h" #include "problib/datatypes.h" //#define assert_msg(_Expression, _Msg) if (!_Expression) { printf(_Msg); printf("\n"); throw std::logic_error(""); } From 81c8ad10f9a17b8c54d473cfcc38039e4ab99991 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 09:49:13 +0200 Subject: [PATCH 04/14] (problib) Fix logical-not-parenthesis --- problib/include/problib/globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problib/include/problib/globals.h b/problib/include/problib/globals.h index 355ba15..69073b1 100644 --- a/problib/include/problib/globals.h +++ b/problib/include/problib/globals.h @@ -49,6 +49,6 @@ #include "problib/datatypes.h" //#define assert_msg(_Expression, _Msg) if (!_Expression) { printf(_Msg); printf("\n"); throw std::logic_error(""); } -#define assert_msg(_Expression, _Msg) do { if (!_Expression) { printf(_Msg); printf("\n"); assert(_Expression); } } while (false); +#define assert_msg(_Expression, _Msg) do { if (!(_Expression)) { printf(_Msg); printf("\n"); assert(_Expression); } } while (false); #endif /* GLOBALS_H_ */ From e942655ab7b46702e059f634436b5fe3db55037d Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 09:50:27 +0200 Subject: [PATCH 05/14] (problib) Fix unused-parameter --- problib/src/pdfs/Gaussian.cpp | 4 ++-- problib/src/pdfs/Hybrid.cpp | 4 ++-- problib/src/pdfs/PDF.cpp | 4 ++-- problib/src/pdfs/PMF.cpp | 4 ++-- problib/src/pdfs/Uniform.cpp | 4 ++-- problib/src/test.cpp | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/problib/src/pdfs/Gaussian.cpp b/problib/src/pdfs/Gaussian.cpp index 484947a..6c91d4b 100644 --- a/problib/src/pdfs/Gaussian.cpp +++ b/problib/src/pdfs/Gaussian.cpp @@ -108,7 +108,7 @@ double Gaussian::getDensity(const arma::vec& v, double max_mah_dist) const { return getDensity(v, ptr_->mu_, ptr_->cov_, max_mah_dist); } -double Gaussian::getDensity(const Gaussian& G, double max_mah_dist) const { +double Gaussian::getDensity(const Gaussian& G, double /*max_mah_dist*/) const { CHECK_INITIALIZED arma::mat S = G.getCovariance() + ptr_->cov_; return getDensity(ptr_->mu_, G.getMean(), S); @@ -188,7 +188,7 @@ const arma::mat& Gaussian::getCovariance() const { return ptr_->cov_; } -std::string Gaussian::toString(const std::string& indent) const { +std::string Gaussian::toString(const std::string& /*indent*/) const { if (!ptr_) { return "N(-)"; } diff --git a/problib/src/pdfs/Hybrid.cpp b/problib/src/pdfs/Hybrid.cpp index 8d76286..c59ddb7 100644 --- a/problib/src/pdfs/Hybrid.cpp +++ b/problib/src/pdfs/Hybrid.cpp @@ -84,7 +84,7 @@ void Hybrid::cloneStruct() { } } -double Hybrid::getLikelihood(const PDF& pdf) const { +double Hybrid::getLikelihood(const PDF& /*pdf*/) const { assert_msg(false, "Likelihood method not implemented. Please create a subclass of Hybrid and implement your own method."); return 0.; // Never reached because of assertion of false } @@ -104,7 +104,7 @@ double Hybrid::getMaxDensity() const { return 0; } -void Hybrid::addPDF(const PDF& pdf, double priority) { +void Hybrid::addPDF(const PDF& pdf, double /*priority*/) { if (dimensions_ < 0) { dimensions_ = pdf.dimensions(); } else { diff --git a/problib/src/pdfs/PDF.cpp b/problib/src/pdfs/PDF.cpp index 3dd7f9e..737f1e7 100644 --- a/problib/src/pdfs/PDF.cpp +++ b/problib/src/pdfs/PDF.cpp @@ -57,10 +57,10 @@ PDF::PDFType PDF::type() const { return type_; } -bool PDF::getExpectedValue(std::string& v) const { +bool PDF::getExpectedValue(std::string& /*v*/) const { return false; } -bool PDF::getExpectedValue(arma::vec& v) const { +bool PDF::getExpectedValue(arma::vec& /*v*/) const { return false; } diff --git a/problib/src/pdfs/PMF.cpp b/problib/src/pdfs/PMF.cpp index c038d69..5023166 100644 --- a/problib/src/pdfs/PMF.cpp +++ b/problib/src/pdfs/PMF.cpp @@ -280,7 +280,7 @@ void PMF::normalize() { ptr_->total_prob_ = 1; } -double PMF::getDensity(const arma::vec& v) const { +double PMF::getDensity(const arma::vec& /*v*/) const { assert_msg(false, "Cannot get density of a PMF"); return 0; } @@ -290,7 +290,7 @@ double PMF::getMaxDensity() const { return 0; } -std::string PMF::toString(const std::string& indent) const { +std::string PMF::toString(const std::string& /*indent*/) const { std::stringstream ss; ss << indent << "PMF(" << ptr_->domain_size_ << ")["; diff --git a/problib/src/pdfs/Uniform.cpp b/problib/src/pdfs/Uniform.cpp index b010fb9..8ccdbc9 100644 --- a/problib/src/pdfs/Uniform.cpp +++ b/problib/src/pdfs/Uniform.cpp @@ -125,7 +125,7 @@ void Uniform::setDensity(const double& density) { size_is_set_ = false; } -double Uniform::getDensity(const arma::vec& vec) const { +double Uniform::getDensity(const arma::vec& /*vec*/) const { return uniform_probability_; } @@ -151,7 +151,7 @@ void Uniform::calculateUniformDensity() { size_is_set_ = true; } -std::string Uniform::toString(const std::string& indent) const { +std::string Uniform::toString(const std::string& /*indent*/) const { std::stringstream s; s << "U(" << uniform_probability_; diff --git a/problib/src/test.cpp b/problib/src/test.cpp index c38b699..b1ab909 100644 --- a/problib/src/test.cpp +++ b/problib/src/test.cpp @@ -52,13 +52,13 @@ list TIMERS; stringstream TIMER_LOG; stringstream OUTPUT_LOG; -inline void startTimer(int ID = 0) { +inline void startTimer(int /*ID*/=0) { timespec t_start; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t_start); TIMERS.push_back(t_start); } -inline void stopTimer(string msg, int ID = 0, double factor = 1) { +inline void stopTimer(string msg, int /*ID*/=0, double factor=1) { timespec t_end; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t_end); @@ -253,7 +253,7 @@ void test() { delete pdf_exact_real; } -int main(int argc, char **argv) { +int main() { startTimer(); test(); From 96c57e9ca5d7e4be9d11df9d64fef372cae13b46 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 10:00:27 +0200 Subject: [PATCH 06/14] (problib) improve toString funcs --- problib/src/pdfs/Mixture.cpp | 2 +- problib/src/pdfs/PMF.cpp | 2 +- problib/src/pdfs/Uniform.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/problib/src/pdfs/Mixture.cpp b/problib/src/pdfs/Mixture.cpp index ced2dbb..f16f3b9 100644 --- a/problib/src/pdfs/Mixture.cpp +++ b/problib/src/pdfs/Mixture.cpp @@ -170,7 +170,7 @@ std::string Mixture::toString(const std::string& indent) const { ss << "MIX{\n"; std::vector::const_iterator it_w = ptr_->weights_.begin(); for (std::vector::const_iterator it_pdf = ptr_->components_.begin(); it_pdf != ptr_->components_.end(); ++it_pdf) { - ss << new_indent << (*it_w) << " : " << (*it_pdf)->toString(new_indent) << "\n"; + ss << new_indent << (*it_w) << ": " << (*it_pdf)->toString(new_indent) << "\n"; ++it_w; } ss << indent << "}"; diff --git a/problib/src/pdfs/PMF.cpp b/problib/src/pdfs/PMF.cpp index 5023166..51d1f98 100644 --- a/problib/src/pdfs/PMF.cpp +++ b/problib/src/pdfs/PMF.cpp @@ -292,7 +292,7 @@ double PMF::getMaxDensity() const { std::string PMF::toString(const std::string& /*indent*/) const { std::stringstream ss; - ss << indent << "PMF(" << ptr_->domain_size_ << ")["; + ss << "PMF(" << ptr_->domain_size_ << ")["; std::map::const_iterator it = ptr_->pmf_.begin(); if (it != ptr_->pmf_.end()) { diff --git a/problib/src/pdfs/Uniform.cpp b/problib/src/pdfs/Uniform.cpp index 8ccdbc9..1aa92f9 100644 --- a/problib/src/pdfs/Uniform.cpp +++ b/problib/src/pdfs/Uniform.cpp @@ -156,7 +156,7 @@ std::string Uniform::toString(const std::string& /*indent*/) const { s << "U(" << uniform_probability_; if (size_is_set_) { - s << ", mean = " << mean_ << ", size = " << size_; + s << ", mean =\n" << mean_ << ", size =\n" << size_; } s << ")"; From 65937907173383f1534854dcc85c5361eda56113 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 10:01:37 +0200 Subject: [PATCH 07/14] (problib) improve test output --- problib/src/test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problib/src/test.cpp b/problib/src/test.cpp index b1ab909..728cb50 100644 --- a/problib/src/test.cpp +++ b/problib/src/test.cpp @@ -148,7 +148,7 @@ void test() { for (int i = 0; i < 1000; ++i) { d = mix2.getLikelihood(exact2); } - cout << "Density of mixture at " << mean2 << " = " << d << endl << endl; + cout << "Density of mixture at:\n" << mean2 << " = " << d << endl << endl; cout << "Converting to msg ..." << endl << endl; problib_msgs::PDF pdf_msg; @@ -159,7 +159,7 @@ void test() { PDF* received_pdf = pbl::msgToPDF(pdf_msg); cout << "Result:" << endl << received_pdf->toString() << endl << endl; - cout << "Density of mixture at " << mean2 << " = " << received_pdf->getLikelihood(exact2) << endl << endl; + cout << "Density of mixture at:\n" << mean2 << " = " << received_pdf->getLikelihood(exact2) << endl << endl; delete received_pdf; From 68bce7af6d2aa5353b938fef9ea7252feda241ad Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 10:47:55 +0200 Subject: [PATCH 08/14] (wire_core) Mark external includes as system --- wire_core/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wire_core/CMakeLists.txt b/wire_core/CMakeLists.txt index 8d89326..d9804dd 100644 --- a/wire_core/CMakeLists.txt +++ b/wire_core/CMakeLists.txt @@ -32,7 +32,12 @@ catkin_package( TinyXML2 ) -include_directories(include ${catkin_INCLUDE_DIRS} ${TinyXML2_INCLUDE_DIRS}) +include_directories( + include + SYSTEM + ${catkin_INCLUDE_DIRS} + ${TinyXML2_INCLUDE_DIRS} +) ## Build add_compile_options(-Wreturn-type) # Return type checking From eff7989bdfb237dd80f2872b12dd3e88dff373eb Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 10:48:54 +0200 Subject: [PATCH 09/14] (wire_core) Add -Wall and -Wextra as errors --- wire_core/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wire_core/CMakeLists.txt b/wire_core/CMakeLists.txt index d9804dd..3773cc2 100644 --- a/wire_core/CMakeLists.txt +++ b/wire_core/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.0.2) project(wire_core) +add_compile_options(-Wall -Werror=all) +add_compile_options(-Wextra -Werror=extra) + ## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages @@ -40,10 +43,6 @@ include_directories( ) ## Build -add_compile_options(-Wreturn-type) # Return type checking -add_compile_options(-Wreorder) - - add_library(wire src/WorldModelROS.cpp src/models/FixedState.cpp @@ -79,7 +78,6 @@ add_library(wire include/wire/logic/AssignmentMatrix.h include/wire/logic/Hypothesis.h include/wire/logic/HypothesesTree.h - ) target_link_libraries(wire ${catkin_LIBRARIES} ${TinyXML2_LIBRARIES}) From 06269df7eb75161ca6a0c8fb86c281a01607a379 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 11:17:16 +0200 Subject: [PATCH 10/14] (wire_core) fix unused-parameter --- wire_core/src/WorldModelROS.cpp | 2 +- wire_core/src/core/PropertySet.cpp | 2 +- wire_core/src/models/FixedState.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wire_core/src/WorldModelROS.cpp b/wire_core/src/WorldModelROS.cpp index f3406b7..7a3d031 100644 --- a/wire_core/src/WorldModelROS.cpp +++ b/wire_core/src/WorldModelROS.cpp @@ -301,7 +301,7 @@ void WorldModelROS::processEvidence(const wire_msgs::WorldEvidence& world_eviden } } -bool WorldModelROS::resetWorldModel(std_srvs::Empty::Request& req, std_srvs::Empty::Response& res) { +bool WorldModelROS::resetWorldModel(std_srvs::Empty::Request& /*req*/, std_srvs::Empty::Response& /*res*/) { delete world_model_; world_model_ = new HypothesisTree(max_num_hyps_, min_prob_ratio_); return true; diff --git a/wire_core/src/core/PropertySet.cpp b/wire_core/src/core/PropertySet.cpp index d25d408..c0faab4 100644 --- a/wire_core/src/core/PropertySet.cpp +++ b/wire_core/src/core/PropertySet.cpp @@ -103,7 +103,7 @@ void PropertySet::propagate(const Time& time) { timestamp_ = time; } -void PropertySet::update(const pbl::PDF& z, const Time& time) { +void PropertySet::update(const pbl::PDF& /*z*/, const Time& /*time*/) { assert(false); } diff --git a/wire_core/src/models/FixedState.cpp b/wire_core/src/models/FixedState.cpp index 15bf3fd..36373e9 100644 --- a/wire_core/src/models/FixedState.cpp +++ b/wire_core/src/models/FixedState.cpp @@ -27,7 +27,7 @@ FixedState* FixedState::clone() const { return new FixedState(*this); } -void FixedState::update(const pbl::PDF& z, const mhf::Time& /*time*/) { +void FixedState::update(const pbl::PDF& /*z*/, const mhf::Time& /*time*/) { } void FixedState::propagate(const mhf::Time& /*time*/) { From 3330fdd33648d6f0b8bf19f1df4ae1957cd49b70 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 27 Sep 2022 11:18:15 +0200 Subject: [PATCH 11/14] (wire_core) fix bitwise-instead-of-logical --- wire_core/src/util/ObjectModelParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wire_core/src/util/ObjectModelParser.cpp b/wire_core/src/util/ObjectModelParser.cpp index 286cc06..8734614 100644 --- a/wire_core/src/util/ObjectModelParser.cpp +++ b/wire_core/src/util/ObjectModelParser.cpp @@ -104,7 +104,7 @@ bool ObjectModelParser::parseStateEstimator(ClassModel* obj_model, const tinyxml // check behavior model's attribute and model type std::string attribute_name, model_type; if (!getAttributeValue(elem, "attribute", attribute_name, error) - | !getAttributeValue(elem, "model", model_type, error)) { + || !getAttributeValue(elem, "model", model_type, error)) { return false; } From cf48f73420de258fdf77f46e8a645a7be8e28401 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Wed, 7 Dec 2022 10:28:12 +0100 Subject: [PATCH 12/14] (core) fix return-type --- wire_core/src/core/PropertySet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wire_core/src/core/PropertySet.cpp b/wire_core/src/core/PropertySet.cpp index c0faab4..f1f1b89 100644 --- a/wire_core/src/core/PropertySet.cpp +++ b/wire_core/src/core/PropertySet.cpp @@ -115,6 +115,7 @@ void PropertySet::reset() { const pbl::PDF& PropertySet::getValue() const { assert(false); + return pbl::PDF(0, pbl::PDF::UNKNOWN); } double PropertySet::getLikelihood(const PropertySet& P) const { From fd81a62b0788ca3c227c1cad9d6a318a73412c2a Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 28 Feb 2023 09:00:23 +0100 Subject: [PATCH 13/14] (estimators) Add -Wall and -Wextra as errors --- wire_state_estimators/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wire_state_estimators/CMakeLists.txt b/wire_state_estimators/CMakeLists.txt index 092df7c..97146ad 100644 --- a/wire_state_estimators/CMakeLists.txt +++ b/wire_state_estimators/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.0.2) project(wire_state_estimators) +add_compile_options(-Wall -Werror=all) +add_compile_options(-Wextra -Werror=extra) + ## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages From 3b2e5cf2b7d0d15d1295da5339d08a7a07a033bb Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 28 Feb 2023 09:01:18 +0100 Subject: [PATCH 14/14] (estimators) mark catkin_INCLUDE_DIRS as SYSTEM --- wire_state_estimators/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wire_state_estimators/CMakeLists.txt b/wire_state_estimators/CMakeLists.txt index 97146ad..e631aba 100644 --- a/wire_state_estimators/CMakeLists.txt +++ b/wire_state_estimators/CMakeLists.txt @@ -21,7 +21,11 @@ catkin_package( pluginlib ) -include_directories(include ${catkin_INCLUDE_DIRS}) +include_directories( + include + SYSTEM + ${catkin_INCLUDE_DIRS} +) ## Build