HEBI C++ API  3.9.0
group_info.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "hebi.h"
4 
5 #include <memory>
6 #include <vector>
7 
8 #include "Eigen/Eigen"
10 #include "info.hpp"
11 
12 namespace hebi {
13 
18 class GroupInfo final {
19 public:
20 #ifndef DOXYGEN_OMIT_INTERNAL
21 
25  std::shared_ptr<GroupInfoWrapper> internal_;
26 #endif // DOXYGEN_OMIT_INTERNAL
27 
28 private:
32  const size_t number_of_modules_;
36  std::vector<Info> infos_;
37 
41  const bool is_subview_{};
42 
46  GroupInfo(std::shared_ptr<GroupInfoWrapper>, std::vector<int> indices);
47 
48 public:
52  GroupInfo(size_t number_of_modules);
53 
57  ~GroupInfo() noexcept = default;
58 
62  GroupInfo(GroupInfo&&) = default;
63 
74  GroupInfo subview(std::vector<int> indices) const;
75 
79  bool isSubview() const { return is_subview_; }
80 
84  size_t size() const;
85 
89  const Info& operator[](size_t index) const;
90 
95  bool writeGains(const std::string& file) const;
96 
101  FunctionCallResult writeSafetyParameters(const std::string& file) const {
102  if (is_subview_)
103  return FunctionCallResult{false, "Cannot call this method on a subview!"};
104  auto res = hebiGroupInfoWriteSafetyParameters(internal_->internal_, file.c_str()) == HebiStatusSuccess;
105  if (res) {
106  return FunctionCallResult{true};
107  }
108  return FunctionCallResult{false, std::string{hebiSafetyParametersGetLastError()}};
109  }
110 
114  Eigen::VectorXd getSpringConstant() const;
115 
119  void getSpringConstant(Eigen::VectorXd& out) const;
120 };
121 
122 } // namespace hebi
A list of Info objects that can be received from a Group of modules; the size() must match the number...
Definition: group_info.hpp:18
FunctionCallResult writeSafetyParameters(const std::string &file) const
Export the safety parameters from this GroupInfo object into a file, creating it as necessary.
Definition: group_info.hpp:101
Definition: arm.cpp:8
~GroupInfo() noexcept=default
Destructor cleans up group info object as necessary.
Info objects have various fields representing the module state; which fields are populated depends on...
Definition: info.hpp:34
bool writeGains(const std::string &file) const
Export the gains from this GroupInfo object into a file, creating it as necessary.
Definition: group_info.cpp:29
const Info & operator[](size_t index) const
Access the info for an individual module.
Definition: group_info.cpp:27
bool isSubview() const
Was this created as a subview of another GroupInfo?
Definition: group_info.hpp:79
Used as a return.
Definition: util.hpp:28
size_t size() const
Returns the number of module infos in this group info.
Definition: group_info.cpp:25
GroupInfo subview(std::vector< int > indices) const
Creates a "subview" of this group info object, with shared access to a subset of the Info elements....
Definition: group_info.cpp:17
Eigen::VectorXd getSpringConstant() const
Convenience function for returning spring constant values.
Definition: group_info.cpp:35