group_info.cpp
Go to the documentation of this file.
1 #include "group_info.hpp"
2 
3 namespace hebi {
4 
5 GroupInfo::GroupInfo(size_t number_of_modules)
6  : internal_(hebiGroupInfoCreate(number_of_modules)),
7  number_of_modules_(number_of_modules)
8 {
9  for (size_t i = 0; i < number_of_modules_; i++)
11 }
12 
14 {
15  if (internal_ != nullptr)
17 }
18 
19 size_t GroupInfo::size() const
20 {
21  return number_of_modules_;
22 }
23 
24 const Info& GroupInfo::operator[](size_t index) const
25 {
26  return infos_[index];
27 }
28 
29 bool GroupInfo::writeGains(const std::string& file) const
30 {
31  return hebiGroupInfoWriteGains(internal_, file.c_str()) == HebiStatusSuccess;
32 }
33 
34 Eigen::VectorXd GroupInfo::getSpringConstant() const
35 {
36  Eigen::VectorXd res(number_of_modules_);
37  for (size_t i = 0; i < number_of_modules_; ++i)
38  {
39  auto& info = infos_[i].settings().actuator().springConstant();
40  res[i] = (info) ? info.get() : std::numeric_limits<float>::quiet_NaN();
41  }
42  return res;
43 }
44 
45 void GroupInfo::getSpringConstant(Eigen::VectorXd& out) const
46 {
47  if (out.size() != number_of_modules_)
48  {
49  out.resize(number_of_modules_);
50  }
51 
52  for (size_t i = 0; i < number_of_modules_; ++i)
53  {
54  auto& info = infos_[i].settings().actuator().springConstant();
55  out[i] = (info) ? info.get() : std::numeric_limits<float>::quiet_NaN();
56  }
57 }
58 
59 } // namespace hebi
size_t size() const
Returns the number of module infos in this group info.
Definition: group_info.cpp:19
Definition: color.hpp:5
Info objects have various fields representing the module state; which fields are populated depends on...
Definition: info.hpp:30
void hebiGroupInfoRelease(HebiGroupInfoPtr info)
Frees resources created by the GroupInfo object.
HebiStatusCode hebiGroupInfoWriteGains(HebiGroupInfoPtr info, const char *file)
Export gains from a GroupInfo object into a file.
HebiGroupInfoPtr hebiGroupInfoCreate(size_t size)
Creates a GroupInfo for a group with the specified number of modules.
const Info & operator[](size_t index) const
Access the info for an individual module.
Definition: group_info.cpp:24
GroupInfo(size_t number_of_modules)
Create a group info with the specified number of modules.
Definition: group_info.cpp:5
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
Eigen::VectorXd getSpringConstant() const
Convenience function for returning spring constant values.
Definition: group_info.cpp:34
~GroupInfo() noexcept
Destructor cleans up group info object as necessary.
Definition: group_info.cpp:13
std::vector< Info > infos_
Definition: group_info.hpp:33
HebiInfoPtr hebiGroupInfoGetModuleInfo(HebiGroupInfoPtr info, size_t module_index)
Get an individual info for a particular module at index module_index.
HebiGroupInfoPtr internal_
Definition: group_info.hpp:22
const size_t number_of_modules_
Definition: group_info.hpp:29


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:14