HEBI C++ API  3.8.0
robot_config.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 #include "arm/plugin_config.hpp"
9 
10 namespace hebi {
11 
12 // A wrapper for loading robot configurations. (See https://github.com/HebiRobotics/robot-config)
13 class RobotConfig {
14 public:
15  // Reads the robot config from the given file. This reads all included
16  // parameters/references, and verifies that all referenced paths exist and
17  // load properly.
18  //
19  // Any errors when loading are added to the passed in vector. For non-fatal
20  // errors, an object may still be returned.
21  static std::unique_ptr<RobotConfig> loadConfig(std::string filepath, std::vector<std::string>& errors);
22 
24 
25  // Return names (required)
26  const std::vector<std::string>& getNames() const { return names_; }
27  // Return families (required)
28  const std::vector<std::string>& getFamilies() const { return families_; }
29  // Return HRDF absolute file path (optional)
30  const std::string& getHrdf() const { return hrdf_; }
31  // Return gain for specific key
32  std::string getGains(const std::string& key) const { return gains_.count(key) == 0 ? "" : gains_.at(key); }
33  // Return all gains (absolute paths; may be empty)
34  const std::map<std::string, std::string>& getGains() { return gains_; }
35  // Get ordered list of plugin parameters
36  const std::vector<experimental::arm::PluginConfig>& getPluginConfigs() const { return plugin_configs_; }
37 
38  // Any listed string keys
39  const std::map<std::string, std::string>& getUserData() { return user_data_; }
40 
41 private:
42  RobotConfig() = default;
43 
44  std::vector<std::string> names_;
45  std::vector<std::string> families_;
46  // Stored as an absolute path for reading later
47  std::string hrdf_;
48  // Stored as absolute paths for reading later
49  std::map<std::string, std::string> gains_;
50  // plugins
51  std::vector<experimental::arm::PluginConfig> plugin_configs_;
52 
53  std::map<std::string, std::string> user_data_;
54 };
55 
56 } // namespace hebi
Definition: arm.cpp:8
const std::vector< std::string > & getFamilies() const
Definition: robot_config.hpp:28
const std::vector< experimental::arm::PluginConfig > & getPluginConfigs() const
Definition: robot_config.hpp:36
static std::unique_ptr< RobotConfig > loadConfig(std::string filepath, std::vector< std::string > &errors)
Definition: robot_config.cpp:41
std::string getGains(const std::string &key) const
Definition: robot_config.hpp:32
const std::map< std::string, std::string > & getGains()
Definition: robot_config.hpp:34
const std::map< std::string, std::string > & getUserData()
Definition: robot_config.hpp:39
Definition: robot_config.hpp:13
const std::string & getHrdf() const
Definition: robot_config.hpp:30
const std::vector< std::string > & getNames() const
Definition: robot_config.hpp:26