humoto
generalized_coordinates.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
5  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
6 
7  @brief
8 */
9 
10 #pragma once
11 
12 namespace humoto
13 {
14  namespace pepper_ik
15  {
16  /**
17  * @brief State of the model
18  *
19  * @tparam t_features features which identify model
20  */
21  template <int t_features>
23  {
24  #define HUMOTO_CONFIG_SECTION_ID "GeneralizedCoordinates"
25  #define HUMOTO_CONFIG_CONSTRUCTOR GeneralizedCoordinates
26  #define HUMOTO_CONFIG_ENTRIES \
27  HUMOTO_CONFIG_COMPOUND_(root_pose)\
28  HUMOTO_CONFIG_COMPOUND_(joint_angles)
29  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
30 
31 
32  protected:
33  /**
34  * @brief Default configuration
35  */
36  void setDefaults()
37  {
38  ModelDescription<t_features>::getDefaultGeneralizedCoordinates(joint_angles_, root_pose_);
39  }
40 
41 
42  /**
43  * @brief Check length of the vector of joint angles after
44  * reading it from a configuration file.
45  */
46  void finalize()
47  {
48  HUMOTO_ASSERT( ModelDescription<t_features>::JOINTS_DOF_NUMBER == joint_angles_.rows(),
49  "Wrong size of the vector of joint angles.");
50  }
51 
52 
53  public:
54  EIGENTOOLS_CONSTANT_SIZE_VECTOR(ModelDescription<t_features>::ROOT_DOF_NUMBER) root_pose_;
55  EIGENTOOLS_CONSTANT_SIZE_VECTOR(ModelDescription<t_features>::JOINTS_DOF_NUMBER) joint_angles_;
56 
57 
58  public:
59  /**
60  * @brief Default constructor
61  */
63  {
64  setDefaults();
65  }
66 
67 
68  /**
69  * @brief Set position of the root
70  *
71  * @param[in] position
72  */
73  void setRootPosition(const etools::Vector3 & position)
74  {
75  ModelDescription<t_features>::setRootPosition(root_pose_, position);
76  }
77 
78 
79  /**
80  * @brief Set orientation of the root
81  *
82  * @param[in] rpy
83  */
84  void setRootOrientation(const etools::Vector3 & rpy)
85  {
86  ModelDescription<t_features>::setRootOrientation(root_pose_, rpy);
87  }
88 
89 
90  /**
91  * @brief Get position of the root
92  *
93  * @param[out] position
94  */
95  void getRootPosition(etools::Vector3 & position) const
96  {
97  ModelDescription<t_features>::getRootPosition(position, root_pose_);
98  }
99 
100 
101  /**
102  * @brief Get orientation of the root
103  *
104  * @param[out] rpy
105  */
106  void getRootOrientation(etools::Vector3 & rpy) const
107  {
108  ModelDescription<t_features>::getRootOrientation(rpy, root_pose_);
109  }
110 
111 
112 
113  /**
114  * @brief Returns generalized coordinates as a single vector
115  * [root_pose; joint_angles].
116  *
117  * @return generalized coordinates.
118  */
119  EIGENTOOLS_CONSTANT_SIZE_VECTOR(ModelDescription<t_features>::DOF_NUMBER)
120  asVector() const
121  {
122  Eigen::Matrix<double, ModelDescription<t_features>::DOF_NUMBER, 1> generalized_coordinates;
123  generalized_coordinates << root_pose_, joint_angles_;
124  return (generalized_coordinates);
125  }
126 
127 
128  /**
129  * @brief Log
130  *
131  * @param[in,out] logger logger
132  * @param[in] parent parent
133  * @param[in] name name
134  */
136  const LogEntryName &parent = LogEntryName(),
137  const std::string &name = "model_state") const
138  {
139  logger.log(LogEntryName(parent).add(name).add("root_pose"), root_pose_);
140  logger.log(LogEntryName(parent).add(name).add("joint_angles"), joint_angles_);
141  }
142  };
143  }
144 }
void getRootPosition(etools::Vector3 &position) const
Get position of the root.
#define HUMOTO_LOCAL
Definition: export_import.h:26
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
Definition: logger.h:997
#define HUMOTO_ASSERT(condition, message)
Default configurable base is strict.
Definition: config.h:353
void getRootOrientation(etools::Vector3 &rpy) const
Get orientation of the root.
Represents log entry name.
Definition: logger.h:169
void setRootPosition(const etools::Vector3 &position)
Set position of the root.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
Definition: logger.h:555
void finalize()
Check length of the vector of joint angles after reading it from a configuration file.
The root namespace of HuMoTo.
Definition: config.h:12
Abstract class to be used for interfaces.
Definition: model.h:18
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="model_state") const
Log.
#define EIGENTOOLS_CONSTANT_SIZE_VECTOR(rows)
Definition: eigentools.h:58
void setRootOrientation(const etools::Vector3 &rpy)
Set orientation of the root.