4#include <rclcpp/rclcpp.hpp>
6#include <unordered_set>
8#include <std_msgs/msg/color_rgba.hpp>
22 std::ostream&
operator<<(std::ostream& os,
const Eigen::MatrixX<T>& var);
66 using MatrixX = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
71 bool m_load_successful, m_print_values;
72 std::string m_node_name;
73 std::shared_ptr<rclcpp::Node> m_node;
75 std::unordered_set<resolved_name_t> m_loaded_params;
81 void printError(
const std::string& str);
82 void printWarning(
const std::string& str);
105 template <
typename T>
106 std::pair<MatrixX<T>,
bool> loadMatrixX(
const std::string& name,
const MatrixX<T>& default_value,
int rows,
int cols = Eigen::Dynamic,
107 optional_t optional = OPTIONAL, unique_t unique = UNIQUE, swap_t swap = NO_SWAP,
bool printValues =
true);
111 template <
int rows,
int cols,
typename T>
112 std::pair<Eigen::Matrix<T, rows, cols>,
bool> loadMatrixStatic_internal(
const std::string& name,
const Eigen::Matrix<T, rows, cols>& default_value,
113 optional_t optional, unique_t unique);
117 template <
typename T>
118 std::pair<MatrixX<T>,
bool> loadMatrixKnown_internal(
const std::string& name,
const MatrixX<T>& default_value,
int rows,
int cols, optional_t optional,
123 template <
typename T>
124 std::pair<MatrixX<T>,
bool> loadMatrixDynamic_internal(
const std::string& name,
const MatrixX<T>& default_value,
int rows,
int cols, optional_t optional,
129 template <
typename T>
130 std::vector<MatrixX<T>> loadMatrixArray_internal(
const std::string& name,
const std::vector<MatrixX<T>>& default_value, optional_t optional,
148 template <
typename T>
149 std::pair<T, bool> load(
const std::string& name,
const T& default_value, optional_t optional = OPTIONAL, unique_t unique = UNIQUE);
161 ParamLoader(
const std::shared_ptr<rclcpp::Node>& node,
bool printValues =
true, std::string_view node_name = std::string());
170 ParamLoader(
const std::shared_ptr<rclcpp::Node>& node, std::string node_name);
184 void setPrefix(
const std::string& prefix);
271 template <
typename T>
272 bool loadParam(
const std::string& name, T& out_value,
const T& default_value);
285 template <
typename T>
286 T
loadParam2(
const std::string& name,
const T& default_value);
300 template <
typename T>
301 bool loadParamReusable(
const std::string& name, T& out_value,
const T& default_value);
314 template <
typename T>
331 template <
typename T>
332 bool loadParam(
const std::string& name, T& out_value);
344 template <
typename T>
358 template <
typename T>
371 template <
typename T>
388 bool loadParam(
const std::string& name, rclcpp::Duration& out,
const rclcpp::Duration& default_value);
399 bool loadParam(
const std::string& name, rclcpp::Duration& out);
415 bool loadParam(
const std::string& name, std_msgs::msg::ColorRGBA& out,
const std_msgs::msg::ColorRGBA& default_value = std_msgs::msg::ColorRGBA());
426 std_msgs::msg::ColorRGBA
loadParam2(
const std::string& name,
const std_msgs::msg::ColorRGBA& default_value = std_msgs::msg::ColorRGBA());
446 template <
typename T>
447 bool loadParam(
const std::string& name, MatrixX<T>& mat,
const MatrixX<T>& default_value);
462 template <
typename T>
463 MatrixX<T>
loadParam2(
const std::string& name,
const MatrixX<T>& default_value);
486 template <
int rows,
int cols,
typename T>
487 bool loadMatrixStatic(
const std::string& name, Eigen::Matrix<T, rows, cols>& mat);
506 template <
int rows,
int cols,
typename T,
typename Derived>
507 bool loadMatrixStatic(
const std::string& name, Eigen::Matrix<T, rows, cols>& mat,
const Eigen::MatrixBase<Derived>& default_value);
525 template <
int rows,
int cols,
typename T =
double>
544 template <
int rows,
int cols,
typename T,
typename Derived>
545 Eigen::Matrix<T, rows, cols>
loadMatrixStatic2(
const std::string& name,
const Eigen::MatrixBase<Derived>& default_value);
566 template <
typename T>
567 bool loadMatrixKnown(
const std::string& name, MatrixX<T>& mat,
int rows,
int cols);
584 template <
typename T,
typename Derived>
585 bool loadMatrixKnown(
const std::string& name, MatrixX<T>& mat,
const Eigen::MatrixBase<Derived>& default_value,
int rows,
int cols);
601 template <
typename T =
double>
618 template <
typename T,
typename Derived>
619 MatrixX<T>
loadMatrixKnown2(
const std::string& name,
const Eigen::MatrixBase<Derived>& default_value,
int rows,
int cols);
640 template <
typename T>
641 bool loadMatrixDynamic(
const std::string& name, MatrixX<T>& mat,
int rows,
int cols);
659 template <
typename T,
typename Derived>
660 bool loadMatrixDynamic(
const std::string& name, MatrixX<T>& mat,
const Eigen::MatrixBase<Derived>& default_value,
int rows,
int cols);
676 template <
typename T =
double>
693 template <
typename T,
typename Derived>
694 MatrixX<T>
loadMatrixDynamic2(
const std::string& name,
const Eigen::MatrixBase<Derived>& default_value,
int rows,
int cols);
731 template <
typename T>
732 void loadMatrixArray(
const std::string& name, std::vector<MatrixX<T>>& mat);
745 template <
typename T>
746 void loadMatrixArray(
const std::string& name, std::vector<MatrixX<T>>& mat,
const std::vector<MatrixX<T>>& default_value);
758 template <
typename T =
double>
772 template <
typename T>
773 std::vector<MatrixX<T>>
loadMatrixArray2(
const std::string& name,
const std::vector<MatrixX<T>>& default_value);
789 rclcpp::Duration ParamLoader::loadParam2<rclcpp::Duration>(
const std::string& name,
const rclcpp::Duration& default_value);
800 rclcpp::Duration ParamLoader::loadParam2<rclcpp::Duration>(
const std::string& name);
804#include <mrs_lib/impl/param_loader.hpp>
Convenience class for loading parameters from rosparam server.
Definition param_loader.h:46
void copyYamls(const ParamLoader ¶m_loader)
Copies parsed YAMLs from another ParamLoader.
Definition param_loader.cpp:136
bool loadMatrixKnown(const std::string &name, MatrixX< T > &mat, int rows, int cols)
Specialized method for loading compulsory Eigen matrix parameters.
Definition param_loader.hpp:603
void resetLoadedSuccessfully()
Resets the loadedSuccessfully flag back to true.
Definition param_loader.cpp:113
bool loadedSuccessfully() const
Indicates whether all compulsory parameters were successfully loaded.
Definition param_loader.cpp:108
std::vector< MatrixX< T > > loadMatrixArray2(const std::string &name)
Specialized method for loading compulsory parameters, interpreted as an array of dynamic Eigen matric...
Definition param_loader.hpp:840
bool addYamlFileFromParam(const std::string ¶m_name)
Loads a filepath from a parameter loads that file as a YAML.
Definition param_loader.cpp:128
void loadMatrixArray(const std::string &name, std::vector< MatrixX< T > > &mat)
Specialized method for loading compulsory parameters, interpreted as an array of dynamic Eigen matric...
Definition param_loader.hpp:807
std::string getPrefix()
Returns the current parameter name prefix.
Definition param_loader.cpp:103
T loadParam2(const std::string &name, const T &default_value)
Loads a parameter from the rosparam server with a default value.
Definition param_loader.hpp:322
bool addYamlFile(const std::string &filepath)
Adds the specified file as a source of static parameters.
Definition param_loader.cpp:123
void setPrefix(const std::string &prefix)
Sets a prefix that will be applied to parameter names before subnode namespaces.
Definition param_loader.cpp:98
Eigen::Matrix< T, rows, cols > loadMatrixStatic2(const std::string &name)
Specialized method for loading compulsory Eigen matrix parameters.
Definition param_loader.hpp:553
bool loadParam(const std::string &name, T &out_value, const T &default_value)
Loads a parameter from the rosparam server with a default value.
Definition param_loader.hpp:304
bool loadMatrixStatic(const std::string &name, Eigen::Matrix< T, rows, cols > &mat)
Specialized method for loading compulsory Eigen matrix parameters.
Definition param_loader.hpp:504
MatrixX< T > loadMatrixKnown2(const std::string &name, int rows, int cols)
Specialized method for loading compulsory Eigen matrix parameters.
Definition param_loader.hpp:648
ParamProvider & getParamProvider()
Returns the internal ParamProvider object.
Definition param_loader.cpp:141
bool loadMatrixDynamic(const std::string &name, MatrixX< T > &mat, int rows, int cols)
Specialized method for loading compulsory dynamic Eigen matrix parameters.
Definition param_loader.hpp:696
bool loadParamReusable(const std::string &name, T &out_value, const T &default_value)
Loads a parameter from the rosparam server with a default value.
Definition param_loader.hpp:340
MatrixX< T > loadMatrixDynamic2(const std::string &name, int rows, int cols)
Specialized method for loading compulsory dynamic Eigen matrix parameters.
Definition param_loader.hpp:742
T loadParamReusable2(const std::string &name, const T &default_value)
Loads an optional reusable parameter from the rosparam server.
Definition param_loader.hpp:358
void resetUniques()
Resets the list of already loaded parameter names used when checking for uniqueness.
Definition param_loader.cpp:118
Helper class for ParamLoader and DynparamMgr.
Definition param_provider.h:73
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
std::ostream & operator<<(std::ostream &os, const Eigen::MatrixX< T > &var)
Helper overload for printing of Eigen matrices.
Definition param_loader.hpp:21
Defines ParamProvider - a convenience class for seamlessly loading parameters from YAML or ROS.
Definition param_provider.hpp:43