diff --git a/CMakeLists.txt b/CMakeLists.txt index 16f94577c6d285823875434038935bbcb9f1694a..d7de1cdfc1c79a7f853c38f0fb77dbe9afe1b35b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,7 +395,7 @@ endif() #Link the created libraries #============================================================= TARGET_LINK_LIBRARIES(${PLUGIN_NAME} PUBLIC ${CMAKE_THREAD_LIBS_INIT} dl) -TARGET_LINK_LIBRARIES(${PLUGIN_NAME} PUBLIC yaml-cpp) +TARGET_LINK_LIBRARIES(${PLUGIN_NAME} PUBLIC yaml-schema-cpp) TARGET_LINK_LIBRARIES(${PLUGIN_NAME} PUBLIC Eigen3::Eigen) TARGET_LINK_LIBRARIES(${PLUGIN_NAME} PUBLIC spdlog::spdlog) IF (Ceres_FOUND) diff --git a/demos/hello_wolf/capture_range_bearing.h b/demos/hello_wolf/capture_range_bearing.h index 03803089d8a68d9ab14fd31aee123c6bf04144f3..a57f78a8f59a69af26911730632c744896e3ab12 100644 --- a/demos/hello_wolf/capture_range_bearing.h +++ b/demos/hello_wolf/capture_range_bearing.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * capture_range_bearing.h - * - * Created on: Nov 30, 2017 - * Author: jsola - */ - -#ifndef HELLO_WOLF_CAPTURE_RANGE_BEARING_H_ -#define HELLO_WOLF_CAPTURE_RANGE_BEARING_H_ +#pragma once #include "core/capture/capture_base.h" @@ -99,6 +91,4 @@ inline Eigen::Vector2d CaptureRangeBearing::getRangeBearing(int _i) const return Vector2d(ranges_(_i), bearings_(_i)); } -} /* namespace wolf */ - -#endif /* HELLO_WOLF_CAPTURE_RANGE_BEARING_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/demos/hello_wolf/factor_bearing.h b/demos/hello_wolf/factor_bearing.h index f790a24839bb6c63f1a09703fe283a6f48c11949..8e62a6470407ab3002b026b0ecb50b8cec910aea 100644 --- a/demos/hello_wolf/factor_bearing.h +++ b/demos/hello_wolf/factor_bearing.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * FactorBearing.h - * - * Created on: Nov 30, 2017 - * Author: jsola - */ - -#ifndef HELLO_WOLF_FACTOR_BEARING_H_ -#define HELLO_WOLF_FACTOR_BEARING_H_ +#pragma once #include "core/factor/factor_autodiff.h" @@ -123,6 +115,4 @@ inline bool FactorBearing::operator ()( const T* const _p_w_r, return true; } -} // namespace wolf - -#endif /* HELLO_WOLF_FACTOR_BEARING_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/demos/hello_wolf/factor_range_bearing.h b/demos/hello_wolf/factor_range_bearing.h index 4495682647b7b1ddcac24726e2bfbb86df1e343a..cc74186c93823f2735c7c0082d2ae2317dda9ee7 100644 --- a/demos/hello_wolf/factor_range_bearing.h +++ b/demos/hello_wolf/factor_range_bearing.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factor_range_bearing.h - * - * Created on: Dec 1, 2017 - * \author: jsola - */ - -#ifndef HELLO_WOLF_FACTOR_RANGE_BEARING_H_ -#define HELLO_WOLF_FACTOR_RANGE_BEARING_H_ +#pragma once #include "core/factor/factor_autodiff.h" @@ -155,5 +147,4 @@ inline bool FactorRangeBearing::operator ()(const T* const _p_w_r, // robot posi return true; } -} // namespace wolf -#endif /* HELLO_WOLF_FACTOR_RANGE_BEARING_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/demos/hello_wolf/feature_range_bearing.h b/demos/hello_wolf/feature_range_bearing.h index 24123e4df893acc29337713877bc342db39563bc..acb5ac8d04dc891d7b97b6d9c0be92b57fbf0104 100644 --- a/demos/hello_wolf/feature_range_bearing.h +++ b/demos/hello_wolf/feature_range_bearing.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * FeatureRangeBearing2d.h - * - * Created on: Nov 30, 2017 - * Author: jsola - */ - -#ifndef HELLO_WOLF_FEATURE_RANGE_BEARING_H_ -#define HELLO_WOLF_FEATURE_RANGE_BEARING_H_ +#pragma once #include "core/feature/feature_base.h" @@ -43,6 +35,4 @@ class FeatureRangeBearing : public FeatureBase ~FeatureRangeBearing() override; }; -} // namespace wolf - -#endif /* HELLO_WOLF_FEATURE_RANGE_BEARING_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/demos/hello_wolf/landmark_point_2d.h b/demos/hello_wolf/landmark_point_2d.h index 78aeafe9bf28b7abbd81f937db60d96da8f8c601..ce0eec818479f2f45c294039bf0256f78dda0038 100644 --- a/demos/hello_wolf/landmark_point_2d.h +++ b/demos/hello_wolf/landmark_point_2d.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file landmark_point_2d.h - * - * Created on: Dec 4, 2017 - * \author: jsola - */ - -#ifndef HELLO_WOLF_LANDMARK_POINT_2d_H_ -#define HELLO_WOLF_LANDMARK_POINT_2d_H_ +#pragma once #include "core/landmark/landmark_base.h" @@ -43,6 +35,4 @@ class LandmarkPoint2d : public LandmarkBase ~LandmarkPoint2d() override; }; -} /* namespace wolf */ - -#endif /* HELLO_WOLF_LANDMARK_POINT_2d_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/demos/hello_wolf/processor_range_bearing.h b/demos/hello_wolf/processor_range_bearing.h index ffd8b9b9c754aa0938b8d158eabedec373706577..516876ce75f0b6c8f0229b87c4b71619d3a2c2c1 100644 --- a/demos/hello_wolf/processor_range_bearing.h +++ b/demos/hello_wolf/processor_range_bearing.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * ProcessorRangeBearing.h - * - * Created on: Nov 30, 2017 - * Author: jsola - */ - -#ifndef HELLO_WOLF_PROCESSOR_RANGE_BEARING_H_ -#define HELLO_WOLF_PROCESSOR_RANGE_BEARING_H_ +#pragma once #include "core/processor/processor_base.h" #include "sensor_range_bearing.h" @@ -117,6 +109,4 @@ inline void ProcessorRangeBearing::configure(SensorBasePtr _sensor) H_r_s = transform(_sensor->getP()->getState(), _sensor->getO()->getState()); } -} /* namespace wolf */ - -#endif /* HELLO_WOLF_PROCESSOR_RANGE_BEARING_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/demos/hello_wolf/sensor_range_bearing.h b/demos/hello_wolf/sensor_range_bearing.h index 1aa70ac26a69dd9f8f706c3023ef62c87344ded4..263b5813a76781d59ccd881b3d389e1abbe1bea7 100644 --- a/demos/hello_wolf/sensor_range_bearing.h +++ b/demos/hello_wolf/sensor_range_bearing.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * SensorRangeBearing.h - * - * Created on: Nov 30, 2017 - * Author: jsola - */ - -#ifndef HELLO_WOLF_SENSOR_RANGE_BEARING_H_ -#define HELLO_WOLF_SENSOR_RANGE_BEARING_H_ +#pragma once #include "core/sensor/sensor_base.h" #include "core/utils/params_server.h" @@ -79,6 +71,4 @@ class SensorRangeBearing : public SensorBase Eigen::MatrixXd computeNoiseCov(const Eigen::VectorXd & _data) const override; }; -} /* namespace wolf */ - -#endif /* HELLO_WOLF_SENSOR_RANGE_BEARING_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/capture/capture_base.h b/include/core/capture/capture_base.h index b946f35b770aabb02f7f237933221131b30afdbc..b7f24d4a0f33270614a247d51d26181fc7fe6052 100644 --- a/include/core/capture/capture_base.h +++ b/include/core/capture/capture_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CAPTURE_BASE_H_ -#define CAPTURE_BASE_H_ +#pragma once // Forward declarations for node templates namespace wolf{ @@ -282,6 +281,4 @@ inline void CaptureBase::setTimeStampToNow() time_stamp_.setToNow(); } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/capture/capture_diff_drive.h b/include/core/capture/capture_diff_drive.h index a41e7dec78fa134b7a09fe99740daaccff42ed7a..45ead93cdd73c744290f3c3a2d9bfd91ae43052b 100644 --- a/include/core/capture/capture_diff_drive.h +++ b/include/core/capture/capture_diff_drive.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file diff_drive_tools.h - * - * Created on: Oct 20, 2016 - * \author: Jeremie Deray - */ - -#ifndef CAPTURE_DIFF_DRIVE_H_ -#define CAPTURE_DIFF_DRIVE_H_ +#pragma once //wolf includes #include "core/capture/capture_motion.h" @@ -61,6 +53,4 @@ public: ~CaptureDiffDrive() override = default; }; -} // namespace wolf - -#endif /* CAPTURE_DIFF_DRIVE_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/capture/capture_motion.h b/include/core/capture/capture_motion.h index 719c1f800cec4ae0e5d019f56a09b656b2c3f9f5..acc911feeacf9c524f9d930fcf6af0d4766fb637 100644 --- a/include/core/capture/capture_motion.h +++ b/include/core/capture/capture_motion.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file capture_motion.h - * - * Created on: Mar 16, 2016 - * \author: jsola - */ - -#ifndef SRC_CAPTURE_MOTION_H_ -#define SRC_CAPTURE_MOTION_H_ +#pragma once // Wolf includes #include "core/capture/capture_base.h" @@ -221,6 +213,4 @@ inline MatrixXd CaptureMotion::getDeltaPreintCov(const TimeStamp& _ts) const return getBuffer().getMotion(_ts).delta_integr_cov_; } -} // namespace wolf - -#endif /* SRC_CAPTURE_MOTION_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/capture/capture_odom_2d.h b/include/core/capture/capture_odom_2d.h index 8bc18706d5fb6122d9bc7e6262f8879f158bef60..e580ffdbb4956923eded1103ea37dd2f6fd48c1a 100644 --- a/include/core/capture/capture_odom_2d.h +++ b/include/core/capture/capture_odom_2d.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * capture_odom_2d.h - * - * Created on: Oct 16, 2017 - * Author: jsola - */ - -#ifndef CAPTURE_ODOM_2d_H_ -#define CAPTURE_ODOM_2d_H_ +#pragma once #include "core/capture/capture_motion.h" @@ -56,6 +48,4 @@ class CaptureOdom2d : public CaptureMotion }; -} /* namespace wolf */ - -#endif /* CAPTURE_ODOM_2d_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/capture/capture_odom_3d.h b/include/core/capture/capture_odom_3d.h index 0b6deb6a8f05cb0769a9065b57c190f693c78b62..5db3da878e3a662ae16ecf649cd76b94155b5086 100644 --- a/include/core/capture/capture_odom_3d.h +++ b/include/core/capture/capture_odom_3d.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * capture_odom_3d.h - * - * Created on: Oct 16, 2017 - * Author: jsola - */ - -#ifndef CAPTURE_ODOM_3d_H_ -#define CAPTURE_ODOM_3d_H_ +#pragma once #include "core/capture/capture_motion.h" @@ -56,6 +48,4 @@ class CaptureOdom3d : public CaptureMotion }; -} /* namespace wolf */ - -#endif /* CAPTURE_ODOM_3d_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/capture/capture_pose.h b/include/core/capture/capture_pose.h index 15b32f85ea340cc4a83a9745e54ce647f15fc250..e7313e1f5e73851978574ba757e826400ef44e4c 100644 --- a/include/core/capture/capture_pose.h +++ b/include/core/capture/capture_pose.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CAPTURE_POSE_H_ -#define CAPTURE_POSE_H_ +#pragma once //Wolf includes #include "core/capture/capture_base.h" @@ -54,5 +53,4 @@ class CapturePose : public CaptureBase }; -} //namespace wolf -#endif +} //namespace wolf \ No newline at end of file diff --git a/include/core/capture/capture_void.h b/include/core/capture/capture_void.h index 1adb08e43512af44f3d04951a8c3b27f685a9a43..4c388f387d8e09e6df92e7bc5f4ca76cfb1b8ffc 100644 --- a/include/core/capture/capture_void.h +++ b/include/core/capture/capture_void.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CAPTURE_VOID_H_ -#define CAPTURE_VOID_H_ +#pragma once //Wolf includes #include "core/capture/capture_base.h" @@ -39,6 +38,4 @@ class CaptureVoid : public CaptureBase }; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/ceres_wrapper/cost_function_wrapper.h b/include/core/ceres_wrapper/cost_function_wrapper.h index 9bca9394f7f3bd99e1bd2846f07d15e3bdc776e9..43b59c7f67def7d3cde93307203f877f94cbcd98 100644 --- a/include/core/ceres_wrapper/cost_function_wrapper.h +++ b/include/core/ceres_wrapper/cost_function_wrapper.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef TRUNK_SRC_COST_FUNCTION_WRAPPER_H_ -#define TRUNK_SRC_COST_FUNCTION_WRAPPER_H_ +#pragma once // WOLF #include "core/common/wolf.h" @@ -75,6 +74,4 @@ inline FactorBasePtr CostFunctionWrapper::getFactor() const return factor_ptr_; } -} // namespace wolf - -#endif /* TRUNK_SRC_COST_FUNCTION_WRAPPER_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/ceres_wrapper/create_numeric_diff_cost_function.h b/include/core/ceres_wrapper/create_numeric_diff_cost_function.h index 42bf8a7a9abd1339a26b58dd0dc0a195faf8957d..35886e5cf9c6979f3f1084859fa70f3f65664bfd 100644 --- a/include/core/ceres_wrapper/create_numeric_diff_cost_function.h +++ b/include/core/ceres_wrapper/create_numeric_diff_cost_function.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * create_numeric_diff_cost_function.h - * - * Created on: Apr 5, 2016 - * Author: jvallve - */ - -#ifndef SRC_CERES_WRAPPER_CREATE_NUMERIC_DIFF_COST_FUNCTION_H_ -#define SRC_CERES_WRAPPER_CREATE_NUMERIC_DIFF_COST_FUNCTION_H_ +#pragma once #include "ceres/cost_function.h" #include "ceres/numeric_diff_cost_function.h" @@ -66,6 +58,4 @@ inline std::shared_ptr<ceres::CostFunction> createNumericDiffCostFunction(Factor // } } -} // namespace wolf - -#endif /* SRC_CERES_WRAPPER_CREATE_NUMERIC_DIFF_COST_FUNCTION_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/ceres_wrapper/iteration_update_callback.h b/include/core/ceres_wrapper/iteration_update_callback.h index 6cf6179ff8c9d5e7543a5794210b65bd30b75049..2e223ed97e53fd7857192f16875f2f5fb7c46720 100644 --- a/include/core/ceres_wrapper/iteration_update_callback.h +++ b/include/core/ceres_wrapper/iteration_update_callback.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * iteration_callback.h - * - * Created on: Jun 15, 2020 - * Author: joanvallve - */ - -#ifndef INCLUDE_CORE_CERES_WRAPPER_ITERATION_UPDATE_CALLBACK_H_ -#define INCLUDE_CORE_CERES_WRAPPER_ITERATION_UPDATE_CALLBACK_H_ +#pragma once #include "core/problem/problem.h" #include "ceres/ceres.h" @@ -76,6 +68,4 @@ class IterationUpdateCallback : public ceres::IterationCallback bool verbose_; }; -} - -#endif /* INCLUDE_CORE_CERES_WRAPPER_ITERATION_UPDATE_CALLBACK_H_ */ +} \ No newline at end of file diff --git a/include/core/ceres_wrapper/local_parametrization_wrapper.h b/include/core/ceres_wrapper/local_parametrization_wrapper.h index 51d10c49764e8386727b1acd17aab4423bbe071c..4078a974b5699520d19d6e65c650a994208d0809 100644 --- a/include/core/ceres_wrapper/local_parametrization_wrapper.h +++ b/include/core/ceres_wrapper/local_parametrization_wrapper.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef LOCAL_PARAMETRIZATION_WRAPPER_H_ -#define LOCAL_PARAMETRIZATION_WRAPPER_H_ +#pragma once // Fwd refs namespace wolf{ @@ -83,6 +82,4 @@ inline LocalParametrizationBasePtr LocalParametrizationWrapper::getLocalParametr return local_parametrization_ptr_; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/ceres_wrapper/qr_manager.h b/include/core/ceres_wrapper/qr_manager.h index d859b6a655825809c35de4808c38af0a7dbcd32e..73906bb8b8af85bc9b353d655384ef29e673af95 100644 --- a/include/core/ceres_wrapper/qr_manager.h +++ b/include/core/ceres_wrapper/qr_manager.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * qr_manager.h - * - * Created on: Jun 7, 2017 - * Author: jvallve - */ - -#ifndef SRC_CERES_WRAPPER_QR_MANAGER_H_ -#define SRC_CERES_WRAPPER_QR_MANAGER_H_ +#pragma once #include "core/solver/solver_manager.h" #include "core/solver_suitesparse/sparse_utils.h" @@ -78,6 +70,4 @@ class QRManager : public SolverManager void relinearizeFactor(FactorBasePtr _fac_ptr); }; -} /* namespace wolf */ - -#endif /* SRC_CERES_WRAPPER_QR_MANAGER_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/ceres_wrapper/solver_ceres.h b/include/core/ceres_wrapper/solver_ceres.h index da0ac085504dfe02d64ee7c0b2c4d30b0b029adb..ed7269333147655487ae83e2e0e4b24485028165 100644 --- a/include/core/ceres_wrapper/solver_ceres.h +++ b/include/core/ceres_wrapper/solver_ceres.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CERES_MANAGER_H_ -#define CERES_MANAGER_H_ +#pragma once //Ceres includes #include "ceres/jet.h" @@ -55,25 +54,25 @@ struct ParamsCeres : public ParamsSolver loadHardcodedValues(); } - ParamsCeres(std::string _unique_name, const ParamsServer& _server) : - ParamsSolver(_unique_name, _server) + ParamsCeres(const YAML::Node& _input_node) : + ParamsSolver(_input_node) { loadHardcodedValues(); // interrupt solver whenever the problem is updated (via ceres::iterationCallback) - interrupt_on_problem_change = _server.getParam<bool>(prefix + "interrupt_on_problem_change"); + interrupt_on_problem_change = _input_node["interrupt_on_problem_change"].as<bool>(); if (interrupt_on_problem_change) - min_num_iterations = _server.getParam<int>(prefix + "min_num_iterations"); + min_num_iterations = _input_node["min_num_iterations"].as<int>(); // CERES SOLVER OPTIONS - solver_options.max_num_iterations = _server.getParam<int>(prefix + "max_num_iterations"); - solver_options.function_tolerance = _server.getParam<double>(prefix + "function_tolerance"); - solver_options.gradient_tolerance = _server.getParam<double>(prefix + "gradient_tolerance"); - solver_options.num_threads = _server.getParam<int>(prefix + "n_threads"); + solver_options.max_num_iterations = _input_node["max_num_iterations"].as<int>(); + solver_options.function_tolerance = _input_node["function_tolerance"].as<double>(); + solver_options.gradient_tolerance = _input_node["gradient_tolerance"].as<double>(); + solver_options.num_threads = _input_node["n_threads"].as<int>(); covariance_options.num_threads = solver_options.num_threads; // minimizer type - std::string minimizer = _server.getParam<std::string>(prefix + "minimizer"); + std::string minimizer = _input_node["minimizer"].as<std::string>(); if (minimizer == "LEVENBERG_MARQUARDT" or minimizer == "levenberg_marquardt") { solver_options.minimizer_type = ceres::TRUST_REGION; @@ -102,9 +101,9 @@ struct ParamsCeres : public ParamsSolver // specific options for TRUST REGION if (solver_options.minimizer_type == ceres::TRUST_REGION) { - solver_options.use_nonmonotonic_steps = _server.getParam<bool>(prefix + "use_nonmonotonic_steps"); + solver_options.use_nonmonotonic_steps = _input_node["use_nonmonotonic_steps"].as<bool>(); if (solver_options.use_nonmonotonic_steps) - solver_options.max_consecutive_nonmonotonic_steps = _server.getParam<int>(prefix + "max_consecutive_nonmonotonic_steps"); + solver_options.max_consecutive_nonmonotonic_steps = _input_node["max_consecutive_nonmonotonic_steps"].as<int>(); } } @@ -262,6 +261,4 @@ inline int SolverCeres::numFactorsDerived() const return ceres_problem_->NumResidualBlocks(); }; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/ceres_wrapper/sparse_utils.h b/include/core/ceres_wrapper/sparse_utils.h index e0d70f26f95c2d5dfd10131e48103586c52fd20d..9c2e6422e84a8747ec8a468f7ba7c1fca1089394 100644 --- a/include/core/ceres_wrapper/sparse_utils.h +++ b/include/core/ceres_wrapper/sparse_utils.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * sparse_utils.h - * - * Created on: Jul 2, 2015 - * Author: jvallve - */ - -#ifndef SPARSE_UTILS_H_ -#define SPARSE_UTILS_H_ +#pragma once // eigen includes //#include <eigen3/Eigen/Sparse> @@ -124,5 +116,4 @@ void getDiagonalBlocks(const Eigen::SparseMatrix<double,_Options,_StorageIndex>& diag_.push_back(Eigen::MatrixXd(_M.block(i,i,dim,dim))); } -} // namespace wolf -#endif /* SPARSE_UTILS_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/common/factory.h b/include/core/common/factory.h index c73d042f6599a2e386a19b2d10fed02bf8dd3aa8..bd09e14228352eda82cee813692308c23cc7e2aa 100644 --- a/include/core/common/factory.h +++ b/include/core/common/factory.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factory.h - * - * Created on: May 16, 2016 - * \author: jsola - */ - -#ifndef FACTORY_H_ -#define FACTORY_H_ +#pragma once // wolf #include "core/common/wolf.h" @@ -436,6 +428,4 @@ inline std::string FactoryLandmark::getClass() const # define UNUSED(x) x #endif -} /* namespace wolf */ - -#endif /* FACTORY_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/common/node_base.h b/include/core/common/node_base.h index 1f7cf9eaff36bdbae80a8802981ea88f9ba019a6..31ae60e6c388ac9113db10ea2dfe33718b709cae 100644 --- a/include/core/common/node_base.h +++ b/include/core/common/node_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef NODE_BASE_H_ -#define NODE_BASE_H_ +#pragma once // Wolf includes #include "core/common/wolf.h" @@ -176,6 +175,4 @@ inline void NodeBase::setProblem(ProblemPtr _prob_ptr) problem_ptr_ = _prob_ptr; } -} // namespace wolf - -#endif /* NODE_BASE_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/common/params_base.h b/include/core/common/params_base.h index 51825a75307752c7ee88447dd14008e435c5a9a1..168af730ae84ff7ff832af732996f0fa702f3c19 100644 --- a/include/core/common/params_base.h +++ b/include/core/common/params_base.h @@ -19,27 +19,94 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef PARAMS_BASE_H_ -#define PARAMS_BASE_H_ +#pragma once -#include "core/utils/params_server.h" -#include "yaml-schema-cpp/yaml_server.hpp" +#include "yaml-cpp/yaml.h" -namespace wolf { - struct ParamsBase +namespace wolf +{ + +struct ParamsBase +{ + ParamsBase() = default; + ParamsBase(const YAML::Node& _n) { - ParamsBase() = default; - ParamsBase(std::string _unique_name, const ParamsServer&) - { - // - } - ParamsBase(const YAML::Node& _n) - { - // - } - - virtual ~ParamsBase() = default; - virtual std::string print() const = 0; - }; -} -#endif + // + } + + virtual ~ParamsBase() = default; + virtual std::string print() const = 0; +}; + +template<typename Derived> +std::string toString(const Eigen::DenseBase<Derived>& mat) +{ + std::stringstream ss; + if (mat.cols() == 1) + ss << mat.transpose(); + else + ss << std::endl << mat; + return ss.str(); +} + +std::string toString(bool _arg); +std::string toString(int _arg); +std::string toString(long _arg); +std::string toString(long long _arg); +std::string toString(unsigned _arg); +std::string toString(unsigned long _arg); +std::string toString(unsigned long long _arg); +std::string toString(float _arg); +std::string toString(double _arg); +std::string toString(long double _arg); + +inline std::string toString(bool _arg) +{ + return (_arg ? "true" : "false"); +} + +inline std::string toString(int _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(long _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(long long _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(unsigned _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(unsigned long _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(unsigned long long _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(float _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(double _arg) +{ + return std::to_string(_arg); +} + +inline std::string toString(long double _arg) +{ + return std::to_string(_arg); +} +} diff --git a/include/core/common/time_stamp.h b/include/core/common/time_stamp.h index c327ab2d05f1d335e51d27ec6dfe07ebf5c5ab5c..cda69dd4a2354476a67317424cd66548204cac08 100644 --- a/include/core/common/time_stamp.h +++ b/include/core/common/time_stamp.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef TIME_STAMP_H_ -#define TIME_STAMP_H_ +#pragma once //wolf includes #include "core/common/wolf.h" @@ -311,6 +309,4 @@ inline double TimeStamp::operator -(const TimeStamp& ts) const return double((long int)(time_stamp_nano_ - ts.time_stamp_nano_))*1e-9; // long int cast fix overflow in case of negative substraction result } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/common/wolf.h b/include/core/common/wolf.h index 25e9325fd3b61f425f085bd47e9b788ebd494aa9..eda4914d26f887017074d5f52da1fec6ab7eeabe 100644 --- a/include/core/common/wolf.h +++ b/include/core/common/wolf.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file wolf.h - * \brief General typedefs for the Wolf project - * \author Joan Sola - * Created on: 28/05/2014 - */ - -#ifndef WOLF_H_ -#define WOLF_H_ +#pragma once // Enable project-specific definitions and macros #include "core/internal/config.h" @@ -316,6 +308,4 @@ inline bool file_exists(const std::string& _name) inline const Eigen::Vector3d gravity(void) { return Eigen::Vector3d(0,0,-9.806); } -} // namespace wolf - -#endif /* WOLF_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_analytic.h b/include/core/factor/factor_analytic.h index 88f28a3880d513ace93166d6e38cc80a178455be..536293d68ba2b1409ca6af3a1a5285248abaf722 100644 --- a/include/core/factor/factor_analytic.h +++ b/include/core/factor/factor_analytic.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef FACTOR_ANALYTIC_H_ -#define FACTOR_ANALYTIC_H_ +#pragma once //Wolf includes #include "core/factor/factor_base.h" @@ -203,6 +201,4 @@ class FactorAnalytic: public FactorBase void resizeVectors(); }; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_autodiff.h b/include/core/factor/factor_autodiff.h index c10c0b58b799f6171a418c9a6217b4d69a9e6f88..befbe579d48c44f15c321a50675b9f280921ce40 100644 --- a/include/core/factor/factor_autodiff.h +++ b/include/core/factor/factor_autodiff.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef FACTOR_AUTODIFF_H_ -#define FACTOR_AUTODIFF_H_ +#pragma once //Wolf includes #include "core/factor/factor_base.h" @@ -3340,6 +3338,4 @@ const std::vector<unsigned int> FactorAutodiff<FacT,RES,B0,B1,0,0,0,0,0,0,0,0,0, template <class FacT,unsigned int RES,unsigned int B0> const std::vector<unsigned int> FactorAutodiff<FacT,RES,B0,0,0,0,0,0,0,0,0,0,0,0>::jacobian_locations_ = {0}; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_base.h b/include/core/factor/factor_base.h index 1894148de2ea576614b14d6de81a4f138c4e037c..d35617be28a0999ddeadaa54b05597b7fd7d9015 100644 --- a/include/core/factor/factor_base.h +++ b/include/core/factor/factor_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_BASE_H_ -#define FACTOR_BASE_H_ +#pragma once // Forward declarations for node templates namespace wolf{ @@ -428,5 +427,4 @@ inline LandmarkBaseConstWPtrList FactorBase::getLandmarkOtherList() const return list_const; } -} // namespace wolf -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_block_absolute.h b/include/core/factor/factor_block_absolute.h index 3b9e464a01f6f5d9d28b2cfb3e74614e3ef4e212..51806e360fa78d15d0bc3af4bf2e420a4efbcf9f 100644 --- a/include/core/factor/factor_block_absolute.h +++ b/include/core/factor/factor_block_absolute.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factor_block_absolute.h - * - * Created on: Dec 15, 2017 - * \author: AtDinesh - */ - -#ifndef FACTOR_BLOCK_ABSOLUTE_H_ -#define FACTOR_BLOCK_ABSOLUTE_H_ +#pragma once //Wolf includes #include "core/factor/factor_analytic.h" @@ -215,6 +207,4 @@ inline unsigned int FactorBlockAbsolute::getSize() const return sb_constrained_size_; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_block_difference.h b/include/core/factor/factor_block_difference.h index 503ace5dd84ece4a7adb05205deba25883b72609..0d6c24c327e765385a012a91781a3700dcbd92e0 100644 --- a/include/core/factor/factor_block_difference.h +++ b/include/core/factor/factor_block_difference.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factor_block_difference.h - * - * Created on: Feb 28, 2020 - * \author: mfourmy - */ - -#ifndef FACTOR_BLOCK_DIFFERENCE_H_ -#define FACTOR_BLOCK_DIFFERENCE_H_ +#pragma once //Wolf includes #include "core/factor/factor_analytic.h" @@ -216,6 +208,4 @@ inline unsigned int FactorBlockDifference::getSize() const return sb1_constrained_size_; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_diff_drive.h b/include/core/factor/factor_diff_drive.h index 9606e23b17f21b8772081f090a31e16c617338de..42b34d895fc5e76e444670b30674cc43dccd2944 100644 --- a/include/core/factor/factor_diff_drive.h +++ b/include/core/factor/factor_diff_drive.h @@ -19,16 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factor_diff_drive.h - * - * Created on: Oct 27, 2017 - * \author: Jeremie Deray - * \adapted: Joan Sola - July 2019 - */ - -#ifndef WOLF_FACTOR_DIFF_DRIVE_H_ -#define WOLF_FACTOR_DIFF_DRIVE_H_ +#pragma once //Wolf includes #include "core/capture/capture_diff_drive.h" @@ -164,6 +155,4 @@ inline Eigen::VectorXd FactorDiffDrive::residual() return residual; } -} // namespace wolf - -#endif /* WOLF_FACTOR_DIFF_DRIVE_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_distance_3d.h b/include/core/factor/factor_distance_3d.h index d4207b254443ad077a0b9ad319ab333a8b0040cc..ad7a370c7b14cc49a17aed223d8949fe1a951809 100644 --- a/include/core/factor/factor_distance_3d.h +++ b/include/core/factor/factor_distance_3d.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factor_autodiff_distance_3d.h - * - * Created on: Apr 10, 2018 - * \author: jsola - */ - -#ifndef FACTOR_DISTANCE_3d_H_ -#define FACTOR_DISTANCE_3d_H_ +#pragma once #include "core/factor/factor_autodiff.h" @@ -85,6 +77,4 @@ class FactorDistance3d : public FactorAutodiff<FactorDistance3d, 1, 3, 3> } }; -} /* namespace wolf */ - -#endif /* FACTOR_DISTANCE_3d_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/factor/factor_pose_2d.h b/include/core/factor/factor_pose_2d.h index 2d3f40ed24c53cb7e28d7cb2054ccaa33140c02d..30d4c716834738159fd08ecbe3147438d34bdadf 100644 --- a/include/core/factor/factor_pose_2d.h +++ b/include/core/factor/factor_pose_2d.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef FACTOR_POSE_2d_H_ -#define FACTOR_POSE_2d_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -99,6 +97,4 @@ inline bool FactorPose2d::operator ()(const T* const _p, const T* const _o, T* _ return true; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_pose_3d.h b/include/core/factor/factor_pose_3d.h index 04f7f7b1798eb3669a2f397f1c7f2915871b1b9e..fc02776d10cd3c9f9401dbebec9708d20d20d858 100644 --- a/include/core/factor/factor_pose_3d.h +++ b/include/core/factor/factor_pose_3d.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef FACTOR_POSE_3d_H_ -#define FACTOR_POSE_3d_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -84,6 +82,4 @@ inline bool FactorPose3d::operator ()(const T* const _p, const T* const _o, T* _ return true; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_pose_3d_with_extrinsics.h b/include/core/factor/factor_pose_3d_with_extrinsics.h index 2daacba6d7d05fb2dde5356a62ccf43a18213777..0cafc061524d519c030f5542a5e4af53909a7bf9 100644 --- a/include/core/factor/factor_pose_3d_with_extrinsics.h +++ b/include/core/factor/factor_pose_3d_with_extrinsics.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_POSE_3D_WITH_EXTRINSICS_THETA_H_ -#define FACTOR_POSE_3D_WITH_EXTRINSICS_THETA_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -154,6 +153,4 @@ inline bool FactorPose3dWithExtrinsics::operator ()(const T* const _p, return true; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_quaternion_absolute.h b/include/core/factor/factor_quaternion_absolute.h index 5e93a15389990111ddb1751e635e3e11ff73c503..f760bd2de64e279c605b524e2c755585ead4edfd 100644 --- a/include/core/factor/factor_quaternion_absolute.h +++ b/include/core/factor/factor_quaternion_absolute.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factor_quaternion_absolute.h - * - * Created on: Dec 15, 2017 - * \author: AtDinesh - */ - -#ifndef FACTOR_QUATERNION_ABSOLUTE_H_ -#define FACTOR_QUATERNION_ABSOLUTE_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -102,6 +94,4 @@ inline bool FactorQuaternionAbsolute::operator ()(const T* const _o, T* _residua return true; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_relative_pose_2d.h b/include/core/factor/factor_relative_pose_2d.h index 4a608feb01c29b413b19608987767853eecf5407..3271c97d3cc8fd8b66512532e68afd00ab33339e 100644 --- a/include/core/factor/factor_relative_pose_2d.h +++ b/include/core/factor/factor_relative_pose_2d.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_RELATIVE_POSE_2d_H_ -#define FACTOR_RELATIVE_POSE_2d_H_ +#pragma once //Wolf includes #include "core/factor/factor_analytic.h" @@ -274,6 +273,4 @@ inline void FactorRelativePose2d::evaluatePureJacobians(std::vector<Eigen::Matri jacobians[3] = (Eigen::MatrixXd(3,1) << 0, 0, 1).finished(); } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_relative_pose_2d_with_extrinsics.h b/include/core/factor/factor_relative_pose_2d_with_extrinsics.h index b0eea0f2b8f91f00a9a2bc8a7bda6ce1be66dc45..67260654b58004a61e4a3d6ee612255e1861e615 100644 --- a/include/core/factor/factor_relative_pose_2d_with_extrinsics.h +++ b/include/core/factor/factor_relative_pose_2d_with_extrinsics.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_RELATIVE_POSE_2D_WITH_EXTRINSICS_H_ -#define FACTOR_RELATIVE_POSE_2D_WITH_EXTRINSICS_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -186,6 +185,4 @@ inline bool FactorRelativePose2dWithExtrinsics::operator ()(const T* const _p_re return true; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_relative_pose_3d.h b/include/core/factor/factor_relative_pose_3d.h index 6003c446732399f1abe6c4127dfb257543c82c2c..e73a3fc86ec32475cb770ea9b49fa2454b0bc0f2 100644 --- a/include/core/factor/factor_relative_pose_3d.h +++ b/include/core/factor/factor_relative_pose_3d.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * factor_relative_pose_3d.h - * - * Created on: Oct 7, 2016 - * Author: jsola - */ - -#ifndef FACTOR_RELATIVE_POSE_3D_H_ -#define FACTOR_RELATIVE_POSE_3D_H_ +#pragma once #include "core/factor/factor_autodiff.h" #include "core/math/rotations.h" @@ -254,6 +246,4 @@ inline bool FactorRelativePose3d::operator ()(const T* const _p_current, return true; } -} /* namespace wolf */ - -#endif /* FACTOR_RELATIVE_POSE_3D_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/factor/factor_relative_pose_3d_with_extrinsics.h b/include/core/factor/factor_relative_pose_3d_with_extrinsics.h index 19245f6bcf630f737e4a01aa78b4a11030d8264a..5c463ff979bcec3e254959d42024f8d85e280f12 100644 --- a/include/core/factor/factor_relative_pose_3d_with_extrinsics.h +++ b/include/core/factor/factor_relative_pose_3d_with_extrinsics.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef _FACTOR_TELATIVE_POSE_3D_WITH_EXTRINSICS -#define _FACTOR_TELATIVE_POSE_3D_WITH_EXTRINSICS +#pragma once //Wolf includes #include "core/common/wolf.h" @@ -210,6 +209,4 @@ inline double FactorRelativePose3dWithExtrinsics::cost() const return residual().squaredNorm(); } -} // namespace wolf - -#endif /* _FACTOR_TELATIVE_POSE_3D_WITH_EXTRINSICS */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/factor/factor_velocity_local_direction_3d.h b/include/core/factor/factor_velocity_local_direction_3d.h index 89d8cb1268180c4cdd1076251731f52f4329214a..c19bdc65e6ee9c1d5bf74602cfdca1c91422f004 100644 --- a/include/core/factor/factor_velocity_local_direction_3d.h +++ b/include/core/factor/factor_velocity_local_direction_3d.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef FACTOR_VELOCITY_LOCAL_DIRECTION_3D_H_ -#define FACTOR_VELOCITY_LOCAL_DIRECTION_3D_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -165,6 +163,4 @@ inline bool FactorVelocityLocalDirection3d::operator ()(const T* const _v, const return true; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/feature/feature_base.h b/include/core/feature/feature_base.h index beb5eae22b8667750d43c2a51ade0a24857c6483..e1a4a8ee8a68af60bf322cdc75d1ded12a448b33 100644 --- a/include/core/feature/feature_base.h +++ b/include/core/feature/feature_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FEATURE_BASE_H_ -#define FEATURE_BASE_H_ +#pragma once // Forward declarations for node templates namespace wolf{ @@ -258,6 +257,4 @@ inline void FeatureBase::setExpectation(const Eigen::VectorXd& expectation) expectation_ = expectation; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/feature/feature_diff_drive.h b/include/core/feature/feature_diff_drive.h index 8b756e29a415db4f6b3278497cdab946db736857..0698ff0a39384ddf460dcbaacab682fe7bdafa1a 100644 --- a/include/core/feature/feature_diff_drive.h +++ b/include/core/feature/feature_diff_drive.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file feature_diff_drive.h - * - * Created on: Oct 27, 2016 - * \author: Jeremie Deray - */ - -#ifndef _WOLF_FEATURE_DIFF_DRIVE_H_ -#define _WOLF_FEATURE_DIFF_DRIVE_H_ +#pragma once //Wolf includes #include "core/feature/feature_motion.h" @@ -49,6 +41,4 @@ class FeatureDiffDrive : public FeatureMotion }; -} /* namespace wolf */ - -#endif /* _WOLF_FEATURE_DIFF_DRIVE_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/feature/feature_match.h b/include/core/feature/feature_match.h index 36b5b2ca1cdb9f75547a092379156eac2a26746a..6315fbf4ad71fcef343ce84e8caa31155151bf54 100644 --- a/include/core/feature/feature_match.h +++ b/include/core/feature/feature_match.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FEATURE_MATCH_H_ -#define FEATURE_MATCH_H_ +#pragma once // Wolf includes #include "core/common/wolf.h" @@ -51,7 +50,4 @@ struct FeatureMatch double normalized_score_; ///< normalized similarity score (0 is bad, 1 is good) }; -}//end namespace - -#endif - +}//end namespace \ No newline at end of file diff --git a/include/core/feature/feature_motion.h b/include/core/feature/feature_motion.h index 535acdfe98317b9a1e4c801dd6e47862c1b7b4d3..0bcc316e681f44cb7d570db42246da3967b50a6c 100644 --- a/include/core/feature/feature_motion.h +++ b/include/core/feature/feature_motion.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * feature_motion.h - * - * Created on: Aug 11, 2017 - * Author: jsola - */ - -#ifndef FEATURE_MOTION_H_ -#define FEATURE_MOTION_H_ +#pragma once #include "core/feature/feature_base.h" #include "core/capture/capture_motion.h" @@ -71,7 +63,4 @@ inline const Eigen::MatrixXd& FeatureMotion::getJacobianCalibration() const return jacobian_calib_; } - -} /* namespace wolf */ - -#endif /* FEATURE_MOTION_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/feature/feature_odom_2d.h b/include/core/feature/feature_odom_2d.h index e83d964e061c74600a94db83623335e33f0e2e26..d130ee00e1b7778aa26af8f165fab75f666fa3c7 100644 --- a/include/core/feature/feature_odom_2d.h +++ b/include/core/feature/feature_odom_2d.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FEATURE_ODOM_2d_H_ -#define FEATURE_ODOM_2d_H_ +#pragma once //Wolf includes #include "core/feature/feature_base.h" @@ -47,6 +46,4 @@ class FeatureOdom2d : public FeatureBase ~FeatureOdom2d() override; }; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/feature/feature_pose.h b/include/core/feature/feature_pose.h index bd30ee7394a85240fe8fc69582c5c5a3ca49aabb..9d67e97fbe9b9826bf868e85a09cafcd2b456662 100644 --- a/include/core/feature/feature_pose.h +++ b/include/core/feature/feature_pose.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FEATURE_POSE_H_ -#define FEATURE_POSE_H_ +#pragma once //Wolf includes #include "core/feature/feature_base.h" @@ -47,6 +46,4 @@ class FeaturePose : public FeatureBase ~FeaturePose() override; }; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/frame/frame_base.h b/include/core/frame/frame_base.h index 8d64663585af0982d7ac3209a3fcb808c753080a..97d76c632258a5ed7177c6f8230f26ce79f6aaff 100644 --- a/include/core/frame/frame_base.h +++ b/include/core/frame/frame_base.h @@ -19,10 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - - -#ifndef FRAME_BASE_H_ -#define FRAME_BASE_H_ +#pragma once // Fwd refs namespace wolf{ @@ -327,6 +324,4 @@ inline CaptureBasePtrList FrameBase::getCapturesOfType() return captures; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/hardware/hardware_base.h b/include/core/hardware/hardware_base.h index 4e86c8892af30795657610cf5576f724a7c792d3..29d4ba6666acb5fba05c02d69067da4acbfd4ef9 100644 --- a/include/core/hardware/hardware_base.h +++ b/include/core/hardware/hardware_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef HARDWARE_BASE_H_ -#define HARDWARE_BASE_H_ +#pragma once // Fwd dependencies namespace wolf{ @@ -94,6 +93,4 @@ inline SensorBasePtrList HardwareBase::getSensorList() return sensor_list_; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/landmark/landmark_base.h b/include/core/landmark/landmark_base.h index 1d08d5748404c4bbe6151c8e28cf6827dc79f183..3f7bd7adb38a3f263361bd206534e6f06a63a691 100644 --- a/include/core/landmark/landmark_base.h +++ b/include/core/landmark/landmark_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef LANDMARK_BASE_H_ -#define LANDMARK_BASE_H_ +#pragma once // Fwd references namespace wolf{ @@ -210,5 +209,4 @@ inline const Eigen::VectorXd& LandmarkBase::getDescriptor() const return descriptor_; } -} // namespace wolf -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/landmark/landmark_match.h b/include/core/landmark/landmark_match.h index a7fbe5cc33f3c9c1761fd7d6a575df613324a316..aeb6862075f5dd465342b911b08a29b69f3dc130 100644 --- a/include/core/landmark/landmark_match.h +++ b/include/core/landmark/landmark_match.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef LANDMARK_MATCH_H_ -#define LANDMARK_MATCH_H_ +#pragma once // Wolf includes #include "core/common/wolf.h" @@ -54,6 +53,4 @@ struct LandmarkMatch } }; -}//end namespace - -#endif +}//end namespace \ No newline at end of file diff --git a/include/core/map/factory_map.h b/include/core/map/factory_map.h index 5772e4e8a1abab280f5e6ee096161e99be39d515..b5203917e48731bc4fc80ed63e967615e348b518 100644 --- a/include/core/map/factory_map.h +++ b/include/core/map/factory_map.h @@ -19,26 +19,20 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factory_map.h - * - * Created on: Jul 25, 2016 - * \author: jvallve - */ - -#ifndef FACTORY_MAP_H_ -#define FACTORY_MAP_H_ +#pragma once namespace wolf { class MapBase; -struct ParamsMapBase; } // wolf #include "core/common/factory.h" #include "core/utils/params_server.h" +// Yaml +#include "yaml-cpp/yaml.h" + namespace wolf { @@ -175,8 +169,7 @@ namespace wolf * \endcode * */ -typedef Factory<MapBase, - const ParamsMapBasePtr> FactoryMap; +typedef Factory<MapBase, const YAML::Node&> FactoryMap; template<> inline std::string FactoryMap::getClass() const @@ -184,35 +177,8 @@ inline std::string FactoryMap::getClass() const return "FactoryMap"; } -// ParamsMap factory -struct ParamsMapBase; -typedef Factory<ParamsMapBase, - const std::string&> FactoryParamsMap; -template<> -inline std::string FactoryParamsMap::getClass() const -{ - return "FactoryParamsMap"; -} - #define WOLF_REGISTER_MAP(MapType) \ namespace{ const bool WOLF_UNUSED MapType##Registered = \ - FactoryMap::registerCreator(#MapType, MapType::create); } \ - - -typedef Factory<MapBase, - const ParamsServer&> AutoConfFactoryMap; - -template<> -inline std::string AutoConfFactoryMap::getClass() const -{ - return "AutoConfFactoryMap"; -} - -#define WOLF_REGISTER_MAP_AUTO(MapType) \ - namespace{ const bool WOLF_UNUSED MapType##AutoConfRegistered = \ - AutoConfFactoryMap::registerCreator(#MapType, MapType::create); } \ - - -} /* namespace wolf */ + FactoryMap::registerCreator(#MapType, MapType::create); } \ -#endif /* SENSOR_FACTORY_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/map/map_base.h b/include/core/map/map_base.h index af09f86002c697ad026ad9942d218026808555c4..d1078082e587fe300123c84b8d1d97d498c8679d 100644 --- a/include/core/map/map_base.h +++ b/include/core/map/map_base.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef MAP_BASE_H_ -#define MAP_BASE_H_ +#pragma once // Fwd refs namespace wolf{ @@ -34,7 +32,8 @@ class LandmarkBase; #include "core/common/node_base.h" #include "core/common/params_base.h" -//std includes +//other includes +#include "yaml-schema-cpp/yaml_server.hpp" namespace wolf { @@ -51,23 +50,13 @@ namespace wolf { * * We recommend writing one of such constructors in your derived maps. */ -#define WOLF_MAP_CREATE(MapClass, ParamsMapClass) \ -static \ -MapBasePtr create(const ParamsServer& _server) \ -{ \ - auto params = std::make_shared<ParamsMapClass>(_server); \ - \ - return std::make_shared<MapClass>(params); \ -} \ - \ -static \ -MapBasePtr create(const ParamsMapBasePtr _params) \ -{ \ - auto params = std::static_pointer_cast<ParamsMapClass>(_params); \ - \ - return std::make_shared<MapClass>(params); \ -} \ - +#define WOLF_MAP_CREATE(MapClass, ParamsMapClass) \ +static MapBasePtr create(const YAML::Node& _node_input) \ +{ \ + auto params = std::make_shared<ParamsMapClass>(_node_input); \ + \ + return std::make_shared<MapClass>(params); \ +} \ /** \brief base struct for map parameters * @@ -77,8 +66,8 @@ struct ParamsMapBase: public ParamsBase { std::string prefix = "map"; - ParamsMapBase(const ParamsServer& _param_server) : - ParamsBase("map", _param_server) + ParamsMapBase(const YAML::Node& _input_node) : + ParamsBase(_input_node) { }; @@ -150,6 +139,4 @@ inline LandmarkBasePtrList MapBase::getLandmarkList() return landmark_list_; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/math/SE2.h b/include/core/math/SE2.h index 95631a8a6fb82ac22595b64d3e1d5b4fe7849cb4..32dbd2fc4f2854af11d40f22cbaab19d4185b3d1 100644 --- a/include/core/math/SE2.h +++ b/include/core/math/SE2.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file SE2.h - * - * Created on: Jul 27, 2019 - * \author: jsola - */ - -#ifndef MATH_SE2_H_ -#define MATH_SE2_H_ +#pragma once #include "core/common/wolf.h" #include "core/math/rotations.h" @@ -483,6 +475,4 @@ inline Matrix<typename D1::Scalar, 3, 1> between(const MatrixBase<D1>& d1, } } // namespace SE2 -} // namespacs wolf - -#endif /* MATH_SE2_H_ */ +} // namespacs wolf \ No newline at end of file diff --git a/include/core/math/SE3.h b/include/core/math/SE3.h index 7917935549619fbc58cc917e834d5ae735d90d41..701dfebf4811b399dbd5af22ec2578f0402e2563 100644 --- a/include/core/math/SE3.h +++ b/include/core/math/SE3.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * SE3.h - * - * Created on: Mar 15, 2018 - * Author: jsola - */ - -#ifndef SE3_H_ -#define SE3_H_ +#pragma once #include "core/common/wolf.h" #include "core/math/rotations.h" @@ -624,7 +616,4 @@ inline Matrix<typename D1::Scalar, 6, 6> jac_SE3_right(const MatrixBase<D1>& tan } } // namespace three_d -} // namespace wolf - - -#endif /* SE3_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/math/covariance.h b/include/core/math/covariance.h index 06ae067ccb0e7be12ead33c56839efc15256d19e..4aa6304bdec44edcd98f9684d27d90bfa4b874a7 100644 --- a/include/core/math/covariance.h +++ b/include/core/math/covariance.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file covariance.h - * - * Created on: Feb 26, 2020 - * \author: jsola - */ - -#ifndef MATH_COVARIANCE_H_ -#define MATH_COVARIANCE_H_ +#pragma once #include <Eigen/Dense> @@ -125,9 +117,4 @@ inline Eigen::MatrixXd computeSqrtUpper(const Eigen::MatrixXd & _info) return R; } - -} - - - -#endif /* MATH_COVARIANCE_H_ */ +} \ No newline at end of file diff --git a/include/core/math/rotations.h b/include/core/math/rotations.h index f33c18fcb075a9c2503556beb4907fd55ad4513e..b1cdcc26c5f0a3ce8766426b07cb187e824a0d7c 100644 --- a/include/core/math/rotations.h +++ b/include/core/math/rotations.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file rotations.h - * - * Created on: Sep 6, 2016 - * \author: jsola - */ - -#ifndef ROTATIONS_H_ -#define ROTATIONS_H_ +#pragma once #include "core/common/wolf.h" @@ -663,6 +655,4 @@ diff(const Eigen::QuaternionBase<D1>& q1, const Eigen::QuaternionBase<D2>& q2) return minus(q1, q2); } -} // namespace wolf - -#endif /* ROTATIONS_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/problem/problem.h b/include/core/problem/problem.h index 7c551678e21f932c75f084cd770b0c35165e4e2d..8fdfc1ffe4c0e16a0808d03756845620622d9629 100644 --- a/include/core/problem/problem.h +++ b/include/core/problem/problem.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef PROBLEM_H_ -#define PROBLEM_H_ +#pragma once // Fwd refs namespace wolf{ @@ -34,6 +33,7 @@ class TimeStamp; struct ParamsSensorBase; struct ParamsProcessorBase; } +class Loader; //wolf includes #include "core/common/wolf.h" @@ -47,6 +47,9 @@ struct ParamsProcessorBase; // std includes #include <mutex> +// yaml includes +#include "yaml-cpp/yaml.h" + namespace wolf { enum Notification @@ -96,11 +99,17 @@ class Problem : public std::enable_shared_from_this<Problem> void setup(); public: - static ProblemPtr create(const std::string& _frame_structure, SizeEigen _dim, MapBasePtr _map = std::make_shared<MapBase>()); // USE THIS AS A CONSTRUCTOR! - static ProblemPtr autoSetup(ParamsServer &_server); + static ProblemPtr create(const std::string& _frame_structure, + SizeEigen _dim, + MapBasePtr _map = std::make_shared<MapBase>()); // USE THIS AS A CONSTRUCTOR! + static ProblemPtr autoSetup(const std::string& _input_yaml_file, + const std::vector<std::string>& _primary_schema_folders={}); virtual ~Problem(); - + protected: + static void loadPlugin(const std::string& plugin_name, + const std::string& plugins_path, + std::list<std::shared_ptr<Loader>>& loaders); // Properties ----------------------------------------- public: @@ -126,79 +135,70 @@ class Problem : public std::enable_shared_from_this<Problem> HardwareBaseConstPtr getHardware() const; HardwareBasePtr getHardware(); - /** \brief Factory method to install (create and add) sensors only from its properties - * \param _sen_type type of sensor - * \param _unique_sensor_name unique sensor name, used to identify the particular instance of the sensor - * \param _params a base-pointer to a derived struct defining the intrinsic parameters. - * \param _priors an unordered map of the states priors indexed by their key. + /** \brief Factory method to install (create and add) sensors only from a YAML node -- Helper method loading parameters from file + * \param _sensor_node YAML node containing all necessary information to call the factory and create the sensor. */ - SensorBasePtr installSensor(const std::string& _sen_type, - const std::string& _unique_sensor_name, - ParamsSensorBasePtr _params, - const Priors& _priors); + SensorBasePtr installSensor(const YAML::Node& _sensor_node); /** \brief Factory method to install (create and add) sensors only from its properties -- Helper method loading parameters from file * \param _sen_type type of sensor - * \param _unique_sensor_name unique sensor name, used to identify the particular instance of the sensor * \param _params_yaml_filename the name of a file containing the parameters in a format compatible with the intrinsics creator registered in FactoryParamsSensor under the key _sen_type. + * \param _folders_schema a vector of paths where the schema files (to validate the YAML file) are placed */ SensorBasePtr installSensor(const std::string& _sen_type, - const std::string& _unique_sensor_name, - const std::string& _params_yaml_filename); - /**\brief Factory method to install (create and add) sensors only from its properties -- Helper method loading parameters from file + const std::string& _params_yaml_filename, + const std::vector<std::string>& _folders_schema); + /** \brief Factory method to install (create and add) sensors only from its properties * \param _sen_type type of sensor - * \param _unique_sensor_name unique sensor name, used to identify the particular instance of the sensor - * \param _server the parameter server. + * \param _params a base-pointer to a derived struct defining the intrinsic parameters. + * \param _priors an unordered map of the states priors indexed by their key. */ SensorBasePtr installSensor(const std::string& _sen_type, - const std::string& _unique_sensor_name, - const ParamsServer& _server); - /** \brief get a sensor pointer by its name - * \param _sensor_name The sensor name, as it was installed with installSensor() - */ - SensorBaseConstPtr findSensor(const std::string& _sensor_name) const; - SensorBasePtr findSensor(const std::string& _sensor_name); - - /** \brief get a processor pointer by its name - * \param _processor_name The processor name, as it was installed with installProcessor() - */ - ProcessorBaseConstPtr findProcessor(const std::string& _processor_name) const; - ProcessorBasePtr findProcessor(const std::string& _processor_name); + ParamsSensorBasePtr _params, + const Priors& _priors); + /** \brief Factory method to install (create, and add to sensor) processors only from a YAML node -- Helper method loading parameters from file + * \param _processor_node YAML node containing all necessary information to call the factory and create the processor. + */ + ProcessorBasePtr installProcessor(const YAML::Node& _processor_node); + /** \brief Factory method to install (create, and add to sensor) processors only from its properties * * This method creates a Processor, and adds it to the specified sensor's list of processors + * + * This method is a helper wrapper around the version accepting a sensor pointer instead of a sensor name. * \param _prc_type type of processor - * \param _unique_processor_name unique processor name, used to identify the particular instance of the processor - * \param _corresponding_sensor_ptr pointer to the sensor where the processor will be installed. - * \param _prc_params a base-pointer to a derived struct defining the processor parameters. + * \param _corresponding_sensor_name corresponding sensor name, used to bind the processor to the particular instance of the sensor + * \param _params_yaml_filename name of formatted yaml file defining the processor parameters. + * \param _folders_schema a vector of paths where the schema files (to validate the YAML file) are placed */ - ProcessorBasePtr installProcessor(const std::string& _prc_type, // - const std::string& _unique_processor_name, // - SensorBasePtr _corresponding_sensor_ptr, // - ParamsProcessorBasePtr _prc_params = nullptr); + ProcessorBasePtr installProcessor(const std::string& _prc_type, + const std::string& _corresponding_sensor_name, + const std::string& _params_yaml_filename, + const std::vector<std::string>& _folders_schema); /** \brief Factory method to install (create, and add to sensor) processors only from its properties * * This method creates a Processor, and adds it to the specified sensor's list of processors - * - * This method is a helper wrapper around the version accepting a sensor pointer instead of a sensor name. * \param _prc_type type of processor - * \param _unique_processor_name unique processor name, used to identify the particular instance of the processor - * \param _corresponding_sensor_name corresponding sensor name, used to bind the processor to the particular instance of the sensor - * \param _params_filename name of formatted file (xml, yaml, etc) defining the processor parameters. + * \param _corresponding_sensor_ptr pointer to the sensor where the processor will be installed. + * \param _prc_params a base-pointer to a derived struct defining the processor parameters. */ - ProcessorBasePtr installProcessor(const std::string& _prc_type, // - const std::string& _unique_processor_name, // - const std::string& _corresponding_sensor_name, // - const std::string& _params_filename = ""); + ProcessorBasePtr installProcessor(const std::string& _prc_type, + SensorBasePtr _corresponding_sensor_ptr, + ParamsProcessorBasePtr _prc_params); + + /** \brief get a sensor pointer by its name + * \param _sensor_name The sensor name, as it was installed with installSensor() + */ + SensorBaseConstPtr findSensor(const std::string& _sensor_name) const; + SensorBasePtr findSensor(const std::string& _sensor_name); + + /** \brief get a processor pointer by its name + * \param _processor_name The processor name, as it was installed with installProcessor() + */ + ProcessorBaseConstPtr findProcessor(const std::string& _processor_name) const; + ProcessorBasePtr findProcessor(const std::string& _processor_name); - /** - Custom installProcessor to be used with parameters server - */ - ProcessorBasePtr installProcessor(const std::string& _prc_type, // - const std::string& _unique_processor_name, // - const std::string& _corresponding_sensor_name, // - const ParamsServer& _server); protected: /** \brief Set the processor motion * @@ -501,8 +501,4 @@ inline void Problem::consumeNotifications(std::map<StateBlockPtr,Notification>& _fac_notification_map = std::move(factor_notification_map_); } -} // namespace wolf - - - -#endif // PROBLEM_H +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/factory_processor.h b/include/core/processor/factory_processor.h index c4918dea51cc9a233954827fa52979e12201dd64..253ccb9361aa6a69cb8c67a60ee46211df15d65f 100644 --- a/include/core/processor/factory_processor.h +++ b/include/core/processor/factory_processor.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factory_processor.h - * - * Created on: May 4, 2016 - * \author: jsola - */ - -#ifndef FACTORY_PROCESSOR_H_ -#define FACTORY_PROCESSOR_H_ +#pragma once namespace wolf { @@ -126,26 +118,16 @@ namespace wolf * */ typedef Factory<ProcessorBase, - const std::string&, - const ParamsProcessorBasePtr> FactoryProcessor; + const YAML::Node&> FactoryProcessor; template<> inline std::string FactoryProcessor::getClass() const { - return "FactoryProcessor"; + return "FactoryProcessor"; } typedef Factory<ProcessorBase, const std::string&, - const ParamsServer&> FactoryProcessorServer; -template<> -inline std::string FactoryProcessorServer::getClass() const -{ - return "FactoryProcessorServer"; -} - -typedef Factory<ProcessorBase, - const std::string&, - const std::string&> FactoryProcessorYaml; + const std::vector<std::string>&> FactoryProcessorYaml; template<> inline std::string FactoryProcessorYaml::getClass() const { @@ -153,32 +135,19 @@ inline std::string FactoryProcessorYaml::getClass() const } typedef Factory<ProcessorBase, - const YAML::Node&> FactoryProcessorYamlNode; -template<> -inline std::string FactoryProcessorYamlNode::getClass() const -{ - return "FactoryProcessorYamlNode"; -} - -// ParamsProcessor factory -struct ParamsProcessorBase; -typedef Factory<ParamsProcessorBase, - const std::string&> FactoryParamsProcessor; + std::shared_ptr<ParamsProcessorBase>> FactoryProcessorParams; template<> -inline std::string FactoryParamsProcessor::getClass() const +inline std::string FactoryProcessorParams::getClass() const { - return "FactoryParamsProcessor"; + return "FactoryProcessorParams"; } #define WOLF_REGISTER_PROCESSOR(ProcessorType) \ - namespace{ const bool WOLF_UNUSED ProcessorType##ServerRegistered = \ - wolf::FactoryProcessorServer::registerCreator(#ProcessorType, ProcessorType::create); } \ namespace{ const bool WOLF_UNUSED ProcessorType##Registered = \ wolf::FactoryProcessor::registerCreator(#ProcessorType, ProcessorType::create); } \ namespace{ const bool WOLF_UNUSED ProcessorType##YamlRegistered = \ wolf::FactoryProcessorYaml::registerCreator(#ProcessorType, ProcessorType::create); } \ - namespace{ const bool WOLF_UNUSED ProcessorType##YamlNodeRegistered = \ - wolf::FactoryProcessorYamlNode::registerCreator(#ProcessorType, ProcessorType::create); } \ + namespace{ const bool WOLF_UNUSED ProcessorType##ParamsRegistered = \ + wolf::FactoryProcessorParams::registerCreator(#ProcessorType, ProcessorType::create); } \ -} /* namespace wolf */ -#endif /* PROCESSOR_FACTORY_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/processor/motion_buffer.h b/include/core/processor/motion_buffer.h index 4763d0bc45d513611d34775754898da9290b7aec..343247a93f07350eacb9296bbfdbf201962db4a9 100644 --- a/include/core/processor/motion_buffer.h +++ b/include/core/processor/motion_buffer.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file motion_buffer.h - * - * Created on: Apr 14, 2016 - * \author: jsola - */ - -#ifndef SRC_MOTIONBUFFER_H_ -#define SRC_MOTIONBUFFER_H_ +#pragma once #include "core/common/wolf.h" #include "core/common/time_stamp.h" @@ -103,6 +95,4 @@ class MotionBuffer : public std::list<Motion> void print(bool show_data = 0, bool show_delta = 0, bool show_delta_int = 0, bool show_jacs = 0); }; -} // namespace wolf - -#endif /* SRC_MOTIONBUFFER_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/motion_provider.h b/include/core/processor/motion_provider.h index 2f6a63573941ce7c58bc45fc98094c710567dea1..9cec9025a6dc5874b93b63e5fa2f64f520e9d072 100644 --- a/include/core/processor/motion_provider.h +++ b/include/core/processor/motion_provider.h @@ -19,19 +19,12 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file motion_provider.h - * - * Created on: Mar 10, 2020 - * \author: jsola - */ - -#ifndef PROCESSOR_MOTION_PROVIDER_H_ -#define PROCESSOR_MOTION_PROVIDER_H_ +#pragma once #include "core/common/wolf.h" #include "core/state_block/state_composite.h" -#include "core/utils/params_server.h" +#include "core/common/params_base.h" // for toString +#include "yaml-cpp/yaml.h" namespace wolf { @@ -44,11 +37,11 @@ struct ParamsMotionProvider int state_priority = 1; ParamsMotionProvider() = default; - ParamsMotionProvider(std::string _unique_name, const ParamsServer& _server) + ParamsMotionProvider(const YAML::Node& _n) { - state_getter = _server.getParam<bool>("processor/" + _unique_name + "/state_getter"); + state_getter = _n["state_getter"].as<bool>(); if (state_getter) - state_priority = _server.getParam<double>("processor/" + _unique_name + "/state_priority"); + state_priority = _n["state_priority"].as<double>(); } std::string print() const { @@ -127,6 +120,4 @@ inline void MotionProvider::setStatePriority(int _priority) params_motion_provider_->state_priority = _priority; } -} /* namespace wolf */ - -#endif /* PROCESSOR_MOTION_PROVIDER_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index 62019c087088db640e09f86d846807ab6f84d8cb..4bced936e7fcdfd70e508b6fdb7476b7f10a1bf6 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef PROCESSOR_BASE_H_ -#define PROCESSOR_BASE_H_ +#pragma once // Fwd refs namespace wolf{ @@ -30,7 +29,7 @@ class SensorBase; // Wolf includes #include "core/common/wolf.h" #include "core/common/node_base.h" -#include <core/processor/motion_provider.h> +#include "core/processor/motion_provider.h" #include "core/sensor/sensor_base.h" #include "core/frame/frame_base.h" #include "core/common/time_stamp.h" @@ -41,6 +40,9 @@ class SensorBase; #include <map> #include <chrono> +// yaml +#include "yaml-cpp/yaml.h" + namespace wolf { /* @@ -53,53 +55,43 @@ namespace wolf { * must have a constructor available with the API: * * ProcessorClass(const ParamsProcessorClassPtr _params); + * + * Also, there should be the schema file 'SensorClass.schema' containing the specifications + * of the user input yaml file. */ -#define WOLF_PROCESSOR_CREATE(ProcessorClass, ParamsProcessorClass) \ -static ProcessorBasePtr create(const std::string& _unique_name, \ - const ParamsServer& _server) \ -{ \ - auto params = std::make_shared<ParamsProcessorClass>(_unique_name, _server); \ - \ - auto processor = std::make_shared<ProcessorClass>(params); \ - \ - processor ->setName(_unique_name); \ - \ - return processor; \ -} \ -static ProcessorBasePtr create(const std::string& _unique_name, \ - const ParamsProcessorBasePtr _params) \ -{ \ - auto params = std::static_pointer_cast<ParamsProcessorClass>(_params); \ - \ - auto processor = std::make_shared<ProcessorClass>(params); \ - \ - processor ->setName(_unique_name); \ - \ - return processor; \ -} \ -static ProcessorBasePtr create(const std::string& _unique_name, \ - const std::string& _yaml_filepath) \ -{ \ - auto parser = ParserYaml(_yaml_filepath, true); \ - \ - auto server = ParamsServer(parser.getParams(), "processor/" + _unique_name); \ - \ - auto params = std::make_shared<ParamsProcessorClass>(_unique_name, server); \ - \ - auto processor = std::make_shared<ProcessorClass>(params); \ - \ - processor ->setName(_unique_name); \ - \ - return processor; \ -} \ -static ProcessorBasePtr create(const YAML::Node& _input_node) \ -{ \ - auto params = std::make_shared<ParamsProcessorClass>(_input_node); \ - \ - auto processor = std::make_shared<ProcessorClass>(params); \ - \ - return processor; \ -} \ +#define WOLF_PROCESSOR_CREATE(ProcessorClass, ParamsProcessorClass) \ +static ProcessorBasePtr create(const YAML::Node& _input_node) \ +{ \ + auto params = std::make_shared<ParamsProcessorClass>(_input_node); \ + \ + return std::make_shared<ProcessorClass>(params); \ +} \ +static ProcessorBasePtr create(const std::string& _yaml_filepath, \ + const std::vector<std::string>& _folders_schema) \ +{ \ + auto server = yaml_schema_cpp::YamlServer(_folders_schema, _yaml_filepath); \ + \ + if (not server.validate(#ProcessorClass)) \ + { \ + WOLF_ERROR(server.getLog().str()); \ + return nullptr; \ + } \ + auto params = std::make_shared<ParamsProcessorClass>(server.getNode()); \ + \ + return std::make_shared<ProcessorClass>(params); \ +} \ +static ProcessorBasePtr create(const ParamsProcessorBasePtr _params) \ +{ \ + auto params_derived = std::dynamic_pointer_cast<ParamsProcessorClass>(_params); \ + if (not params_derived) \ + { \ + WOLF_ERROR("In " #ProcessorClass " creator:", \ + " _params is not of type " #ParamsProcessorClass "!"); \ + return nullptr; \ + } \ + \ + return std::make_shared<ProcessorClass>(params_derived); \ +} \ /** \brief Buffer for arbitrary type objects @@ -222,18 +214,11 @@ class BufferCapture : public Buffer<CaptureBasePtr> {}; */ struct ParamsProcessorBase : public ParamsBase { - std::string prefix = "processor/"; ParamsProcessorBase() = default; - ParamsProcessorBase(std::string _unique_name, const ParamsServer& _server): - ParamsBase(_unique_name, _server) - { - time_tolerance = _server.getParam<double>(prefix + _unique_name + "/time_tolerance"); - voting_active = _server.getParam<bool>(prefix + _unique_name + "/keyframe_vote/voting_active"); - apply_loss_function = _server.getParam<bool>(prefix + _unique_name + "/apply_loss_function"); - } ParamsProcessorBase(const YAML::Node& _n): ParamsBase(_n) { + name = _n["name"].as<std::string>(); time_tolerance = _n["time_tolerance"].as<double>(); voting_active = _n["keyframe_vote"]["voting_active"].as<bool>(); apply_loss_function = _n["apply_loss_function"].as<bool>(); @@ -245,13 +230,15 @@ struct ParamsProcessorBase : public ParamsBase * a particular Capture of this processor to allow assigning * this Capture to the Keyframe. */ + std::string name; double time_tolerance; bool voting_active; ///< Whether this processor is allowed to vote for a Key Frame or not bool apply_loss_function; ///< Whether this processor emplaces factors with loss function or not std::string print() const override { - return "voting_active: " + toString(voting_active) + "\n" + return "name: " + name + "\n" + + "voting_active: " + toString(voting_active) + "\n" + "time_tolerance: " + toString(time_tolerance) + "\n" + "apply_loss_function: " + toString(apply_loss_function) + "\n"; } @@ -712,6 +699,4 @@ inline bool Buffer<T>::checkTimeTolerance(const TimeStamp& _time_stamp1, return pass; } -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/processor_diff_drive.h b/include/core/processor/processor_diff_drive.h index 5e9b1012c8408f481fae04c1f4cb40e1dcfbbaba..8b81af6a87015310996aa535239a38b9c3f5a103 100644 --- a/include/core/processor/processor_diff_drive.h +++ b/include/core/processor/processor_diff_drive.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file processor_diff_drive.h - * - * Created on: Jul 22, 2019 - * \author: jsola - */ - -#ifndef PROCESSOR_PROCESSOR_DIFF_DRIVE_H_ -#define PROCESSOR_PROCESSOR_DIFF_DRIVE_H_ +#pragma once #include "core/processor/processor_odom_2d.h" @@ -39,10 +31,6 @@ WOLF_STRUCT_PTR_TYPEDEFS(ParamsProcessorDiffDrive); struct ParamsProcessorDiffDrive : public ParamsProcessorOdom2d { ParamsProcessorDiffDrive() = default; - ParamsProcessorDiffDrive(std::string _unique_name, const wolf::ParamsServer & _server) : - ParamsProcessorOdom2d(_unique_name, _server) - { - } ParamsProcessorDiffDrive(const YAML::Node& _n) : ParamsProcessorOdom2d(_n) { @@ -108,7 +96,4 @@ inline void ProcessorDiffDrive::setCalibration (const CaptureBasePtr _capture, c } -} - - -#endif /* PROCESSOR_PROCESSOR_DIFF_DRIVE_H_ */ +} \ No newline at end of file diff --git a/include/core/processor/processor_fixed_wing_model.h b/include/core/processor/processor_fixed_wing_model.h index 607f2cf9d25c6b352edac0c69f4fa4b3cbb8dce9..26e7d8867eb5f2b20d4450e80d52c88bdd94f37e 100644 --- a/include/core/processor/processor_fixed_wing_model.h +++ b/include/core/processor/processor_fixed_wing_model.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * processor_fix_wing_model.h - * - * Created on: Sep 6, 2021 - * Author: joanvallve - */ - -#ifndef INCLUDE_CORE_PROCESSOR_PROCESSOR_FIXED_WING_MODEL_H_ -#define INCLUDE_CORE_PROCESSOR_PROCESSOR_FIXED_WING_MODEL_H_ +#pragma once #include "core/processor/processor_base.h" @@ -43,15 +35,6 @@ struct ParamsProcessorFixedWingModel : public ParamsProcessorBase double min_vel_norm; ParamsProcessorFixedWingModel() = default; - ParamsProcessorFixedWingModel(std::string _unique_name, const wolf::ParamsServer & _server) : - ParamsProcessorBase(_unique_name, _server) - { - velocity_local = _server.getParam<Eigen::Vector3d> (prefix + _unique_name + "/velocity_local"); - angle_stdev = _server.getParam<double> (prefix + _unique_name + "/angle_stdev"); - min_vel_norm = _server.getParam<double> (prefix + _unique_name + "/min_vel_norm"); - - assert(std::abs(velocity_local.norm() - 1.0) < wolf::Constants::EPS && "ParamsProcessorFixedWingModel: 'velocity_local' must be normalized"); - } ParamsProcessorFixedWingModel(const YAML::Node & _n) : ParamsProcessorBase(_n) { @@ -117,6 +100,4 @@ class ProcessorFixedWingModel : public ProcessorBase ParamsProcessorFixedWingModelPtr params_processor_; }; -} /* namespace wolf */ - -#endif /* INCLUDE_CORE_PROCESSOR_PROCESSOR_FIXED_WING_MODEL_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/processor/processor_loop_closure.h b/include/core/processor/processor_loop_closure.h index 78e480fdd2eee35d426f18549acce013b1d246e5..14c8324d4fc77e6e763c02efc3d8f97b26ca053b 100644 --- a/include/core/processor/processor_loop_closure.h +++ b/include/core/processor/processor_loop_closure.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef _WOLF_PROCESSOR_LOOP_CLOSURE_BASE_H -#define _WOLF_PROCESSOR_LOOP_CLOSURE_BASE_H +#pragma once // Wolf related headers #include "core/processor/processor_base.h" @@ -34,11 +33,6 @@ struct ParamsProcessorLoopClosure : public ParamsProcessorBase int max_loops=-1; ParamsProcessorLoopClosure() = default; - ParamsProcessorLoopClosure(std::string _unique_name, const ParamsServer& _server): - ParamsProcessorBase(_unique_name, _server) - { - max_loops = _server.getParam<int>(prefix + _unique_name + "/max_loops"); - } ParamsProcessorLoopClosure(const YAML::Node& _n): ParamsProcessorBase(_n) { @@ -131,6 +125,4 @@ class ProcessorLoopClosure : public ProcessorBase bool voteForKeyFrame() const override { return false;}; }; -} // namespace wolf - -#endif /* _WOLF_PROCESSOR_LOOP_CLOSURE_BASE_H */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h index e9b1597f96effd18b2ff273f00d7cc369eb98cfc..3a2e7a60c1430e42cd19ab31352984f2c1515199 100644 --- a/include/core/processor/processor_motion.h +++ b/include/core/processor/processor_motion.h @@ -19,22 +19,13 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file processor_motion.h - * - * Created on: 15/03/2016 - * \author: jsola - */ - -#ifndef PROCESSOR_MOTION_H_ -#define PROCESSOR_MOTION_H_ +#pragma once // Wolf #include <core/processor/motion_provider.h> #include "core/capture/capture_motion.h" #include "core/processor/processor_base.h" #include "core/common/time_stamp.h" -#include "core/utils/params_server.h" // std #include <iomanip> @@ -53,16 +44,6 @@ struct ParamsProcessorMotion : public ParamsProcessorBase, public ParamsMotionPr double unmeasured_perturbation_std = 1e-4; ParamsProcessorMotion() = default; - ParamsProcessorMotion(std::string _unique_name, const ParamsServer& _server): - ParamsProcessorBase(_unique_name, _server), - ParamsMotionProvider(_unique_name, _server) - { - max_time_span = _server.getParam<double>(prefix + _unique_name + "/keyframe_vote/max_time_span"); - max_buff_length = _server.getParam<unsigned int>(prefix + _unique_name + "/keyframe_vote/max_buff_length"); - dist_traveled = _server.getParam<double>(prefix + _unique_name + "/keyframe_vote/dist_traveled"); - angle_turned = _server.getParam<double>(prefix + _unique_name + "/keyframe_vote/angle_turned"); - unmeasured_perturbation_std = _server.getParam<double>(prefix + _unique_name + "/unmeasured_perturbation_std"); - } ParamsProcessorMotion(const YAML::Node& _n): ParamsProcessorBase(_n), ParamsMotionProvider(_n) @@ -696,6 +677,4 @@ inline void ProcessorMotion::setAngleTurned(const double& _angle_turned) params_motion_->angle_turned = _angle_turned; } -} // namespace wolf - -#endif /* PROCESSOR_MOTION2_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/processor_odom_2d.h b/include/core/processor/processor_odom_2d.h index 51ada92bbe6e758a497c3fee642e35bd1c49fa67..e5dd0d822f34922f8afeba03ee71ab85d7b8d68c 100644 --- a/include/core/processor/processor_odom_2d.h +++ b/include/core/processor/processor_odom_2d.h @@ -19,20 +19,11 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file processor_odom_2d.h - * - * Created on: Apr 15, 2016 - * \author: jvallve - */ - -#ifndef SRC_PROCESSOR_ODOM_2d_H_ -#define SRC_PROCESSOR_ODOM_2d_H_ +#pragma once #include "core/processor/processor_motion.h" #include "core/capture/capture_odom_2d.h" #include "core/math/rotations.h" -#include "core/utils/params_server.h" #include "core/math/SE2.h" namespace wolf { @@ -45,10 +36,10 @@ struct ParamsProcessorOdom2d : public ParamsProcessorMotion double cov_det = 1.0; ParamsProcessorOdom2d() = default; - ParamsProcessorOdom2d(std::string _unique_name, const wolf::ParamsServer & _server) : - ParamsProcessorMotion(_unique_name, _server) + ParamsProcessorOdom2d(const YAML::Node& _n) : + ParamsProcessorMotion(_n) { - cov_det = _server.getParam<double>(prefix + _unique_name + "/keyframe_vote/cov_det"); + cov_det = _n["keyframe_vote"]["cov_det"].as<double>(); } std::string print() const override @@ -137,6 +128,4 @@ inline void ProcessorOdom2d::setCalibration (const CaptureBasePtr _capture, cons { } -} // namespace wolf - -#endif /* SRC_PROCESSOR_ODOM_2d_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/processor_odom_3d.h b/include/core/processor/processor_odom_3d.h index 3008bbc807747525f549cf8a349d73a38b088c0f..8118344916d696f262fc3227dab735e2b56a4cc7 100644 --- a/include/core/processor/processor_odom_3d.h +++ b/include/core/processor/processor_odom_3d.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file processor_odom_3d.h - * - * Created on: Mar 18, 2016 - * \author: jsola - */ - -#ifndef SRC_PROCESSOR_ODOM_3d_H_ -#define SRC_PROCESSOR_ODOM_3d_H_ +#pragma once #include "core/processor/processor_motion.h" #include "core/capture/capture_odom_3d.h" @@ -42,8 +34,8 @@ WOLF_STRUCT_PTR_TYPEDEFS(ParamsProcessorOdom3d); struct ParamsProcessorOdom3d : public ParamsProcessorMotion { ParamsProcessorOdom3d() = default; - ParamsProcessorOdom3d(std::string _unique_name, const ParamsServer& _server): - ParamsProcessorMotion(_unique_name, _server) + ParamsProcessorOdom3d(const YAML::Node& _n): + ParamsProcessorMotion(_n) { // } @@ -141,6 +133,4 @@ inline Eigen::VectorXd ProcessorOdom3d::deltaZero() const return (Eigen::VectorXd(7) << 0,0,0, 0,0,0,1).finished(); // p, q } -} // namespace wolf - -#endif /* SRC_PROCESSOR_ODOM_3d_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/processor_pose.h b/include/core/processor/processor_pose.h index ca5cd69cd5c06f9455c0948cd1a476b76a882303..e3cb9e497570d7684acd2257779553f0830218b2 100644 --- a/include/core/processor/processor_pose.h +++ b/include/core/processor/processor_pose.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef PROCESSOR_POSE_NOMOVE_H -#define PROCESSOR_POSE_NOMOVE_H +#pragma once // Wolf #include "core/sensor/sensor_base.h" @@ -36,14 +35,14 @@ WOLF_STRUCT_PTR_TYPEDEFS(ParamsProcessorPose); struct ParamsProcessorPose : public ParamsProcessorBase { ParamsProcessorPose() = default; - ParamsProcessorPose(std::string _unique_name, const ParamsServer& _server): - ParamsProcessorBase(_unique_name, _server) + ParamsProcessorPose(const YAML::Node& _n): + ParamsProcessorBase(_n) { } ~ParamsProcessorPose() override = default; std::string print() const override { - return "\n" + ParamsProcessorBase::print() + "\n"; + return ParamsProcessorBase::print(); } }; @@ -71,19 +70,4 @@ class ProcessorPose : public ProcessorBase{ ParamsProcessorPosePtr params_pfnomove_; }; - - - - -} /* namespace wolf */ - -///////////////////////////////////////////////////////// -// IMPLEMENTATION. Put your implementation includes here -///////////////////////////////////////////////////////// - - -namespace wolf{ - -} // namespace wolf - -#endif // PROCESSOR_POSE_NOMOVE_H +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/processor/processor_tracker.h b/include/core/processor/processor_tracker.h index 5ea080d61972b224d7aa64ea4a691d964274fb6d..b4461c7e101f031a768d24b4912a06d0a1a5dad4 100644 --- a/include/core/processor/processor_tracker.h +++ b/include/core/processor/processor_tracker.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * processor_tracker.h - * - * Created on: Apr 7, 2016 - * Author: jvallve - */ - -#ifndef SRC_PROCESSOR_TRACKER_H_ -#define SRC_PROCESSOR_TRACKER_H_ +#pragma once #include "core/processor/processor_base.h" #include "core/capture/capture_motion.h" @@ -42,11 +34,11 @@ struct ParamsProcessorTracker : public ParamsProcessorBase int max_new_features; ///< maximum nbr. of new features to be processed when adding a keyframe (-1: unlimited. 0: none.) ParamsProcessorTracker() = default; - ParamsProcessorTracker(std::string _unique_name, const wolf::ParamsServer & _server): - ParamsProcessorBase(_unique_name, _server) + ParamsProcessorTracker(const YAML::Node& _n): + ParamsProcessorBase(_n) { - min_features_for_keyframe = _server.getParam<unsigned int>(prefix + _unique_name + "/keyframe_vote/min_features_for_keyframe"); - max_new_features = _server.getParam<int>(prefix + _unique_name + "/max_new_features"); + min_features_for_keyframe = _n["keyframe_vote"]["min_features_for_keyframe"].as<unsigned int>(); + max_new_features = _n["max_new_features"].as<int>(); } std::string print() const override { @@ -353,6 +345,4 @@ inline CaptureBasePtr ProcessorTracker::getIncoming() return incoming_ptr_; } -} // namespace wolf - -#endif /* SRC_PROCESSOR_TRACKER_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/processor_tracker_feature.h b/include/core/processor/processor_tracker_feature.h index f9c954bf2fe4c0877c01bb75833f8e56bb687417..e76d8103fea857d725c52e9bafc365940907cd61 100644 --- a/include/core/processor/processor_tracker_feature.h +++ b/include/core/processor/processor_tracker_feature.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * \processor_tracker_feature.h - * - * Created on: 27/02/2016 - * \author: jsola - */ - -#ifndef PROCESSOR_TRACKER_FEATURE_H_ -#define PROCESSOR_TRACKER_FEATURE_H_ +#pragma once //wolf includes #include "core/processor/processor_tracker.h" @@ -215,6 +207,4 @@ class ProcessorTrackerFeature : public ProcessorTracker void establishFactors() override; }; -} // namespace wolf - -#endif /* PROCESSOR_TRACKER_FEATURE_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/processor/processor_tracker_landmark.h b/include/core/processor/processor_tracker_landmark.h index bbccccf950aa02f499d215a21f5488a724330435..b11ae12b524dd1ce31c3e7c938b164073ce6953d 100644 --- a/include/core/processor/processor_tracker_landmark.h +++ b/include/core/processor/processor_tracker_landmark.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file processor_tracker_landmark.h - * - * Created on: Apr 7, 2016 - * \author: jvallve - */ - -#ifndef PROCESSOR_TRACKER_LANDMARK_H_ -#define PROCESSOR_TRACKER_LANDMARK_H_ +#pragma once //wolf includes #include "core/processor/processor_tracker.h" @@ -205,9 +197,4 @@ class ProcessorTrackerLandmark : public ProcessorTracker void establishFactors() override; }; -}// namespace wolf - -// IMPLEMENTATION -#include "core/landmark/landmark_base.h" - -#endif /* PROCESSOR_TRACKER_LANDMARK_H_ */ +}// namespace wolf \ No newline at end of file diff --git a/include/core/processor/track_matrix.h b/include/core/processor/track_matrix.h index 3b06c46381d24a2191ec271b7a741b121b26fbbb..af045f432b0ef9970f36d02416c7725f38470d03 100644 --- a/include/core/processor/track_matrix.h +++ b/include/core/processor/track_matrix.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file track_matrix.h - * - * Created on: Mar 24, 2018 - * \author: jsola - */ - -#ifndef TRACK_MATRIX_H_ -#define TRACK_MATRIX_H_ +#pragma once #include "core/feature/feature_base.h" #include "core/capture/capture_base.h" @@ -148,6 +140,4 @@ class TrackMatrix map<CaptureBasePtr, Snapshot > snapshots_; // map indexed by capture_ptr of ( maps indexed by track_Id of ( features ) ) }; -} /* namespace wolf */ - -#endif /* TRACK_MATRIX_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/sensor/factory_sensor.h b/include/core/sensor/factory_sensor.h index 0cd4418a68d052423c03f581d99bd1075821a4aa..fa8cc69e3cd8dbaa6f00d993b5d735054dcc9d09 100644 --- a/include/core/sensor/factory_sensor.h +++ b/include/core/sensor/factory_sensor.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factory_sensor.h - * - * Created on: Apr 25, 2016 - * \author: jsola - */ - -#ifndef FACTORY_SENSOR_H_ -#define FACTORY_SENSOR_H_ +#pragma once namespace wolf { @@ -42,6 +34,9 @@ class Prior; // wolf #include "core/common/factory.h" +// yaml +#include "yaml-cpp/yaml.h" + namespace wolf { @@ -215,20 +210,18 @@ namespace wolf */ typedef Factory<SensorBase, - const std::string&, SizeEigen, - const ParamsServer&> FactorySensor; + const YAML::Node&> FactorySensor; typedef Factory<SensorBase, - const std::string&, SizeEigen, - const std::string&> FactorySensorYaml; + const std::string&, + const std::vector<std::string>&> FactorySensorYaml; typedef Factory<SensorBase, - const std::string&, SizeEigen, std::shared_ptr<ParamsSensorBase>, - const std::unordered_map<char,Prior>& > FactorySensorPriors; + const Priors& > FactorySensorPriors; template<> inline std::string FactorySensor::getClass() const @@ -254,6 +247,4 @@ inline std::string FactorySensorPriors::getClass() const namespace{ const bool WOLF_UNUSED SensorType##PriorsRegistered = \ FactorySensorPriors::registerCreator(#SensorType, SensorType::create);} \ -} /* namespace wolf */ - -#endif /* SENSOR_FACTORY_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/sensor/sensor_base.h b/include/core/sensor/sensor_base.h index e0840a59eabd6e086cd6e78ae7226368d003db75..f1322b58b96c074c2e6c9032002b1dd947f77df5 100644 --- a/include/core/sensor/sensor_base.h +++ b/include/core/sensor/sensor_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef SENSOR_BASE_H_ -#define SENSOR_BASE_H_ +#pragma once // Fwd refs namespace wolf{ @@ -37,8 +36,7 @@ class ParamsServer; #include "core/common/time_stamp.h" #include "core/common/params_base.h" #include "core/state_block/has_state_blocks.h" -//#include "core/yaml/parser_yaml.h" -#include "yaml-schema-cpp/yaml_schema.h" +#include "yaml-schema-cpp/yaml_schema.hpp" //std includes @@ -60,23 +58,11 @@ namespace wolf { * * Also, there should be the schema file 'SensorClass.schema' containing the specifications * of the user input yaml file. - * */ #define WOLF_SENSOR_CREATE(SensorClass, ParamsSensorClass) \ static SensorBasePtr create(SizeEigen _dim, \ - const YAML::Node& _input_node, \ - const std::vector<std::string>& folders_schema) \ + const YAML::Node& _input_node) \ { \ - std::stringstream log; \ - if (not yaml-schema-cpp::checkNode(_input_node, \ - SensorClass, \ - folders_schema, \ - log)) \ - { \ - WOLF_ERROR(log.str()); \ - return nullptr; \ - } \ - \ auto params = std::make_shared<ParamsSensorClass>(_input_node); \ \ auto priors = Priors(_input_node["states"]); \ @@ -85,11 +71,11 @@ static SensorBasePtr create(SizeEigen _dim, } \ static SensorBasePtr create(SizeEigen _dim, \ const std::string& _yaml_filepath, \ - const std::vector<std::string>& folders_schema) \ + const std::vector<std::string>& _folders_schema) \ { \ - auto server = yaml-schema-cpp::YamlServer(folders_schema, _yaml_filepath); \ + auto server = yaml_schema_cpp::YamlServer(_folders_schema, _yaml_filepath); \ \ - if (not server.validate(SensorClass)) \ + if (not server.validate(#SensorClass)) \ { \ WOLF_ERROR(server.getLog().str()); \ return nullptr; \ @@ -447,7 +433,4 @@ inline FeatureBasePtr SensorBase::getPriorFeature(char key) return params_prior_map_.at(key); } - -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/sensor/sensor_diff_drive.h b/include/core/sensor/sensor_diff_drive.h index 9cfd61024cfa411019a8e808230f5b2206cd187b..97f6e451a7ee5cb306fc8b57b9cb954e2f132f9e 100644 --- a/include/core/sensor/sensor_diff_drive.h +++ b/include/core/sensor/sensor_diff_drive.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef SENSOR_SENSOR_DIFF_DRIVE_H_ -#define SENSOR_SENSOR_DIFF_DRIVE_H_ +#pragma once #include "core/sensor/sensor_base.h" @@ -40,7 +38,7 @@ struct ParamsSensorDiffDrive : public ParamsSensorBase : ParamsSensorBase(_input_node) { ticks_per_wheel_revolution = _input_node["ticks_per_wheel_revolution"].as<double>(); - ticks_std_factor = _input_node["ticks_std_factor"].as<<double>(); + ticks_std_factor = _input_node["ticks_std_factor"].as<double>(); } ~ParamsSensorDiffDrive() = default; std::string print() const override @@ -58,8 +56,7 @@ class SensorDiffDrive : public SensorBase public: - SensorDiffDrive(const std::string& _unique_name, - const SizeEigen& _dim, + SensorDiffDrive(const SizeEigen& _dim, ParamsSensorDiffDrivePtr _params, const Priors& _priors); @@ -93,6 +90,4 @@ inline double SensorDiffDrive::getRadiansPerTick() const return 2.0 * M_PI / params_diff_drive_->ticks_per_wheel_revolution; } -} /* namespace wolf */ - -#endif /* SENSOR_SENSOR_DIFF_DRIVE_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/sensor/sensor_motion_model.h b/include/core/sensor/sensor_motion_model.h index 90612cc8bea6af53db9d95eb542e213795348057..3b6c56effdf72ad6acaf733150d8627f9389fbc5 100644 --- a/include/core/sensor/sensor_motion_model.h +++ b/include/core/sensor/sensor_motion_model.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef SRC_SENSOR_MOTION_MODEL_H_ -#define SRC_SENSOR_MOTION_MODEL_H_ +#pragma once //wolf includes #include "core/sensor/sensor_base.h" @@ -32,8 +31,7 @@ WOLF_PTR_TYPEDEFS(SensorMotionModel); class SensorMotionModel : public SensorBase { public: - SensorMotionModel(const std::string& _unique_name, - const SizeEigen& _dim, + SensorMotionModel(const SizeEigen& _dim, ParamsSensorBasePtr _params, const Priors& _priors); @@ -45,6 +43,4 @@ class SensorMotionModel : public SensorBase }; -} /* namespace wolf */ - -#endif /* SRC_SENSOR_MOTION_MODEL_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/sensor/sensor_odom.h b/include/core/sensor/sensor_odom.h index bcba531776bf9a4e6c53afa2296d21f66144de24..e8957d561a3cd3fd3a9ffced54169d745dd20d44 100644 --- a/include/core/sensor/sensor_odom.h +++ b/include/core/sensor/sensor_odom.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef SENSOR_ODOM_H_ -#define SENSOR_ODOM_H_ +#pragma once //wolf includes #include "core/sensor/sensor_base.h" @@ -69,16 +68,10 @@ class SensorOdom : public SensorBase ParamsSensorOdomPtr params_odom_; public: - SensorOdom(const std::string& _unique_name, - const SizeEigen& _dim, + SensorOdom(const SizeEigen& _dim, ParamsSensorOdomPtr _params, const Priors& _priors); - SensorOdom(const std::string& _unique_name, - const SizeEigen& _dim, - ParamsSensorOdomPtr _params, - const ParamsServer& _server); - WOLF_SENSOR_CREATE(SensorOdom, ParamsSensorOdom); ~SensorOdom() override = default; @@ -118,6 +111,4 @@ inline double SensorOdom::getMinRotVar() const return params_odom_->min_rot_var; } -} // namespace wolf - -#endif // SENSOR_ODOM_2d_H_ +} // namespace wolf \ No newline at end of file diff --git a/include/core/sensor/sensor_pose.h b/include/core/sensor/sensor_pose.h index 022c44cf4bb702deeb90cc02660830f78cda7bb4..86f8386d81e48c59a76c893a2d1b260c370d23f3 100644 --- a/include/core/sensor/sensor_pose.h +++ b/include/core/sensor/sensor_pose.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file sensor_pose.h - * - * Created on: Feb 18, 2020 - * \author: mfourmy - */ - -#ifndef SRC_SENSOR_POSE_H_ -#define SRC_SENSOR_POSE_H_ +#pragma once //wolf includes #include "core/sensor/sensor_base.h" @@ -66,8 +58,7 @@ class SensorPose : public SensorBase ParamsSensorPosePtr params_pose_; public: - SensorPose(const std::string& _unique_name, - const SizeEigen& _dim, + SensorPose(const SizeEigen& _dim, ParamsSensorPosePtr _params, const Priors& _priors); @@ -92,6 +83,4 @@ inline double SensorPose::getStdO() const return params_pose_->std_o; } -} /* namespace wolf */ - -#endif /* SRC_SENSOR_POSE_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/solver/factory_solver.h b/include/core/solver/factory_solver.h index fc8e5107093de4044f7ef65be490d88cf5af3c9f..72716cf487baf347a26f47b15b28f82c047a90e3 100644 --- a/include/core/solver/factory_solver.h +++ b/include/core/solver/factory_solver.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file factory_solver.h - * - * Created on: Dec 17, 2018 - * \author: jcasals - */ - -#ifndef FACTORY_SOLVER_H_ -#define FACTORY_SOLVER_H_ +#pragma once namespace wolf { @@ -39,6 +31,8 @@ struct ParamsSensorBase; #include "core/common/factory.h" #include "core/solver/solver_manager.h" +#include "yaml-cpp/yaml.h" + namespace wolf { @@ -48,7 +42,7 @@ namespace wolf typedef Factory<SolverManager, const ProblemPtr&, - const ParamsServer&> FactorySolver; + const YAML::Node&> FactorySolver; template<> inline std::string FactorySolver::getClass() const @@ -60,6 +54,4 @@ inline std::string FactorySolver::getClass() const namespace{ const bool WOLF_UNUSED SolverType##Registered = \ wolf::FactorySolver::registerCreator(#SolverType, SolverType::create); } \ -} /* namespace wolf */ - -#endif /* SENSOR_FACTORY_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/solver/solver_manager.h b/include/core/solver/solver_manager.h index b8e99a5a9141399aca063d2bca4adea9dc7c0747..ccfcb62b6684929d9ae5ee35988b7ba467510863 100644 --- a/include/core/solver/solver_manager.h +++ b/include/core/solver/solver_manager.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef _WOLF_SOLVER_MANAGER_H_ -#define _WOLF_SOLVER_MANAGER_H_ +#pragma once //wolf includes #include "core/common/wolf.h" @@ -45,19 +44,13 @@ WOLF_STRUCT_PTR_TYPEDEFS(ParamsSolver) * SolverManagerClass(const ProblemPtr& wolf_problem, * const ParamsSolverClassPtr _params); */ -#define WOLF_SOLVER_CREATE(SolverClass, ParamsSolverClass) \ -static SolverManagerPtr create(const ProblemPtr& _problem, \ - const ParamsServer& _server) \ -{ \ - auto params = std::make_shared<ParamsSolverClass>(#SolverClass, _server); \ - return std::make_shared<SolverClass>(_problem, params); \ -} \ -static SolverManagerPtr create(const ProblemPtr& _problem, \ - const ParamsSolverPtr _params) \ -{ \ - auto params = std::static_pointer_cast<ParamsSolverClass>(_params); \ - return std::make_shared<SolverClass>(_problem, params); \ -} \ +#define WOLF_SOLVER_CREATE(SolverClass, ParamsSolverClass) \ +static SolverManagerPtr create(const ProblemPtr& _problem, \ + const YAML::Node& _input_node) \ +{ \ + auto params = std::make_shared<ParamsSolverClass>(_input_node); \ + return std::make_shared<SolverClass>(_problem, params); \ +} \ struct ParamsSolver; @@ -237,7 +230,6 @@ class SolverManager // Params (here becaure it needs of declaration of SolverManager::ReportVerbosity) struct ParamsSolver: public ParamsBase { - std::string prefix = "solver/"; double period = 0.0; SolverManager::ReportVerbosity verbose = SolverManager::ReportVerbosity::QUIET; bool compute_cov = false; @@ -245,16 +237,16 @@ struct ParamsSolver: public ParamsBase double cov_period = 1.0; ParamsSolver() = default; - ParamsSolver(std::string _unique_name, const ParamsServer& _server): - ParamsBase(_unique_name, _server) + ParamsSolver(const YAML::Node& _input_node): + ParamsBase(_input_node) { - period = _server.getParam<double>(prefix + "period"); - verbose = (SolverManager::ReportVerbosity)_server.getParam<int>(prefix + "verbose"); - compute_cov = _server.getParam<bool>(prefix + "compute_cov"); + period = _input_node["period"].as<double>(); + verbose = (SolverManager::ReportVerbosity)_input_node["verbose"].as<int>(); + compute_cov = _input_node["compute_cov"].as<bool>(); if (compute_cov) { - cov_enum = (SolverManager::CovarianceBlocksToBeComputed)_server.getParam<int>(prefix + "cov_enum"); - cov_period = _server.getParam<double>(prefix + "cov_period"); + cov_enum = (SolverManager::CovarianceBlocksToBeComputed)_input_node["cov_enum"].as<int>(); + cov_period = _input_node["cov_period"].as<double>(); } } std::string print() const override @@ -269,6 +261,4 @@ struct ParamsSolver: public ParamsBase ~ParamsSolver() override = default; }; -} // namespace wolf - -#endif /* _WOLF_SOLVER_MANAGER_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/solver_suitesparse/ccolamd_ordering.h b/include/core/solver_suitesparse/ccolamd_ordering.h index 4683373559f7df440b834c01c7552628e4f4b7b1..eee05794ae2aa545f1ccdd628ce628d99d2b005c 100644 --- a/include/core/solver_suitesparse/ccolamd_ordering.h +++ b/include/core/solver_suitesparse/ccolamd_ordering.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * ccolamd_ordering.h - * - * Created on: Jun 12, 2015 - * Author: jvallve - */ - -#ifndef TRUNK_SRC_WOLF_SOLVER_CCOLAMD_ORDERING_H_ -#define TRUNK_SRC_WOLF_SOLVER_CCOLAMD_ORDERING_H_ +#pragma once //std includes #include <iostream> @@ -96,6 +88,4 @@ class CCOLAMDOrdering return info; } }; -} - -#endif /* TRUNK_SRC_WOLF_SOLVER_CCOLAMD_ORDERING_H_ */ +} \ No newline at end of file diff --git a/include/core/solver_suitesparse/cost_function_base.h b/include/core/solver_suitesparse/cost_function_base.h index fb094beedc0868846edfdbce7a0c64ddce3fb6a6..8ae6a08f3349333e2fc19d3d87dbc285c3b5c723 100644 --- a/include/core/solver_suitesparse/cost_function_base.h +++ b/include/core/solver_suitesparse/cost_function_base.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * cost_function_base.h - * - * Created on: Jun 25, 2015 - * Author: jvallve - */ - -#ifndef TRUNK_SRC_SOLVER_COST_FUNCTION_BASE_H_ -#define TRUNK_SRC_SOLVER_COST_FUNCTION_BASE_H_ +#pragma once #include "core/common/wolf.h" #include <Eigen/StdVector> @@ -113,6 +105,4 @@ class CostFunctionBase for (unsigned int i = 0; i<n_blocks_; i++) jacobians.at(i) = (*jacobians_.at(i)); } -}; - -#endif /* TRUNK_SRC_SOLVER_COST_FUNCTION_BASE_H_ */ +}; \ No newline at end of file diff --git a/include/core/solver_suitesparse/cost_function_sparse.h b/include/core/solver_suitesparse/cost_function_sparse.h index 43e367f4f0975b32f0cb9333ffbb5094bf9f56ab..9b18255db723ea21fed2844e85cb08e8dce996f5 100644 --- a/include/core/solver_suitesparse/cost_function_sparse.h +++ b/include/core/solver_suitesparse/cost_function_sparse.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef TRUNK_SRC_SOLVER_COST_FUNCTION_SPARSE_H_ -#define TRUNK_SRC_SOLVER_COST_FUNCTION_SPARSE_H_ +#pragma once //wolf includes #include "core/common/wolf.h" @@ -525,6 +524,4 @@ class CostFunctionSparse<FactorT, } }; -} //namespace wolf - -#endif /* TRUNK_SRC_SOLVER_COST_FUNCTION_SPARSE_H_ */ +} //namespace wolf \ No newline at end of file diff --git a/include/core/solver_suitesparse/cost_function_sparse_base.h b/include/core/solver_suitesparse/cost_function_sparse_base.h index 8c752208bf2eabd2981fa73c1de2b1ada8dfcefc..ae74f19a4804f5f3453df45cdd67c20b73b8aa95 100644 --- a/include/core/solver_suitesparse/cost_function_sparse_base.h +++ b/include/core/solver_suitesparse/cost_function_sparse_base.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * cost_function_sparse.h - * - * Created on: Jun 25, 2015 - * Author: jvallve - */ - -#ifndef TRUNK_SRC_SOLVER_COST_FUNCTION_SPARSE_BASE_H_ -#define TRUNK_SRC_SOLVER_COST_FUNCTION_SPARSE_BASE_H_ +#pragma once //wolf includes #include "core/common/wolf.h" @@ -341,6 +333,4 @@ const unsigned int MEASUREMENT_SIZE, jets_9_[i].a = *(factor_ptr_->getStateScalarPtrVector().at(9)+i); } -} // wolf namespace - -#endif /* TRUNK_SRC_SOLVER_COST_FUNCTION_SPARSE_BASE_H_ */ +} // wolf namespace \ No newline at end of file diff --git a/include/core/solver_suitesparse/qr_solver.h b/include/core/solver_suitesparse/qr_solver.h index 83c392894a0a63b06c9b86a8d8b31907a2803bf9..f715761d8514009682066365cf67c59c72e227e3 100644 --- a/include/core/solver_suitesparse/qr_solver.h +++ b/include/core/solver_suitesparse/qr_solver.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * qr_solver.h - * - * Created on: Jul 2, 2015 - * Author: jvallve - */ - -#ifndef TRUNK_SRC_SOLVER_QR_SOLVER_H_ -#define TRUNK_SRC_SOLVER_QR_SOLVER_H_ +#pragma once //std includes #include <core/factor/factor_odom_2d.h> @@ -610,6 +602,4 @@ class SolverQR } }; -} // namespace wolf - -#endif /* TRUNK_SRC_SOLVER_QR_SOLVER_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/solver_suitesparse/solver_QR.h b/include/core/solver_suitesparse/solver_QR.h index 3f0f689fec8a1d3aefd293ac50b2a30515da2f1f..abece338f9c35b63c2fe5469dacfa5cee9d873a3 100644 --- a/include/core/solver_suitesparse/solver_QR.h +++ b/include/core/solver_suitesparse/solver_QR.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * solver_QR.h - * - * Created on: Jun 22, 2015 - * Author: jvallve - */ - -#ifndef TRUNK_SRC_SOLVER_SOLVER_QR_H_ -#define TRUNK_SRC_SOLVER_SOLVER_QR_H_ +#pragma once using namespace Eigen; @@ -48,6 +40,4 @@ class SolverQR VectorXi nodes_ordering_factors; private: -}; - -#endif /* TRUNK_SRC_SOLVER_SOLVER_QR_H_ */ +}; \ No newline at end of file diff --git a/include/core/solver_suitesparse/solver_manager.h b/include/core/solver_suitesparse/solver_manager.h index f3baf950fc917017d26ecfe95213205c1a92cffc..9a0817573d0c5838781e72b8fb505a8af74299fd 100644 --- a/include/core/solver_suitesparse/solver_manager.h +++ b/include/core/solver_suitesparse/solver_manager.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CERES_MANAGER_H_ -#define CERES_MANAGER_H_ +#pragma once //wolf includes #include "core/factor/factor_GPS_2d.h" @@ -64,6 +63,4 @@ class SolverManager void updateStateUnitStatus(StateBlockPtr _st_ptr); ceres::CostFunction* createCostFunction(FactorBasePtr _fac_ptr); -}; - -#endif +}; \ No newline at end of file diff --git a/include/core/solver_suitesparse/sparse_utils.h b/include/core/solver_suitesparse/sparse_utils.h index 393a2fb275507aa1e9b5b6c67172a6b589be4f9f..4c0f01633c0a591d62c25daafd3029e10caccfee 100644 --- a/include/core/solver_suitesparse/sparse_utils.h +++ b/include/core/solver_suitesparse/sparse_utils.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * sparse_utils.h - * - * Created on: Jul 2, 2015 - * Author: jvallve - */ - -#ifndef SPARSE_UTILS_H_ -#define SPARSE_UTILS_H_ +#pragma once // eigen includes #include <eigen3/Eigen/Sparse> @@ -63,5 +55,4 @@ void insertSparseBlock(const Eigen::MatrixXd& ins, Eigen::SparseMatrixd& origina original.makeCompressed(); } -} -#endif /* SPARSE_UTILS_H_ */ +} \ No newline at end of file diff --git a/include/core/state_block/factory_state_block.h b/include/core/state_block/factory_state_block.h index c440584c0539625d93b4fa4bc5bbafaa1cad1461..ab77f4afa6d7ad4e6abb1e243afbbc7a7dab945d 100644 --- a/include/core/state_block/factory_state_block.h +++ b/include/core/state_block/factory_state_block.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * \file factory_state_block.h - * - * Created on: Apr 27, 2020 - * \author: jsola - */ - -#ifndef STATE_BLOCK_FACTORY_STATE_BLOCK_H_ -#define STATE_BLOCK_FACTORY_STATE_BLOCK_H_ +#pragma once #include "core/common/factory.h" #include "core/state_block/state_block.h" @@ -149,18 +141,12 @@ inline StateBlockPtr FactoryStateBlock::create(const string& _type, const Eigen: return (creator_callback_it->second)(_state, _fixed); } -#define WOLF_REGISTER_STATEBLOCK(StateBlockType) \ - namespace{ const bool WOLF_UNUSED StateBlockType##Registered = \ - FactoryStateBlock::registerCreator(#StateBlockType, StateBlockType::create); } \ - -#define WOLF_REGISTER_STATEBLOCK_WITH_KEY(Key, StateBlockType) \ - namespace{ const bool WOLF_UNUSED StateBlockType##RegisteredWith##Key = \ - FactoryStateBlock::registerCreator(#Key, StateBlockType::create); } \ - - - - -} +#define WOLF_REGISTER_STATEBLOCK(StateBlockType) \ + namespace{ const bool WOLF_UNUSED StateBlockType##Registered = \ + FactoryStateBlock::registerCreator(#StateBlockType, StateBlockType::create); } \ +#define WOLF_REGISTER_STATEBLOCK_WITH_KEY(Key, StateBlockType) \ + namespace{ const bool WOLF_UNUSED StateBlockType##RegisteredWith##Key = \ + FactoryStateBlock::registerCreator(#Key, StateBlockType::create); } \ -#endif /* STATE_BLOCK_FACTORY_STATE_BLOCK_H_ */ +} \ No newline at end of file diff --git a/include/core/state_block/has_state_blocks.h b/include/core/state_block/has_state_blocks.h index e25e7d908a18a7b0989e4b9c91bf87cb18229266..5b936a73835aa5bd578b88b77462c091c9bbfbcf 100644 --- a/include/core/state_block/has_state_blocks.h +++ b/include/core/state_block/has_state_blocks.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file has_state_blocks.h - * - * Created on: Aug 27, 2019 - * \author: jsola - */ - -#ifndef STATE_BLOCK_HAS_STATE_BLOCKS_H_ -#define STATE_BLOCK_HAS_STATE_BLOCKS_H_ +#pragma once #include "core/common/wolf.h" #include "core/state_block/state_composite.h" @@ -444,6 +436,4 @@ inline unsigned int HasStateBlocks::getLocalSize(const StateStructure& _structur return size; } -} // namespace wolf - -#endif /* STATE_BLOCK_HAS_STATE_BLOCKS_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/state_block/local_parametrization_angle.h b/include/core/state_block/local_parametrization_angle.h index 62833a8b4565bf1d155d950edb121ab86c2b275b..fb371e94f94ea91f0742567c4fb5032f107c3659 100644 --- a/include/core/state_block/local_parametrization_angle.h +++ b/include/core/state_block/local_parametrization_angle.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file local_parametrization_angle.h - * - * Created on: Apr 4, 2017 - * \author: jsola - */ - -#ifndef LOCAL_PARAMETRIZATION_ANGLE_H_ -#define LOCAL_PARAMETRIZATION_ANGLE_H_ +#pragma once #include "core/state_block/local_parametrization_base.h" #include "core/math/rotations.h" @@ -92,6 +84,4 @@ inline bool LocalParametrizationAngle::isValid(const Eigen::VectorXd& _state, do //Eigen::Map not Eigen::VectorXd return true; } -} /* namespace wolf */ - -#endif /* LOCAL_PARAMETRIZATION_ANGLE_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/state_block/local_parametrization_base.h b/include/core/state_block/local_parametrization_base.h index 435489cd3feaa83347fe0c20e5ade7d8b1a8d0ea..cbbb8ab1588fe582190cbbde92ed055abd676dc5 100644 --- a/include/core/state_block/local_parametrization_base.h +++ b/include/core/state_block/local_parametrization_base.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * \file local_parametrization_base.h - * - * Created on: Feb 17, 2016 - * \author: jsola - */ - -#ifndef LOCAL_PARAMETRIZATION_BASE_H_ -#define LOCAL_PARAMETRIZATION_BASE_H_ +#pragma once #include "core/common/wolf.h" @@ -57,6 +49,4 @@ class LocalParametrizationBase{ unsigned int getGlobalSize() const; }; -} // namespace wolf - -#endif /* LOCAL_PARAMETRIZATION_BASE_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/state_block/local_parametrization_homogeneous.h b/include/core/state_block/local_parametrization_homogeneous.h index 476aceb79a8ab48b2cb43bbf148b732411a204ba..2b34c14ea2b1346623c2fbc5dfc44fc422871026 100644 --- a/include/core/state_block/local_parametrization_homogeneous.h +++ b/include/core/state_block/local_parametrization_homogeneous.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * \file local_parametrization_homogeneous.h - * - * Created on: 24/02/2016 - * Author: jsola - */ - -#ifndef LOCALPARAMETRIZATIONHOMOGENEOUS_H_ -#define LOCALPARAMETRIZATIONHOMOGENEOUS_H_ +#pragma once #include "core/state_block/local_parametrization_base.h" @@ -71,6 +63,4 @@ class LocalParametrizationHomogeneous : public LocalParametrizationBase bool isValid(const Eigen::VectorXd& state, double tolerance) override; }; -} // namespace wolf - -#endif /* LOCALPARAMETRIZATIONHOMOGENEOUS_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/state_block/local_parametrization_quaternion.h b/include/core/state_block/local_parametrization_quaternion.h index 70f4c3018b15c00fbfef5b95f14ad1a7a2907d1d..db50598f1c458c784a28cefb2c3cae1a105e01c4 100644 --- a/include/core/state_block/local_parametrization_quaternion.h +++ b/include/core/state_block/local_parametrization_quaternion.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * \file local_parametrization_quaternion.h - * - * Created on: Feb 18, 2016 - * \author: jsola - */ - -#ifndef LOCAL_PARAMETRIZATION_QUATERNION_H_ -#define LOCAL_PARAMETRIZATION_QUATERNION_H_ +#pragma once #include "core/state_block/local_parametrization_base.h" @@ -105,6 +97,4 @@ public: typedef LocalParametrizationQuaternion<DQ_GLOBAL> LocalParametrizationQuaternionGlobal; typedef LocalParametrizationQuaternion<DQ_LOCAL> LocalParametrizationQuaternionLocal; -} // namespace wolf - -#endif /* LOCAL_PARAMETRIZATION_QUATERNION_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/state_block/prior.h b/include/core/state_block/prior.h index 38412c65d1048ba6929973086d93fed74fcb349f..0864028a49f99dd996b01b85aec6c1bf894753b4 100644 --- a/include/core/state_block/prior.h +++ b/include/core/state_block/prior.h @@ -19,55 +19,69 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef PRIOR_H_ -#define PRIOR_H_ +#pragma once #include <string> #include <unordered_map> #include <eigen3/Eigen/Dense> +#include "yaml-cpp/yaml.h" namespace wolf { -class ParamsServer; -class Prior; -typedef std::unordered_map<char, Prior> Priors; class Prior { private: - std::string type_; // State type - Eigen::VectorXd state_; // state values - std::string mode_; // Prior mode. Can be 'initial_guess', 'fix' or 'factor' - Eigen::VectorXd noise_std_; // factor noise std, sqrt of the diagonal of the covariance mtrix (ONLY IF mode == 'factor') - bool dynamic_; // State dynamic - Eigen::VectorXd drift_std_; // OPTIONAL std of the state drift [in units/sqrt(s)] diagonal elements (ONLY IF if dynamic) + std::string type_; // State type + Eigen::VectorXd state_; // state values + std::string mode_; // Prior mode. Can be 'initial_guess', 'fix' or 'factor' + Eigen::VectorXd noise_std_; // factor noise std, sqrt of the diagonal of the covariance mtrix (ONLY IF mode == 'factor') + bool dynamic_; // State dynamic + Eigen::VectorXd drift_std_; // OPTIONAL std of the state drift [in units/sqrt(s)] diagonal elements (ONLY IF if dynamic) public: - Prior() = default; - Prior(const std::string& _type, - const Eigen::VectorXd& _state, - const std::string& _mode = "fix", - const Eigen::VectorXd& _noise_std = Eigen::VectorXd(0), - bool _dynamic = false, - const Eigen::VectorXd& _drift_std = Eigen::VectorXd(0)); - - Prior(const std::string& _prefix, const std::string& _type, const ParamsServer& _server); - - virtual ~Prior() = default; - - const std::string& getType() const; - const std::string& getMode() const; - const Eigen::VectorXd& getState() const; - const Eigen::VectorXd& getNoiseStd() const; - bool isDynamic() const; - bool isFixed() const; - bool isInitialGuess() const; - bool isFactor() const; - const Eigen::VectorXd& getDriftStd() const; - - void check() const; - - virtual std::string print() const final; + Prior() = default; + Prior(const std::string& _type, + const Eigen::VectorXd& _state, + const std::string& _mode = "fix", + const Eigen::VectorXd& _noise_std = Eigen::VectorXd(0), + bool _dynamic = false, + const Eigen::VectorXd& _drift_std = Eigen::VectorXd(0)); + + Prior(const YAML::Node& prior_node); + + virtual ~Prior() = default; + + const std::string& getType() const; + const std::string& getMode() const; + const Eigen::VectorXd& getState() const; + const Eigen::VectorXd& getNoiseStd() const; + bool isDynamic() const; + bool isFixed() const; + bool isInitialGuess() const; + bool isFactor() const; + const Eigen::VectorXd& getDriftStd() const; + + void check() const; + + virtual std::string print() const final; +}; + +typedef std::unordered_map<char, Prior> PriorMap; + +class Priors : public PriorMap +{ + public: + using PriorMap::PriorMap; + + Priors(const YAML::Node& priors_node) + { + for (auto prior_pair : priors_node) + { + this->emplace(prior_pair.first.as<char>(), Prior(prior_pair.second)); + } + } + virtual ~Priors() = default; }; inline const std::string& Prior::getType() const { return type_; } @@ -87,5 +101,5 @@ inline bool Prior::isInitialGuess() const { return mode_ == "initial_guess"; } inline bool Prior::isFactor() const { return mode_ == "factor"; } inline const Eigen::VectorXd& Prior::getDriftStd() const { return drift_std_; } -} // namespace wolf -#endif + +} // namespace wolf \ No newline at end of file diff --git a/include/core/state_block/state_angle.h b/include/core/state_block/state_angle.h index fe0fb46473f64743b17ee96d47143a2b00492ac7..ebe6b02c6c8c8e63e1d8f55836326f2eddd7d702 100644 --- a/include/core/state_block/state_angle.h +++ b/include/core/state_block/state_angle.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file state_angle.h - * - * Created on: Apr 4, 2017 - * \author: jsola - */ - -#ifndef STATE_ANGLE_H_ -#define STATE_ANGLE_H_ +#pragma once #include "core/state_block/state_block.h" #include "core/state_block/local_parametrization_angle.h" @@ -71,6 +63,4 @@ inline void StateAngle::transform(const VectorComposite& _transformation) if (isTransformable()) setState(_transformation.at('O') + getState()); // 2D rotation is a sum of angles } -} /* namespace wolf */ - -#endif /* STATE_ANGLE_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/state_block/state_block.h b/include/core/state_block/state_block.h index 2572cc9b64a729f36496ac403fb18700846dc43c..dea672e85aa339355318892368e6ce3efc3c9f5e 100644 --- a/include/core/state_block/state_block.h +++ b/include/core/state_block/state_block.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef STATE_BLOCK_H_ -#define STATE_BLOCK_H_ +#pragma once // Fwd references namespace wolf{ @@ -354,6 +352,5 @@ inline bool StateBlock::isValid(double tolerance) { return local_param_ptr_ ? local_param_ptr_->isValid(state_, tolerance) : true; } -}// namespace wolf -#endif +}// namespace wolf \ No newline at end of file diff --git a/include/core/state_block/state_block_derived.h b/include/core/state_block/state_block_derived.h index 541b79a19453f34cedf13343de1caee2d2fca74b..13453f63c5d1e99b9306f7cf549a1a9488e2fcd4 100644 --- a/include/core/state_block/state_block_derived.h +++ b/include/core/state_block/state_block_derived.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef STATE_BLOCK_DERIVED_H_ -#define STATE_BLOCK_DERIVED_H_ +#pragma once #include "core/state_block/state_block.h" @@ -149,6 +148,4 @@ class StateVector3d : public StateBlock } }; -} // namespace wolf - -#endif // STATE_BLOCK_DERIVED_H_ \ No newline at end of file +} // namespace wolf \ No newline at end of file diff --git a/include/core/state_block/state_composite.h b/include/core/state_block/state_composite.h index dcfa71155597334de8ff4a3daedbb760314f1856..2b18216ff1a1994b06b5bc6c8cf87928cf0038c1 100644 --- a/include/core/state_block/state_composite.h +++ b/include/core/state_block/state_composite.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * state_composite.h - * - * Created on: Apr 6, 2020 - * Author: jsola - */ - -#ifndef STATE_BLOCK_STATE_COMPOSITE_H_ -#define STATE_BLOCK_STATE_COMPOSITE_H_ +#pragma once #include "core/common/wolf.h" @@ -379,7 +371,4 @@ inline StateBlockPtr wolf::StateBlockComposite::emplace(const char &_sb_type, return sb; } -} - - -#endif /* STATE_BLOCK_STATE_COMPOSITE_H_ */ +} \ No newline at end of file diff --git a/include/core/state_block/state_homogeneous_3d.h b/include/core/state_block/state_homogeneous_3d.h index 8af6059aa6badcfc91665307e92df8fd9379694b..a576fa0ea2f4beb7aec0b8c49bfa8438e674a6d2 100644 --- a/include/core/state_block/state_homogeneous_3d.h +++ b/include/core/state_block/state_homogeneous_3d.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * \file state_homogeneous_3d.h - * - * Created on: Mar 7, 2016 - * \author: jsola - */ - -#ifndef SRC_STATE_HOMOGENEOUS_3d_H_ -#define SRC_STATE_HOMOGENEOUS_3d_H_ +#pragma once #include "core/state_block/state_block.h" #include "core/state_block/local_parametrization_homogeneous.h" @@ -91,6 +83,4 @@ inline StateBlockPtr StateHomogeneous3d::create (const Eigen::VectorXd& _state, return std::make_shared<StateHomogeneous3d>(_state, _fixed); } -} // namespace wolf - -#endif /* SRC_STATE_HOMOGENEOUS_3d_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/state_block/state_quaternion.h b/include/core/state_block/state_quaternion.h index ae7ed2f6381e9ce1149bff585df744d71e74b59e..718f3965da56e0258c0fd02f93edb3fea6dd4f68 100644 --- a/include/core/state_block/state_quaternion.h +++ b/include/core/state_block/state_quaternion.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * \file StateQuaternion.h - * - * Created on: Mar 7, 2016 - * author: jsola - */ - -#ifndef SRC_STATE_QUATERNION_H_ -#define SRC_STATE_QUATERNION_H_ +#pragma once #include "core/state_block/state_block.h" #include "core/state_block/local_parametrization_quaternion.h" @@ -107,6 +99,4 @@ inline StateBlockPtr StateQuaternion::create (const Eigen::VectorXd& _state, boo return std::make_shared<StateQuaternion>(_state, _fixed); } -} // namespace wolf - -#endif /* SRC_STATE_QUATERNION_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/trajectory/trajectory_base.h b/include/core/trajectory/trajectory_base.h index 21b1ab5be7080da9334a979274d5f4513f9a23f0..2362b88ceb13901e5893fd1887fd43038856c283 100644 --- a/include/core/trajectory/trajectory_base.h +++ b/include/core/trajectory/trajectory_base.h @@ -19,9 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- - -#ifndef TRAJECTORY_BASE_H_ -#define TRAJECTORY_BASE_H_ +#pragma once // Fwd refs namespace wolf{ @@ -155,7 +153,4 @@ inline bool TrajectoryBase::hasFrame(FrameBaseConstPtr _frame) const }) != frame_map_.end(); } - -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/tree_manager/factory_tree_manager.h b/include/core/tree_manager/factory_tree_manager.h index fe382c986c04656928e8aa6167d8a5f9aecc6cbc..edd9a44ef28783255afe3190e751ac92aa4c038e 100644 --- a/include/core/tree_manager/factory_tree_manager.h +++ b/include/core/tree_manager/factory_tree_manager.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTORY_TREE_MANAGER_H_ -#define FACTORY_TREE_MANAGER_H_ +#pragma once namespace wolf { @@ -35,53 +34,38 @@ struct ParamsTreeManagerBase; namespace wolf { -/** \brief TreeManager factory class - * TODO - */ -// ParamsTreeManager factory -struct ParamsTreeManagerBase; -typedef Factory<ParamsTreeManagerBase, - const std::string&> FactoryParamsTreeManager; -template<> -inline std::string FactoryParamsTreeManager::getClass() const -{ - return "FactoryParamsTreeManager"; -} - -// TreeManager factory typedef Factory<TreeManagerBase, - ParamsTreeManagerBasePtr> FactoryTreeManager; + const YAML::Node&> FactoryTreeManager; template<> inline std::string FactoryTreeManager::getClass() const { - return "FactoryTreeManager"; + return "FactoryTreeManager"; } typedef Factory<TreeManagerBase, - const ParamsServer&> FactoryTreeManagerServer; + const std::string&, + const std::vector<std::string>&> FactoryTreeManagerYaml; template<> -inline std::string FactoryTreeManagerServer::getClass() const +inline std::string FactoryTreeManagerYaml::getClass() const { - return "FactoryTreeManagerServer"; + return "FactoryTreeManagerYaml"; } typedef Factory<TreeManagerBase, - const std::string&> FactoryTreeManagerYaml; + ParamsTreeManagerBasePtr> FactoryTreeManagerParams; template<> -inline std::string FactoryTreeManagerYaml::getClass() const +inline std::string FactoryTreeManagerParams::getClass() const { - return "FactoryTreeManagerYaml"; + return "FactoryTreeManagerParams"; } #define WOLF_REGISTER_TREE_MANAGER(TreeManagerType) \ namespace{ const bool WOLF_UNUSED TreeManagerType##Registered = \ wolf::FactoryTreeManager::registerCreator(#TreeManagerType, TreeManagerType::create); } \ - namespace{ const bool WOLF_UNUSED TreeManagerType##ServerRegistered = \ - wolf::FactoryTreeManagerServer::registerCreator(#TreeManagerType, TreeManagerType::create); } \ namespace{ const bool WOLF_UNUSED TreeManagerType##YamlRegistered = \ wolf::FactoryTreeManagerYaml::registerCreator(#TreeManagerType, TreeManagerType::create); } \ + namespace{ const bool WOLF_UNUSED TreeManagerType##ParamsRegistered = \ + wolf::FactoryTreeManagerParams::registerCreator(#TreeManagerType, TreeManagerType::create); } \ -} /* namespace wolf */ - -#endif /* FACTORY_TREE_MANAGER_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/tree_manager/tree_manager_base.h b/include/core/tree_manager/tree_manager_base.h index 5d3d9c76af15faf517e8894264e67e0488fdabc1..d979849a05cad59641f4f7550eb16138168685ff 100644 --- a/include/core/tree_manager/tree_manager_base.h +++ b/include/core/tree_manager/tree_manager_base.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef INCLUDE_TREE_MANAGER_BASE_H_ -#define INCLUDE_TREE_MANAGER_BASE_H_ +#pragma once // Wolf includes #include "core/common/wolf.h" @@ -40,37 +39,43 @@ namespace wolf * must have a constructor available with the API: * * TreeManagerClass(const ParamsTreeManagerPtr _params); + * + * Also, there should be the schema file 'TreeManagerClass.schema' containing the specifications + * of the user input yaml file. */ -#define WOLF_TREE_MANAGER_CREATE(TreeManagerClass, ParamsTreeManagerClass) \ -static TreeManagerBasePtr create(const ParamsServer& _server) \ -{ \ - auto params = std::make_shared<ParamsTreeManagerClass>(_server); \ - \ - return std::make_shared<TreeManagerClass>(params); \ -} \ -static TreeManagerBasePtr create(ParamsTreeManagerBasePtr _params) \ -{ \ - auto params = std::static_pointer_cast<ParamsTreeManagerClass>(_params); \ - \ - return std::make_shared<TreeManagerClass>(params); \ -} \ -static TreeManagerBasePtr create(const std::string& _yaml_filepath) \ -{ \ - auto parser = ParserYaml(_yaml_filepath, true); \ - \ - auto server = ParamsServer(parser.getParams(), "problem/tree_manager/"); \ - \ - auto params = std::make_shared<ParamsTreeManagerClass>(server); \ - \ - return std::make_shared<TreeManagerClass>(params); \ -} \ +#define WOLF_TREE_MANAGER_CREATE(TreeManagerClass, ParamsTreeManagerClass) \ +static TreeManagerBasePtr create(const YAML::Node& _input_node) \ +{ \ + auto params = std::make_shared<ParamsTreeManagerClass>(_input_node); \ + \ + return std::make_shared<TreeManagerClass>(params); \ +} \ +static TreeManagerBasePtr create(const std::string& _yaml_filepath, \ + const std::vector<std::string>& _folders_schema) \ +{ \ + auto server = yaml_schema_cpp::YamlServer(_folders_schema, _yaml_filepath); \ + \ + if (not server.validate(#TreeManagerClass)) \ + { \ + WOLF_ERROR(server.getLog().str()); \ + return nullptr; \ + } \ + auto params = std::make_shared<ParamsTreeManagerClass>(server.getNode()); \ + \ + return std::make_shared<TreeManagerClass>(params); \ +} \ +static TreeManagerBasePtr create(ParamsTreeManagerBasePtr _params) \ +{ \ + auto params = std::static_pointer_cast<ParamsTreeManagerClass>(_params); \ + \ + return std::make_shared<TreeManagerClass>(params); \ +} \ struct ParamsTreeManagerBase : public ParamsBase { - std::string prefix = "problem/tree_manager"; ParamsTreeManagerBase() = default; - ParamsTreeManagerBase(const ParamsServer& _server): - ParamsBase("tree_manager", _server) + ParamsTreeManagerBase(const YAML::Node& _input_node): + ParamsBase(_input_node) { } @@ -98,6 +103,4 @@ class TreeManagerBase : public NodeBase ParamsTreeManagerBasePtr params_; }; -} /* namespace wolf */ - -#endif /* INCLUDE_TREE_MANAGER_BASE_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/tree_manager/tree_manager_sliding_window.h b/include/core/tree_manager/tree_manager_sliding_window.h index 65f650c627b153f362b02a881560cbc6b043a97d..9585cc595ee3841d09e42ddc3d57b2c346bc68c7 100644 --- a/include/core/tree_manager/tree_manager_sliding_window.h +++ b/include/core/tree_manager/tree_manager_sliding_window.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef INCLUDE_TREE_MANAGER_SLIDING_WINDOW_H_ -#define INCLUDE_TREE_MANAGER_SLIDING_WINDOW_H_ +#pragma once #include "core/tree_manager/tree_manager_base.h" @@ -33,12 +32,12 @@ WOLF_PTR_TYPEDEFS(TreeManagerSlidingWindow) struct ParamsTreeManagerSlidingWindow : public ParamsTreeManagerBase { ParamsTreeManagerSlidingWindow() = default; - ParamsTreeManagerSlidingWindow(const wolf::ParamsServer & _server) : - ParamsTreeManagerBase(_server) + ParamsTreeManagerSlidingWindow(const YAML::Node& _node_input) : + ParamsTreeManagerBase(_node_input) { - n_frames = _server.getParam<unsigned int>(prefix + "/n_frames"); - n_fix_first_frames = _server.getParam<unsigned int>(prefix + "/n_fix_first_frames"); - viral_remove_empty_parent = _server.getParam<bool> (prefix + "/viral_remove_empty_parent"); + n_frames = _node_input["n_frames"] .as<unsigned int>(); + n_fix_first_frames = _node_input["n_fix_first_frames"] .as<unsigned int>(); + viral_remove_empty_parent = _node_input["viral_remove_empty_parent"] .as<bool>(); if (n_frames <= n_fix_first_frames) throw std::runtime_error("TreeManagerSlidingWindow: Wrong parameter value. 'n_fix_first_frames' should be lower than 'n_frames'!"); } @@ -72,6 +71,4 @@ class TreeManagerSlidingWindow : public TreeManagerBase ParamsTreeManagerSlidingWindowPtr params_sw_; }; -} /* namespace wolf */ - -#endif /* INCLUDE_TREE_MANAGER_SLIDING_WINDOW_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h b/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h index a4f9a0fa721f19866015585bbffbbbe852864fae..511a56d6206c3b907c0ce0901cdc41299860ff84 100644 --- a/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h +++ b/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef INCLUDE_TREE_MANAGER_SLIDING_WINDOW_DUAL_RATE_H_ -#define INCLUDE_TREE_MANAGER_SLIDING_WINDOW_DUAL_RATE_H_ +#pragma once #include "core/tree_manager/tree_manager_sliding_window.h" @@ -33,12 +32,15 @@ WOLF_PTR_TYPEDEFS(TreeManagerSlidingWindowDualRate) struct ParamsTreeManagerSlidingWindowDualRate : public ParamsTreeManagerSlidingWindow { ParamsTreeManagerSlidingWindowDualRate() = default; - ParamsTreeManagerSlidingWindowDualRate(const wolf::ParamsServer & _server) : - ParamsTreeManagerSlidingWindow(_server) + ParamsTreeManagerSlidingWindowDualRate(const YAML::Node& _input_node) : + ParamsTreeManagerSlidingWindow(_input_node) { - n_frames_recent = _server.getParam<unsigned int>(prefix + "/n_frames_recent"); - assert(n_frames_recent <= n_frames); - rate_old_frames = _server.getParam<unsigned int>(prefix + "/rate_old_frames"); + n_frames_recent = _input_node["n_frames_recent"].as<unsigned int>(); + rate_old_frames = _input_node["rate_old_frames"].as<unsigned int>(); + if (n_frames_recent >= n_frames) + { + throw std::runtime_error("ParamsTreeManagerSlidingWindowDualRate: 'n_frames_recent' should be smaller than 'n_frames'"); + } } std::string print() const override { @@ -67,6 +69,4 @@ class TreeManagerSlidingWindowDualRate : public TreeManagerSlidingWindow //TrajectoryIter first_recent_frame_it_; }; -} /* namespace wolf */ - -#endif /* INCLUDE_TREE_MANAGER_SLIDING_WINDOW_DUAL_RATE_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/include/core/utils/check_log.h b/include/core/utils/check_log.h index 947a53175be061589f460577666d765fdfc7a0e4..bd9b67c745dafc6f748616d046f98b8e9294c8c4 100644 --- a/include/core/utils/check_log.h +++ b/include/core/utils/check_log.h @@ -19,8 +19,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CHECK_LOG_H -#define CHECK_LOG_H +#pragma once + #include <iostream> #include <string> #include <sstream> @@ -39,5 +39,5 @@ class CheckLog void compose(CheckLog l); void assertTrue(bool _condition, std::stringstream& _stream); }; -} // namespace wolf -#endif + +} // namespace wolf \ No newline at end of file diff --git a/include/core/utils/converter.h b/include/core/utils/converter.h index 0e2fd206dc03fdc325bf1f901d0294a1b8bdc44a..f989149fb1176e0d0c2df9af9bfad8d16970dccd 100644 --- a/include/core/utils/converter.h +++ b/include/core/utils/converter.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CONVERTER_H -#define CONVERTER_H +#pragma once // wolf #include "core/common/wolf.h" @@ -409,5 +408,4 @@ struct converter<MatrixComposite>{ return helper; } }; -} -#endif +} \ No newline at end of file diff --git a/include/core/utils/converter_utils.h b/include/core/utils/converter_utils.h index 36d67b012337334b2ab26d42fb87cc134fb70b3a..2e3bca6104f1572576855aa75408289b0f79da1b 100644 --- a/include/core/utils/converter_utils.h +++ b/include/core/utils/converter_utils.h @@ -19,13 +19,11 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef CONVERTER_UTILS_H -#define CONVERTER_UTILS_H +#pragma once // wolf #include "core/common/wolf.h" - // std #include <regex> namespace utils{ @@ -63,5 +61,4 @@ namespace utils{ */ std::string splitMapStringRepresentation(std::string str_map); std::vector<std::string> parseList(std::string val); -} -#endif +} \ No newline at end of file diff --git a/include/core/utils/eigen_assert.h b/include/core/utils/eigen_assert.h index fcd44023d307b8fd02403d7be2c2df752b5772b6..76f3880abaf762a579571005bbf29c22c527f98c 100644 --- a/include/core/utils/eigen_assert.h +++ b/include/core/utils/eigen_assert.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef _WOLF_EIGEN_ASSERT_H_ -#define _WOLF_EIGEN_ASSERT_H_ +#pragma once #include <Eigen/Dense> @@ -105,6 +104,4 @@ using VectorSizeCheck = MatrixSizeCheck<Dim, 1>; template <int Dim> using RowVectorSizeCheck = MatrixSizeCheck<1, Dim>; -} /* namespace Eigen */ - -#endif /* _WOLF_EIGEN_ASSERT_H_ */ +} /* namespace Eigen */ \ No newline at end of file diff --git a/include/core/utils/graph_search.h b/include/core/utils/graph_search.h index 549c1f1dec8f5b45579904ac5ec1f0adebbca593..bbd477b5ca0d6a31eef58b9eebe6fb03841ce476 100644 --- a/include/core/utils/graph_search.h +++ b/include/core/utils/graph_search.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef GRAPH_SEARCH_H -#define GRAPH_SEARCH_H +#pragma once #include "core/common/wolf.h" #include "core/frame/frame_base.h" @@ -60,6 +59,4 @@ class GraphSearch }; - -} // namespace wolf -#endif +} // namespace wolf \ No newline at end of file diff --git a/include/core/utils/loader.h b/include/core/utils/loader.h index 13fe987d736a47d50a52de2d86f519c3cea1a63b..2bf505cef691d794d7821e7db935dfaa3b0c18d1 100644 --- a/include/core/utils/loader.h +++ b/include/core/utils/loader.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef LOADER_H -#define LOADER_H +#pragma once #include <string> @@ -49,5 +48,4 @@ public: // void close(){ // delete this->resource_; // } -// }; -#endif +// }; \ No newline at end of file diff --git a/include/core/utils/logging.h b/include/core/utils/logging.h index a0e1556898fd453f5543ba90ec3645ccf282525c..66b44b4c9f036f0d5a6eede98640c78e85f34db8 100644 --- a/include/core/utils/logging.h +++ b/include/core/utils/logging.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file logging.h - * - * Created on: Oct 27, 2016 - * \author: Jeremie Deray - */ - -#ifndef WOLF_LOGGING_H_ -#define WOLF_LOGGING_H_ +#pragma once // third_party include #include <map> @@ -339,6 +331,4 @@ using WolfLoggerManager = Singleton<do_not_enter_where_the_wolf_lives::LoggerMan #else #define WOLF_TRACE(...) #define WOLF_TRACE_COND(cond, ...) -#endif - -#endif /* WOLF_LOGGING_H_ */ +#endif \ No newline at end of file diff --git a/include/core/utils/params_server.h b/include/core/utils/params_server.h index 2ca64f4cc97f11e81616ca716835be2b4681b8d8..812f39e24995176d0eed792564d687a974e32680 100644 --- a/include/core/utils/params_server.h +++ b/include/core/utils/params_server.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef PARAMS_SERVER_H -#define PARAMS_SERVER_H +#pragma once #include "core/utils/converter.h" @@ -69,33 +68,9 @@ class ParamsServer } }; -template<typename Derived> -std::string toString(const Eigen::DenseBase<Derived>& mat) -{ - std::stringstream ss; - if (mat.cols() == 1) - ss << mat.transpose(); - else - ss << std::endl << mat; - return ss.str(); -} - -std::string toString(bool _arg); -std::string toString(int _arg); -std::string toString(long _arg); -std::string toString(long long _arg); -std::string toString(unsigned _arg); -std::string toString(unsigned long _arg); -std::string toString(unsigned long long _arg); -std::string toString(float _arg); -std::string toString(double _arg); -std::string toString(long double _arg); - inline bool ParamsServer::hasParam(std::string _key) const { return params_.count(_key); } -} - -#endif +} \ No newline at end of file diff --git a/include/core/utils/singleton.h b/include/core/utils/singleton.h index edbaa1b5424280f921595859ec9199e4e2a2f863..a8e8840b37c29d56d04a1150200dfdd9bd935cf5 100644 --- a/include/core/utils/singleton.h +++ b/include/core/utils/singleton.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file singleton.h - * - * Created on: Aug 31, 2016 - * \author: Jeremie Deray - */ - -#ifndef WOLF_SINGLETON_H_ -#define WOLF_SINGLETON_H_ +#pragma once #include <memory> @@ -66,6 +58,4 @@ protected: }; } // namespace internal -} // namespace wolf - -#endif /* WOLF_SINGLETON_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/include/core/utils/utils_gtest.h b/include/core/utils/utils_gtest.h index 04eae1ca305801665b5e3fcea22610da7f06026e..905f25c8b26a3fa1caa79cb6e72be4f6d07cfcc1 100644 --- a/include/core/utils/utils_gtest.h +++ b/include/core/utils/utils_gtest.h @@ -19,16 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file utils_gtest.h - * \brief Some utils for gtest - * \author Jeremie Deray - * Created on: 26/09/2016 - * Eigen macros extension by: Joan Sola on 26/04/2017 - */ - -#ifndef WOLF_UTILS_GTEST_H -#define WOLF_UTILS_GTEST_H +#pragma once #include <gtest/gtest.h> @@ -198,6 +189,4 @@ TEST(Test, Foo) }, \ C_expect, C_actual); -} // namespace testing - -#endif /* WOLF_UTILS_GTEST_H */ +} // namespace testing \ No newline at end of file diff --git a/include/core/yaml/parser_yaml.h b/include/core/yaml/parser_yaml.h index e5ee7ed523c8f726c484e8a7f499d546f06eb867..a79a36ac23fe70c75376dc8eb60e1be411276015 100644 --- a/include/core/yaml/parser_yaml.h +++ b/include/core/yaml/parser_yaml.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef PARSER_YAML_H -#define PARSER_YAML_H +#pragma once #include "core/utils/converter.h" #include "core/common/wolf.h" @@ -98,5 +97,4 @@ public: std::string tagsToString(std::vector<std::string>& _tags); void parse(); }; -} -#endif +} \ No newline at end of file diff --git a/include/core/yaml/yaml_conversion.h b/include/core/yaml/yaml_conversion.h index 76991419a0ec370174055479cbb9dfdb910e0356..15dad4cd0b8264950cd3090b83c9c94c78241c19 100644 --- a/include/core/yaml/yaml_conversion.h +++ b/include/core/yaml/yaml_conversion.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file yaml_conversion.h - * - * Created on: May 12, 2016 - * \author: jsola - */ - -#ifndef YAML_YAML_CONVERSION_H_ -#define YAML_YAML_CONVERSION_H_ +#pragma once // Yaml #include <yaml-cpp/yaml.h> @@ -230,6 +222,4 @@ struct convert<Eigen::Quaternion<_Scalar, _Options> > } }; -} // namespace YAML - -#endif /* YAML_YAML_CONVERSION_H_ */ +} // namespace YAML \ No newline at end of file diff --git a/internal/config.h.in b/internal/config.h.in index 8f0d62ec930e2db6e5f4bc874126b8e0787eb856..50b39488d474b6ac73aa51ece7be5c7bd44083ed 100644 --- a/internal/config.h.in +++ b/internal/config.h.in @@ -24,8 +24,7 @@ // which will be added to the include path for compilation, // and installed with the public wolf headers. -#ifndef WOLF_INTERNAL_CONFIG_H_ -#define WOLF_INTERNAL_CONFIG_H_ +#pragma once #cmakedefine _WOLF_DEBUG @@ -33,5 +32,4 @@ #define _WOLF_ROOT_DIR "${_WOLF_ROOT_DIR}" #define _WOLF_LIB_DIR "${_WOLF_LIB_DIR}" - -#endif /* WOLF_INTERNAL_CONFIG_H_ */ +#define _WOLF_SCHEMAS_DIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}/schemas" \ No newline at end of file diff --git a/src/map/map_base.cpp b/src/map/map_base.cpp index 66367305a0b9ad82e9ef5987c3bdacb9e9a1eeea..ebd6038e83a51604023853e17d78dede44e8e34d 100644 --- a/src/map/map_base.cpp +++ b/src/map/map_base.cpp @@ -163,6 +163,5 @@ bool MapBase::check(CheckLog& _log, NodeBaseConstPtr _node_ptr, bool _verbose, s #include "core/map/factory_map.h" namespace wolf { WOLF_REGISTER_MAP(MapBase); -WOLF_REGISTER_MAP_AUTO(MapBase); } // namespace wolf diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index f99e9d8cd77cd862a3da9b3dbe5184c246d40530..d839895ba7bc3957e11b85e4e5f3753660845e5f 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -21,6 +21,7 @@ //--------LICENSE_END-------- // wolf includes #include "core/problem/problem.h" +#include "core/internal/config.h" #include "core/map/factory_map.h" #include "core/sensor/factory_sensor.h" #include "core/processor/factory_processor.h" @@ -33,6 +34,9 @@ #include "core/tree_manager/tree_manager_base.h" #include "core/utils/loader.h" +// yaml-schema-cpp +#include "yaml-schema-cpp/yaml_server.hpp" +#include "yaml-schema-cpp/yaml_schema.hpp" namespace wolf { @@ -84,233 +88,222 @@ ProblemPtr Problem::create(const std::string& _frame_structure, SizeEigen _dim, return p->shared_from_this(); } -ProblemPtr Problem::autoSetup(const std::string& _input_yaml_file, std::vector<std::string> _schema_folders) +ProblemPtr Problem::autoSetup(const std::string& _input_yaml_file, const std::vector<std::string>& _primary_schema_folders) { -#if __APPLE__ - std::string lib_extension = ".dylib"; -#else - std::string lib_extension = ".so"; -#endif - - // Create yaml server - auto server = yaml_schema_cpp::YamlServer({}, _input_yaml_file); - - // get all plugins - auto plugins_nodes = yaml_schema_cpp::findNodesWithKey(server.getNode(),"plugins"); - - - std::stringstream log; - if (not server.validate(SensorClass, log)) - { - WOLF_ERROR(log.str()); - return nullptr; - } - auto params = std::make_shared<ParamsSensorClass>(server.getNode()) - // Problem structure and dimension - std::string frame_structure = _server.getParam<std::string> ("problem/frame_structure"); - int dim = _server.getParam<int> ("problem/dimension"); - auto problem = Problem::create(frame_structure, dim, nullptr); - - WOLF_TRACE("Setting up problem with frame structure {" + frame_structure + "} and dimension " + std::to_string(dim) + "D"); - - // Load plugins - auto loaders = std::vector<std::shared_ptr<Loader>>(); + // Loaders + auto loaders = std::list<std::shared_ptr<Loader>>(); std::string plugins_path = _WOLF_LIB_DIR; if (plugins_path.back() != '/') { plugins_path += '/'; // only works for UNIX systems } - for (auto plugin_name : _server.getParam<std::vector<std::string>>("plugins")) - { - if (plugin_name == "core" or plugin_name == "wolf" or plugin_name == "") continue; // ignore plugin "core" + // // get all plugins + // auto plugins_nodes = yaml_schema_cpp::findNodesWithKey(server.getNode(),"plugins"); + // std::set<std::string> plugins; + // for (auto plugin_n : plugins_nodes) + // { + // if (not plugin_n.IsScalar() and not yaml_schema_cpp::checkType(plugin_n, "string")) + // { + // throw std::runtime_error("Problem::autoSetup: there is one 'plugin' param that is not a string.") + // } + // // plugin string + // auto plugin_str = plugin_n.as<std::string>(); + // if (plugins.count(plugin_str) == 0) + // { + // plugins.insert(plugin_str); + // } + // } + + // Schema folders + std::vector<std::string> schema_folders = _primary_schema_folders; + schema_folders.push_back(_WOLF_SCHEMAS_DIR); - std::string plugin = plugins_path + "libwolf" + plugin_name + lib_extension; - WOLF_TRACE("Loading plugin " + plugin_name + " via " + plugin); - auto l = std::make_shared<LoaderRaw>(plugin); - l->load(); - loaders.push_back(l); - } + // Create yaml server + auto server = yaml_schema_cpp::YamlServer(schema_folders, _input_yaml_file); - // load raw libs - std::vector<std::string> raw_libs; - try - { - raw_libs = _server.getParam<std::vector<std::string>>("raw_libs"); + // Validate agains schema files + if (not server.validate("Problem.schema")) + { + WOLF_ERROR(server.getLog().str()); + return nullptr; } - catch (MissingValueException& e) - { - WOLF_TRACE("No raw libraries to load..."); - } - for (auto lib : raw_libs) { - WOLF_TRACE("Loading raw lib " + lib); - auto l = std::make_shared<LoaderRaw>(lib); - l->load(); - loaders.push_back(l); - } - // Install sensors and processors -- load plugins only if sensors and processor are not registered - auto sensors = _server.getParam<std::vector<std::map<std::string, std::string>>>("sensors"); - for (auto sen : sensors) + // Get param node + YAML::Node param_node = server.getNode(); + + // PROBLEM =============================================================================== + // structure and dimension + YAML::Node problem_node = param_node["problem"]; + std::string frame_structure = problem_node["frame_structure"].as<std::string>(); + int dim = problem_node["dimension"].as<int>(); + auto problem = Problem::create(frame_structure, dim, nullptr); + + // Tree manager + YAML::Node tree_manager_node = problem_node["tree_manager"]; + std::string tree_manager_type = tree_manager_node["type"].as<std::string>(); + problem->setTreeManager(FactoryTreeManager::create(tree_manager_type, tree_manager_node)); + + // TODO: Prior -- first keyframe + // std::string prior_mode = _server.getParam<std::string>("problem/prior/mode"); + // assert((prior_mode == "nothing" || prior_mode == "initial_guess" || prior_mode == "fix" || prior_mode == "factor") && "wrong _mode value, it should be: 'nothing', 'initial_guess', 'fix' or 'factor'"); + // WOLF_TRACE("Prior mode: ", prior_mode); + // if (prior_mode == "nothing") + // { + // problem->setPriorOptions(prior_mode); + // } + // else if (prior_mode == "factor") + // { + // problem->setPriorOptions(prior_mode, + // _server.getParam<VectorComposite>("problem/prior/state"), + // _server.getParam<VectorComposite>("problem/prior/sigma")); + // } + // else + // { + // problem->setPriorOptions(prior_mode, + // _server.getParam<VectorComposite>("problem/prior/state")); + // } + // WOLF_TRACE("Setting up problem with frame structure {" + frame_structure + "} and dimension " + std::to_string(dim) + "D"); + + // SENSORS =============================================================================== + // load plugin if sensor is not registered + YAML::Node sensors_node = param_node["sensors"]; + for (auto sensor_n : sensors_node) { - if (not FactorySensor::isCreatorRegistered(sen["type"])) + auto sensor_type = sensor_n["type"].as<std::string>(); + if (not FactorySensor::isCreatorRegistered(sensor_type)) { - auto plugin_name = sen["plugin"]; - std::string plugin = plugins_path + "libwolf" + plugin_name + lib_extension; - WOLF_TRACE("Loading plugin " + plugin_name + " via " + plugin); - auto l = std::make_shared<LoaderRaw>(plugin); - l->load(); - loaders.push_back(l); + loadPlugin(sensor_n["plugin"].as<std::string>(), plugins_path, loaders); } - problem->installSensor(sen["type"], sen["name"], _server); + problem->installSensor(sensor_n); } - auto processors = _server.getParam<std::vector<std::map<std::string, std::string>>>("processors"); - for (auto prc : processors) + + // PROCESSORS =============================================================================== + // load plugin if processor is not registered + YAML::Node processors_node = param_node["processors"]; + for (auto processor_n : processors_node) { - if (not FactoryProcessor::isCreatorRegistered(prc["type"])) + auto processor_type = processor_n["type"].as<std::string>(); + if (not FactoryProcessor::isCreatorRegistered(processor_type)) { - auto plugin_name = prc["plugin"]; - std::string plugin = plugins_path + "libwolf" + plugin_name + lib_extension; - WOLF_TRACE("Loading plugin " + plugin_name + " via " + plugin); - auto l = std::make_shared<LoaderRaw>(plugin); - l->load(); - loaders.push_back(l); + loadPlugin(processor_n["plugin"].as<std::string>(), plugins_path, loaders); } - problem->installProcessor(prc["type"], prc["name"], prc["sensor_name"], _server); + problem->installProcessor(processor_n); } - // Map (optional) - std::string map_type, map_plugin; - try + // MAP (optional) =============================================================================== + // Default MapBase + if (not param_node["map"]) { - map_type = _server.getParam<std::string>("map/type"); - map_plugin = _server.getParam<std::string>("map/plugin"); - } - catch (MissingValueException& e) + param_node["map"]["type"] = "MapBase"; + } + // load plugin if map is not registered + YAML::Node map_node = param_node["map"]; + auto map_type = map_node["type"].as<std::string>(); + if (not FactoryMap::isCreatorRegistered(map_type)) { - WOLF_TRACE("No map/type and/or map/plugin specified. Emplacing the default map: MapBase."); - map_type = "MapBase"; - map_plugin = "core"; + loadPlugin(map_node["plugin"].as<std::string>(), plugins_path, loaders); } - WOLF_TRACE("Map Type: ", map_type, " in plugin ", map_plugin); - - auto map = AutoConfFactoryMap::create(map_type, _server); + WOLF_TRACE("Map Type: ", map_type); + auto map = FactoryMap::create(map_type, map_node); map->setProblem(problem); problem->setMap(map); - // Tree manager - std::string tree_manager_type = _server.getParam<std::string>("problem/tree_manager/type"); - WOLF_TRACE("Tree Manager Type: ", tree_manager_type); - if (tree_manager_type != "None" and tree_manager_type != "none") - problem->setTreeManager(FactoryTreeManagerServer::create(tree_manager_type, _server)); - - // Set problem prior -- first keyframe - std::string prior_mode = _server.getParam<std::string>("problem/prior/mode"); - assert((prior_mode == "nothing" || prior_mode == "initial_guess" || prior_mode == "fix" || prior_mode == "factor") && "wrong _mode value, it should be: 'nothing', 'initial_guess', 'fix' or 'factor'"); - WOLF_TRACE("Prior mode: ", prior_mode); - if (prior_mode == "nothing") - { - problem->setPriorOptions(prior_mode); - } - else if (prior_mode == "factor") - { - problem->setPriorOptions(prior_mode, - _server.getParam<VectorComposite>("problem/prior/state"), - _server.getParam<VectorComposite>("problem/prior/sigma")); - } - else - { - problem->setPriorOptions(prior_mode, - _server.getParam<VectorComposite>("problem/prior/state")); - } // Done return problem; } +void Problem::loadPlugin(const std::string& plugin_name, + const std::string& plugins_path, + std::list<std::shared_ptr<Loader>>& loaders) +{ +#if __APPLE__ + std::string lib_extension = ".dylib"; +#else + std::string lib_extension = ".so"; +#endif + + std::string plugin = plugins_path + "libwolf" + plugin_name + lib_extension; + WOLF_TRACE("Loading plugin " + plugin_name + " via " + plugin); + auto l = std::make_shared<LoaderRaw>(plugin); + l->load(); + loaders.push_back(l); +} + Problem::~Problem() { // WOLF_DEBUG("destructed -P"); } -SensorBasePtr Problem::installSensor(const std::string& _sen_type, - const std::string& _unique_sensor_name, - ParamsSensorBasePtr _params, - const Priors& _priors) +SensorBasePtr Problem::installSensor(const YAML::Node& _sensor_node) { - SensorBasePtr sen_ptr = FactorySensorPriors::create(_sen_type, - _unique_sensor_name, - dim_, - _params, - _priors); + SensorBasePtr sen_ptr = FactorySensor::create(_sensor_node["type"].as<std::string>(), dim_, _sensor_node); sen_ptr->link(getHardware()); return sen_ptr; } SensorBasePtr Problem::installSensor(const std::string& _sen_type, - const std::string& _unique_sensor_name, - const std::string& _params_yaml_filename) + const std::string& _params_yaml_filename, + const std::vector<std::string>& _folders_schema) { if (_params_yaml_filename == "" or not file_exists(_params_yaml_filename)) { throw std::runtime_error("Cannot install sensor: provided params YAML file: '" + _params_yaml_filename + "' does not exist."); } SensorBasePtr sen_ptr = FactorySensorYaml::create(_sen_type, - _unique_sensor_name, dim_, - _params_yaml_filename); + _params_yaml_filename, + _folders_schema); sen_ptr->link(getHardware()); return sen_ptr; } SensorBasePtr Problem::installSensor(const std::string& _sen_type, - const std::string& _unique_sensor_name, - const ParamsServer& _server) + ParamsSensorBasePtr _params, + const Priors& _priors) { - SensorBasePtr sen_ptr = FactorySensor::create(_sen_type, _unique_sensor_name, dim_, _server); + SensorBasePtr sen_ptr = FactorySensorPriors::create(_sen_type, + dim_, + _params, + _priors); sen_ptr->link(getHardware()); return sen_ptr; } -ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, - const std::string& _unique_processor_name, - SensorBasePtr _corresponding_sensor_ptr, - ParamsProcessorBasePtr _prc_params) +ProcessorBasePtr Problem::installProcessor(const YAML::Node& _processor_node) { - if (_corresponding_sensor_ptr == nullptr) - { - WOLF_ERROR("Cannot install processor '", _unique_processor_name, - "' since the associated sensor does not exist !"); - return ProcessorBasePtr(); - } + auto corresponding_sensor_name = _processor_node["sensor_name"].as<std::string>(); + SensorBasePtr sen_ptr = findSensor(corresponding_sensor_name); + if (sen_ptr == nullptr) + throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); - ProcessorBasePtr prc_ptr = FactoryProcessor::create(_prc_type, _unique_processor_name, _prc_params); + auto processor_type = _processor_node["type"].as<std::string>(); + ProcessorBasePtr prc_ptr = FactoryProcessor::create(processor_type, _processor_node); //Dimension check int prc_dim = prc_ptr->getDim(); auto prb = this; assert(((prc_dim == 0) or (prc_dim == prb->getDim())) && "Processor and Problem do not agree on dimension"); - prc_ptr->configure(_corresponding_sensor_ptr); - prc_ptr->link(_corresponding_sensor_ptr); + prc_ptr->configure(sen_ptr); + prc_ptr->link(sen_ptr); return prc_ptr; } -ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // - const std::string& _unique_processor_name, // - const std::string& _corresponding_sensor_name, // - const std::string& _params_filename) +ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, + const std::string& _corresponding_sensor_name, + const std::string& _params_yaml_filename, + const std::vector<std::string>& _folders_schema) { SensorBasePtr sen_ptr = findSensor(_corresponding_sensor_name); if (sen_ptr == nullptr) throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); - if (_params_filename == "") - return installProcessor(_prc_type, _unique_processor_name, sen_ptr, nullptr); - if (not file_exists(_params_filename)) - throw std::runtime_error("Cannot install processor: parameters' YAML file does not exist: " + _params_filename); + if (not file_exists(_params_yaml_filename)) + throw std::runtime_error("Cannot install processor: parameters' YAML file does not exist: " + _params_yaml_filename); - ProcessorBasePtr prc_ptr = FactoryProcessorYaml::create(_prc_type, _unique_processor_name, _params_filename); + ProcessorBasePtr prc_ptr = FactoryProcessorYaml::create(_prc_type, _params_yaml_filename, _folders_schema); //Dimension check int prc_dim = prc_ptr->getDim(); @@ -323,24 +316,26 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // return prc_ptr; } -ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // - const std::string& _unique_processor_name, // - const std::string& _corresponding_sensor_name, // - const ParamsServer& _server) +ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, + SensorBasePtr _corresponding_sensor_ptr, + ParamsProcessorBasePtr _prc_params) { - SensorBasePtr sen_ptr = findSensor(_corresponding_sensor_name); - if (sen_ptr == nullptr) - throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); + if (_corresponding_sensor_ptr == nullptr) + { + WOLF_ERROR("Cannot install processor '", _prc_params->name, + "' since the associated sensor does not exist !"); + return ProcessorBasePtr(); + } - ProcessorBasePtr prc_ptr = FactoryProcessorServer::create(_prc_type, _unique_processor_name, _server); + ProcessorBasePtr prc_ptr = FactoryProcessorParams::create(_prc_type, _prc_params); //Dimension check int prc_dim = prc_ptr->getDim(); auto prb = this; assert(((prc_dim == 0) or (prc_dim == prb->getDim())) && "Processor and Problem do not agree on dimension"); - prc_ptr->configure(sen_ptr); - prc_ptr->link(sen_ptr); + prc_ptr->configure(_corresponding_sensor_ptr); + prc_ptr->link(_corresponding_sensor_ptr); return prc_ptr; } @@ -664,7 +659,8 @@ void Problem::setTreeManager(TreeManagerBasePtr _gm) if (tree_manager_) tree_manager_->setProblem(nullptr); tree_manager_ = _gm; - tree_manager_->setProblem(shared_from_this()); + if (tree_manager_) + tree_manager_->setProblem(shared_from_this()); } void Problem::addMotionProvider(MotionProviderPtr _motion_provider_ptr) diff --git a/src/processor/processor_base.cpp b/src/processor/processor_base.cpp index 90e40f241c6d15a131b469f31db5c5b9b2938ee2..a4a448aa610ebc9890f90b9060005c1d54f7881f 100644 --- a/src/processor/processor_base.cpp +++ b/src/processor/processor_base.cpp @@ -29,7 +29,7 @@ namespace wolf { unsigned int ProcessorBase::processor_id_count_ = 0; ProcessorBase::ProcessorBase(const std::string& _type, int _dim, ParamsProcessorBasePtr _params) : - NodeBase("PROCESSOR", _type), + NodeBase("PROCESSOR", _type, _params->name), processor_id_(++processor_id_count_), params_(_params), dim_(_dim), diff --git a/src/sensor/sensor_base.cpp b/src/sensor/sensor_base.cpp index 394cf9b6e7d667096b80b1b55dcf840e37b6372a..9ecb93796fdf739fe3ae253a1c8d19b9502aa4e4 100644 --- a/src/sensor/sensor_base.cpp +++ b/src/sensor/sensor_base.cpp @@ -20,7 +20,6 @@ // //--------LICENSE_END-------- #include "core/sensor/sensor_base.h" -#include "core/utils/params_server.h" #include "core/state_block/prior.h" #include "core/state_block/factory_state_block.h" #include "core/state_block/state_block.h" @@ -37,7 +36,7 @@ SensorBase::SensorBase(const std::string& _type, const SizeEigen& _dim, ParamsSensorBasePtr _params, const Priors& _priors) : - NodeBase("SENSOR", _type, _params["name"].as<std::string>()), + NodeBase("SENSOR", _type, _params->name), HasStateBlocks("PO"), hardware_ptr_(), sensor_id_(++sensor_id_count_), // simple ID factory diff --git a/src/state_block/prior.cpp b/src/state_block/prior.cpp index 9e31d09a037cad680a2c3581dff24912849fa944..dbe10672f8552159b714f5f32737e51e8fb9104a 100644 --- a/src/state_block/prior.cpp +++ b/src/state_block/prior.cpp @@ -22,7 +22,7 @@ #include "core/state_block/prior.h" #include "core/state_block/factory_state_block.h" -#include "core/utils/params_server.h" +#include "core/common/params_base.h" // toString() namespace wolf { @@ -37,21 +37,20 @@ Prior::Prior(const std::string& _type, check(); } -Prior::Prior(const std::string& _prefix, const std::string& _type, const ParamsServer& _server) - : type_(_type) +Prior::Prior(const YAML::Node& prior_node) { - state_ = _server.getParam<Eigen::VectorXd>(_prefix + "/state"); - mode_ = _server.getParam<std::string>(_prefix + "/mode"); + state_ = prior_node["state"].as<Eigen::VectorXd>(); + mode_ = prior_node["mode"].as<std::string>(); if (mode_ == "factor") - noise_std_ = _server.getParam<Eigen::VectorXd>(_prefix + "/noise_std"); + noise_std_ = prior_node["noise_std"].as<Eigen::VectorXd>(); else noise_std_ = Eigen::VectorXd(0); - dynamic_ = _server.getParam<bool>(_prefix + "/dynamic"); + dynamic_ = prior_node["dynamic"].as<bool>(); - if (dynamic_ and _server.hasParam(_prefix + "/drift_std")) - drift_std_ = _server.getParam<Eigen::VectorXd>(_prefix + "/drift_std"); + if (dynamic_ and prior_node["drift_std"]) + drift_std_ = prior_node["drift_std"].as<Eigen::VectorXd>(); else drift_std_ = Eigen::VectorXd(0); diff --git a/src/utils/params_server.cpp b/src/utils/params_server.cpp index 2aa43047fe569b9c35a23d164ff812e78fa9a60d..7ed323ab07779dd76737eae55f4b5b8818b45922 100644 --- a/src/utils/params_server.cpp +++ b/src/utils/params_server.cpp @@ -58,54 +58,4 @@ void ParamsServer::addParams(std::map<std::string, std::string> _params) addParam(param_pair.first, param_pair.second); } -std::string toString(bool _arg) -{ - return (_arg ? "true" : "false"); -} - -std::string toString(int _arg) -{ - return std::to_string(_arg); -} - -std::string toString(long _arg) -{ - return std::to_string(_arg); -} - -std::string toString(long long _arg) -{ - return std::to_string(_arg); -} - -std::string toString(unsigned _arg) -{ - return std::to_string(_arg); -} - -std::string toString(unsigned long _arg) -{ - return std::to_string(_arg); -} - -std::string toString(unsigned long long _arg) -{ - return std::to_string(_arg); -} - -std::string toString(float _arg) -{ - return std::to_string(_arg); -} - -std::string toString(double _arg) -{ - return std::to_string(_arg); -} - -std::string toString(long double _arg) -{ - return std::to_string(_arg); -} - } diff --git a/test/dummy/dummy_object.h b/test/dummy/dummy_object.h index ab865a1449ac6a8610129cd8e1f8427bf02d22ec..c1000ee41128bcb00c0aa257014e32f1e2b72dd5 100644 --- a/test/dummy/dummy_object.h +++ b/test/dummy/dummy_object.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef WOLF_DUMMY_OBJECT_H_ -#define WOLF_DUMMY_OBJECT_H_ +#pragma once /************************** * WOLF includes * @@ -95,21 +94,4 @@ inline std::string DummyObject::getName() const return name_; } -// template<typename T> -// inline T DummyObject::getParamWithDefault(const ParamsServer &_server, -// const std::string &_param_name, -// const T _default_value) const -// { -// try -// { -// return _server.getParam<T>(_param_name); -// } -// catch (...) -// { -// WOLF_INFO("DummyObject: Parameter ", _param_name, " is missing. Taking default value: ", _default_value); -// return _default_value; -// } -// } - -} -#endif +} \ No newline at end of file diff --git a/test/dummy/dummy_object_derived.h b/test/dummy/dummy_object_derived.h index 78bf5079fe99a57965f60dd2d6d9c5b67af09a7b..b611dab32e79f877043d14aa9145a284868e627d 100644 --- a/test/dummy/dummy_object_derived.h +++ b/test/dummy/dummy_object_derived.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef DUMMY_OBJECT_DERIVED_H_ -#define DUMMY_OBJECT_DERIVED_H_ +#pragma once /************************** * WOLF includes * @@ -44,6 +43,4 @@ class DummyObjectDerived : public DummyObject }; WOLF_REGISTER_DUMMY_OBJECT(DummyObjectDerived) -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/test/dummy/factor_dummy.h b/test/dummy/factor_dummy.h index 73174d1468e07807e26ab2a6dcf4579ad5a00ef8..b03a8f25e412240cfd52a8682f4bd33581379376 100644 --- a/test/dummy/factor_dummy.h +++ b/test/dummy/factor_dummy.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_DUMMY_H -#define FACTOR_DUMMY_H +#pragma once #include "core/factor/factor_base.h" @@ -107,6 +106,4 @@ class FactorDummy : public FactorBase } }; -} - -#endif // FACTOR_DUMMY_H \ No newline at end of file +} \ No newline at end of file diff --git a/test/dummy/factor_dummy_zero_1.h b/test/dummy/factor_dummy_zero_1.h index 5a52d9c47f61581048d132eb421d4e47474c02d4..fbc36b874aebd6d47202b16e73b84e8b029cf21c 100644 --- a/test/dummy/factor_dummy_zero_1.h +++ b/test/dummy/factor_dummy_zero_1.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_DUMMY_ZERO_1_H_ -#define FACTOR_DUMMY_ZERO_1_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -61,6 +60,4 @@ class FactorDummyZero1 : public FactorAutodiff<FactorDummyZero1, 1, 1> } }; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/factor_dummy_zero_12.h b/test/dummy/factor_dummy_zero_12.h index 707a99908b55bcf1204b54a75889ba9685a95b32..908c34b4f4af6f8cc7c943f24f1808b7e27df63f 100644 --- a/test/dummy/factor_dummy_zero_12.h +++ b/test/dummy/factor_dummy_zero_12.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_DUMMY_ZERO_12_H_ -#define FACTOR_DUMMY_ZERO_12_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -171,6 +170,4 @@ class FactorDummyZero12 : public FactorAutodiff<FactorDummyZero12<ID>, ID, 1, 2, } }; -} // namespace wolf - -#endif +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/factor_feature_dummy.h b/test/dummy/factor_feature_dummy.h index b8f8266c43dea8060c28d5677cbb1082527f11a8..16ae4cec7b4cbafad5e9460920c292a5e7f9421f 100644 --- a/test/dummy/factor_feature_dummy.h +++ b/test/dummy/factor_feature_dummy.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_FEATURE_DUMMY_H -#define FACTOR_FEATURE_DUMMY_H +#pragma once #include "core/factor/factor_base.h" @@ -99,6 +98,4 @@ inline FactorBasePtr FactorFeatureDummy::create(const FeatureBasePtr& _feature_p _processor_ptr); } -} // namespace wolf - -#endif // FACTOR_FEATURE_DUMMY_H +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/factor_landmark_dummy.h b/test/dummy/factor_landmark_dummy.h index ceff8247e73c02bb8ac9bb2ca7151486e3f69f87..49e2bbe31edff984517f86ebd41dcf03995eae02 100644 --- a/test/dummy/factor_landmark_dummy.h +++ b/test/dummy/factor_landmark_dummy.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_LANDMARK_DUMMY_H -#define FACTOR_LANDMARK_DUMMY_H +#pragma once #include "core/factor/factor_base.h" @@ -112,6 +111,4 @@ inline FactorBasePtr FactorLandmarkDummy::create(const FeatureBasePtr& _feature_ _processor_ptr); } -} // namespace wolf - -#endif // FACTOR_LANDMARK_DUMMY_H +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/factor_odom_2d_autodiff.h b/test/dummy/factor_odom_2d_autodiff.h index 9d09f97ae8614168701ad12940d950a14342f383..2fbda080781a96ff485e8c7c1f948fcf34ed52a5 100644 --- a/test/dummy/factor_odom_2d_autodiff.h +++ b/test/dummy/factor_odom_2d_autodiff.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTOR_ODOM_2d_AUTODIFF_H_ -#define FACTOR_ODOM_2d_AUTODIFF_H_ +#pragma once //Wolf includes #include "core/factor/factor_autodiff.h" @@ -116,6 +115,4 @@ inline bool FactorOdom2dAutodiff::operator ()(const T* const _p1, const T* const return true; } -} // namespace wolf - -#endif // FACTOR_ODOM_2d_AUTODIFF_H_ +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/factory_dummy_object.h b/test/dummy/factory_dummy_object.h index 34a215963d94f3837cf77724b0859ce99ea49c0b..88e15e0b3641a23ab358101dbed5511a2cf6f167 100644 --- a/test/dummy/factory_dummy_object.h +++ b/test/dummy/factory_dummy_object.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef FACTORY_DUMMY_OBJECT_H_ -#define FACTORY_DUMMY_OBJECT_H_ +#pragma once // wolf #include <core/common/factory.h> @@ -44,5 +43,4 @@ inline std::string FactoryDummyObject::getClass() const namespace{ const bool WOLF_UNUSED DummyObjectType##Registered = \ wolf::FactoryDummyObject::registerCreator(#DummyObjectType, DummyObjectType::create); } \ -} /* namespace wolf */ -#endif /* FACTORY_DUMMY_OBJECT_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/test/dummy/processor_loop_closure_dummy.h b/test/dummy/processor_loop_closure_dummy.h index a0e456eec87ed473b11852a5981fb3ff2e494eba..3d2e2e8e1687225307dae8a6ceebf37534d1f92d 100644 --- a/test/dummy/processor_loop_closure_dummy.h +++ b/test/dummy/processor_loop_closure_dummy.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef TEST_DUMMY_PROCESSOR_LOOP_CLOSURE_DUMMY_H_ -#define TEST_DUMMY_PROCESSOR_LOOP_CLOSURE_DUMMY_H_ +#pragma once #include "core/processor/processor_loop_closure.h" @@ -108,7 +107,4 @@ class ProcessorLoopClosureDummy : public ProcessorLoopClosure { return buffer_capture_.getContainer().size(); } -}; - - -#endif /* TEST_DUMMY_PROCESSOR_LOOP_CLOSURE_DUMMY_H_ */ +}; \ No newline at end of file diff --git a/test/dummy/processor_motion_provider_dummy.h b/test/dummy/processor_motion_provider_dummy.h index 4e67ec2f75676c274d71b50104f74cdab7d8cbf1..a7e64038e15c0a22130ba1f6fbddb22c08d02373 100644 --- a/test/dummy/processor_motion_provider_dummy.h +++ b/test/dummy/processor_motion_provider_dummy.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * processor_motion_provider_dummy.h - * - * Created on: Mar 8, 2021 - * Author: joanvallve - */ - -#ifndef TEST_DUMMY_PROCESSOR_MOTION_PROVIDER_DUMMY_H_ -#define TEST_DUMMY_PROCESSOR_MOTION_PROVIDER_DUMMY_H_ +#pragma once #include <core/processor/motion_provider.h> #include "core/processor/processor_base.h" @@ -42,9 +34,9 @@ struct ParamsMotionProviderDummy : public ParamsProcessorBase, public ParamsMoti std::string state_structure = "PO"; ParamsMotionProviderDummy() = default; - ParamsMotionProviderDummy(std::string _unique_name, const ParamsServer& _server): - ParamsProcessorBase(_unique_name, _server), - ParamsMotionProvider(_unique_name, _server) + ParamsMotionProviderDummy(const YAML::Node& _n): + ParamsProcessorBase(_n), + ParamsMotionProvider(_n) { }; @@ -91,6 +83,4 @@ class MotionProviderDummy : public ProcessorBase, public MotionProvider #include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR(MotionProviderDummy); -} // namespace wolf - -#endif /* TEST_DUMMY_PROCESSOR_MOTION_PROVIDER_DUMMY_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/processor_tracker_feature_dummy.h b/test/dummy/processor_tracker_feature_dummy.h index d68a55e03bf427c1559add05b30d1a27c47ab87f..ffc25ac1a6a8fa23fd6885ceb248ed6ad7bf7593 100644 --- a/test/dummy/processor_tracker_feature_dummy.h +++ b/test/dummy/processor_tracker_feature_dummy.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file processor_tracker_feature_dummy.h - * - * Created on: Apr 11, 2016 - * \author: jvallve - */ - -#ifndef PROCESSOR_TRACKER_FEATURE_DUMMY_H_ -#define PROCESSOR_TRACKER_FEATURE_DUMMY_H_ +#pragma once #include "core/common/wolf.h" #include "core/processor/processor_tracker_feature.h" @@ -43,11 +35,10 @@ struct ParamsProcessorTrackerFeatureDummy : public ParamsProcessorTrackerFeature unsigned int n_tracks_lost; ///< number of tracks lost each time track is called (the first ones) ParamsProcessorTrackerFeatureDummy() = default; - ParamsProcessorTrackerFeatureDummy(std::string _unique_name, - const wolf::ParamsServer & _server): - ParamsProcessorTrackerFeature(_unique_name, _server) + ParamsProcessorTrackerFeatureDummy(const YAML::Node& _n): + ParamsProcessorTrackerFeature(_n) { - n_tracks_lost = _server.getParam<unsigned int>(prefix + _unique_name + "/n_tracks_lost"); + n_tracks_lost = _n["n_tracks_lost"].as<unsigned int>(); } }; @@ -150,6 +141,4 @@ inline bool ProcessorTrackerFeatureDummy::correctFeatureDrift(const FeatureBaseP return true; } -} // namespace wolf - -#endif /* PROCESSOR_TRACKER_FEATURE_DUMMY_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/processor_tracker_landmark_dummy.h b/test/dummy/processor_tracker_landmark_dummy.h index 22060c82d0c27d4670cd94be45b652efaab0e902..b7f0608d421f75839cd043ba6972a02039a56ca3 100644 --- a/test/dummy/processor_tracker_landmark_dummy.h +++ b/test/dummy/processor_tracker_landmark_dummy.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file processor_tracker_landmark_dummy.h - * - * Created on: Apr 12, 2016 - * \author: jvallve - */ - -#ifndef PROCESSOR_TRACKER_LANDMARK_DUMMY_H_ -#define PROCESSOR_TRACKER_LANDMARK_DUMMY_H_ +#pragma once #include "core/processor/processor_tracker_landmark.h" @@ -41,10 +33,10 @@ struct ParamsProcessorTrackerLandmarkDummy : public ParamsProcessorTrackerLandma unsigned int n_landmarks_lost; ///< number of landmarks lost each time findLandmarks is called (the last ones) ParamsProcessorTrackerLandmarkDummy() = default; - ParamsProcessorTrackerLandmarkDummy(std::string _unique_name, const wolf::ParamsServer & _server): - ParamsProcessorTrackerLandmark(_unique_name, _server) + ParamsProcessorTrackerLandmarkDummy(const YAML::Node& _n): + ParamsProcessorTrackerLandmark(_n) { - n_landmarks_lost = _server.getParam<unsigned int>(prefix + _unique_name + "/n_landmarks_lost"); + n_landmarks_lost = _n["n_landmarks_lost"].as<unsigned int>(); } }; @@ -124,6 +116,4 @@ class ProcessorTrackerLandmarkDummy : public ProcessorTrackerLandmark LandmarkBasePtr _landmark_ptr) override; }; -} // namespace wolf - -#endif /* PROCESSOR_TRACKER_LANDMARK_DUMMY_H_ */ +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/sensor_dummy.h b/test/dummy/sensor_dummy.h index 5421d72fac0bbd7b53ed9191d91eeb54cdb3014f..96e8b5777a61a69e5773759c5ffa9a2cd461e163 100644 --- a/test/dummy/sensor_dummy.h +++ b/test/dummy/sensor_dummy.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef SENSOR_DUMMY_H_ -#define SENSOR_DUMMY_H_ +#pragma once /************************** * WOLF includes * @@ -37,11 +36,11 @@ struct ParamsSensorDummy : public ParamsSensorBase double noise_o_std; ParamsSensorDummy() = default; - ParamsSensorDummy(std::string _unique_name, const ParamsServer& _server): - ParamsSensorBase(_unique_name, _server) + ParamsSensorDummy(const YAML::Node& _n): + ParamsSensorBase(_n) { - noise_p_std = _server.getParam<double>(prefix + _unique_name + "/noise_p_std"); - noise_o_std = _server.getParam<double>(prefix + _unique_name + "/noise_o_std"); + noise_p_std = _n["noise_p_std"].as<double>(); + noise_o_std = _n["noise_o_std"].as<double>(); } ~ParamsSensorDummy() override = default; std::string print() const override @@ -61,33 +60,17 @@ class SensorDummy : public SensorBase SizeEigen dim_; public: - SensorDummy(const std::string& _unique_name, - SizeEigen _dim, - ParamsSensorDummyPtr _params, - const ParamsServer& _server) : - SensorBase("SensorDummy", - _unique_name, - _dim, - _params, - _server), - params_dummy_(_params) - { - } - WOLF_SENSOR_CREATE(SensorDummy, ParamsSensorDummy); - - - SensorDummy(const std::string& _unique_name, - SizeEigen _dim, + SensorDummy(SizeEigen _dim, ParamsSensorDummyPtr _params, const Priors& _priors) : SensorBase("SensorDummy", - _unique_name, _dim, _params, _priors), params_dummy_(_params) { } + WOLF_SENSOR_CREATE(SensorDummy, ParamsSensorDummy); virtual ~SensorDummy(){}; @@ -104,5 +87,4 @@ class SensorDummy : public SensorBase #include "core/sensor/factory_sensor.h" namespace wolf { WOLF_REGISTER_SENSOR(SensorDummy); -} // namespace wolf -#endif +} // namespace wolf \ No newline at end of file diff --git a/test/dummy/sensor_dummy_poia.h b/test/dummy/sensor_dummy_poia.h index c311e9cea73ac4faac86ccaac0d77976d072faea..f81eca9efb48f8fcbc69254d1062347402c28600 100644 --- a/test/dummy/sensor_dummy_poia.h +++ b/test/dummy/sensor_dummy_poia.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef SENSOR_DummyPoi_H_ -#define SENSOR_DummyPoi_H_ +#pragma once /************************** * WOLF includes * @@ -30,16 +29,16 @@ namespace wolf { -SpecStates specs_states_dummy_poia({{'I',SpecState("StateBlock", 5, "some doc for state I")}, - {'A',SpecState("StateQuaternion", 4, "some doc for state A")}}); +// SpecStates specs_states_dummy_poia({{'I',SpecState("StateBlock", 5, "some doc for state I")}, + // {'A',SpecState("StateQuaternion", 4, "some doc for state A")}}); WOLF_STRUCT_PTR_TYPEDEFS(ParamsSensorDummyPoia); struct ParamsSensorDummyPoia : public ParamsSensorDummy { ParamsSensorDummyPoia() = default; - ParamsSensorDummyPoia(std::string _unique_name, const ParamsServer& _server): - ParamsSensorDummy(_unique_name, _server) + ParamsSensorDummyPoia(const YAML::Node& _n): + ParamsSensorDummy(_n) { } ~ParamsSensorDummyPoia() override = default; @@ -58,36 +57,18 @@ class SensorDummyPoia : public SensorBase SizeEigen dim_; public: - SensorDummyPoia(const std::string& _unique_name, - SizeEigen _dim, - ParamsSensorDummyPoiaPtr _params, - const ParamsServer& _server) : + SensorDummyPoia(SizeEigen _dim, + ParamsSensorDummyPoiaPtr _params, + const Priors& _priors) : SensorBase("SensorDummyPoia", - _unique_name, _dim, _params, - _server, - specs_states_dummy_poia), + _priors), params_dummy_poia_(_params) { } WOLF_SENSOR_CREATE(SensorDummyPoia, ParamsSensorDummyPoia); - - SensorDummyPoia(const std::string& _unique_name, - SizeEigen _dim, - ParamsSensorDummyPoiaPtr _params, - const Priors& _priors) : - SensorBase("SensorDummyPoia", - _unique_name, - _dim, - _params, - _priors, - specs_states_dummy_poia), - params_dummy_poia_(_params) - { - } - virtual ~SensorDummyPoia(){}; Eigen::MatrixXd computeNoiseCov(const Eigen::VectorXd & _data) const override @@ -104,4 +85,3 @@ class SensorDummyPoia : public SensorBase namespace wolf { WOLF_REGISTER_SENSOR(SensorDummyPoia); } // namespace wolf -#endif diff --git a/test/dummy/solver_manager_dummy.h b/test/dummy/solver_manager_dummy.h index 9c4df89d8d7ef2a6c0d9fd8ee568ba9d71247178..acef8846b04e9465607520e9de5fdb45c6f5868b 100644 --- a/test/dummy/solver_manager_dummy.h +++ b/test/dummy/solver_manager_dummy.h @@ -19,15 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/* - * solver_manager_dummy.h - * - * Created on: May 27, 2020 - * Author: joanvallve - */ - -#ifndef TEST_DUMMY_SOLVER_MANAGER_DUMMY_H_ -#define TEST_DUMMY_SOLVER_MANAGER_DUMMY_H_ +#pragma once #include "core/solver/solver_manager.h" @@ -126,6 +118,4 @@ class SolverManagerDummy : public SolverManager }; }; -} - -#endif /* TEST_DUMMY_SOLVER_MANAGER_DUMMY_H_ */ +} \ No newline at end of file diff --git a/test/dummy/tree_manager_dummy.h b/test/dummy/tree_manager_dummy.h index 33a8f8fcfda9ec19ff57fd05cb2c2590bd14932f..3866cb688d5f0aa2c343b2ae03952f4cf981e23e 100644 --- a/test/dummy/tree_manager_dummy.h +++ b/test/dummy/tree_manager_dummy.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef INCLUDE_TREE_MANAGER_DUMMY_H_ -#define INCLUDE_TREE_MANAGER_DUMMY_H_ +#pragma once #include "core/tree_manager/tree_manager_base.h" @@ -31,10 +30,10 @@ WOLF_STRUCT_PTR_TYPEDEFS(ParamsTreeManagerDummy) struct ParamsTreeManagerDummy : public ParamsTreeManagerBase { ParamsTreeManagerDummy() = default; - ParamsTreeManagerDummy(const ParamsServer& _server): - ParamsTreeManagerBase(_server) + ParamsTreeManagerDummy(const YAML::Node& _n): + ParamsTreeManagerBase(_n) { - toy_param = _server.getParam<double>(prefix + "/toy_param"); + toy_param = _n["toy_param"].as<double>(); } ~ParamsTreeManagerDummy() override = default; @@ -75,7 +74,4 @@ class TreeManagerDummy : public TreeManagerBase #include "core/tree_manager/factory_tree_manager.h" namespace wolf { WOLF_REGISTER_TREE_MANAGER(TreeManagerDummy) - -} /* namespace wolf */ - -#endif /* INCLUDE_TREE_MANAGER_DUMMY_H_ */ +} /* namespace wolf */ \ No newline at end of file diff --git a/wolf_scripts/templates/class_template.h b/wolf_scripts/templates/class_template.h index a86b1d70ced441fbe57d4c6c16d1cf3bde95b7c8..0981af23308f61f52f36dd7fe6b1fdaa2b3dbf9c 100644 --- a/wolf_scripts/templates/class_template.h +++ b/wolf_scripts/templates/class_template.h @@ -19,8 +19,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -#ifndef _name_cap_H_ -#define _name_cap_H_ +#pragma once //Wolf includes #include "wolf.h" @@ -45,6 +44,4 @@ class class_name : public base_class virtual ~class_name(); }; -} // namespace wolf - -#endif /* _name_cap_H_ */ +} // namespace wolf \ No newline at end of file