mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
param_provider.h
Go to the documentation of this file.
1 // clang: MatousFormat
7 #ifndef PARAM_PROVIDER_H
8 #define PARAM_PROVIDER_H
9 
10 #include <optional>
11 
12 #include <yaml-cpp/yaml.h>
13 #include <ros/node_handle.h>
14 
15 namespace mrs_lib
16 {
17 
18 /*** ParamProvider CLASS //{ **/
19 
31  {
32  public:
33 
41  ParamProvider(const ros::NodeHandle& nh, std::string node_name, const bool use_rosparam = true);
42 
50  bool addYamlFile(const std::string& filepath);
51 
63  template <typename T>
64  bool getParam(const std::string& param_name, T& value_out) const;
65 
77  bool getParam(const std::string& param_name, XmlRpc::XmlRpcValue& value_out) const;
78 
79  private:
80 
81  std::vector<YAML::Node> m_yamls;
82  ros::NodeHandle m_nh;
83  std::string m_node_name;
84  bool m_use_rosparam;
85 
86  template <typename T>
87  bool getParamImpl(const std::string& param_name, T& value_out) const;
88 
89  std::optional<YAML::Node> findYamlNode(const std::string& param_name) const;
90  };
91 //}
92 }
93 
94 #include "mrs_lib/impl/param_provider.hpp"
95 
96 #endif // PARAM_PROVIDER_H
mrs_lib::ParamProvider::addYamlFile
bool addYamlFile(const std::string &filepath)
Add a YAML file to be parsed and used for loading parameters.
Definition: param_provider.cpp:18
mrs_lib::ParamProvider::ParamProvider
ParamProvider(const ros::NodeHandle &nh, std::string node_name, const bool use_rosparam=true)
Main constructor.
Definition: param_provider.cpp:13
mrs_lib::ParamProvider::getParam
bool getParam(const std::string &param_name, T &value_out) const
Gets the value of a parameter.
Definition: param_provider.hpp:9
mrs_lib
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition: attitude_converter.h:29
mrs_lib::ParamProvider
Helper class for ParamLoader.
Definition: param_provider.h:30