humoto
task_baseorient.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 base orientation
18  */
20  {
21  #define HUMOTO_CONFIG_ENTRIES \
22  HUMOTO_CONFIG_PARENT_CLASS(TaskAB) \
23  HUMOTO_CONFIG_SCALAR_(k_orientation_gain)
24  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
25 
26 
27  protected:
29 
30 
31  protected:
32  TaskBaseOrientationBase(const std::string & id,
33  const double gain,
34  const double k_orientation_gain) : TaskAB(id, gain)
35  {
36  k_orientation_gain_ = k_orientation_gain;
37  }
38 
39 
40  virtual void setDefaults()
41  {
43  k_orientation_gain_ = 0.0;
44  }
45 
46 
47  /**
48  * @brief Log task.
49  *
50  * @param[in] logger logger
51  * @param[in] parent parent
52  * @param[in] name name
53  */
55  const LogEntryName &parent = LogEntryName(),
56  const std::string &name = "task") const
57  {
58  LogEntryName subname = parent; subname.add(name);
59  TaskAB::logTask(logger, subname, "");
60  logger.log(LogEntryName(subname).add("k_orientation_gain"), k_orientation_gain_);
61  }
62  };
63 
64 
65 
66  /**
67  * @brief base orientation
68  */
69  template <int t_features>
71  {
72  public:
73  TaskBaseOrientation(const double gain = 1.0,
74  const double k_orientation_gain = 1.0) : TaskBaseOrientationBase( "TaskBaseOrientation",
75  gain,
76  k_orientation_gain) {}
77 
78  /// @copydoc humoto::TaskBase::form
79  void form( const humoto::SolutionStructure &sol_structure,
80  const humoto::Model &model_base,
81  const humoto::ControlProblem &control_problem)
82  {
84  dynamic_cast <const WholeBodyController<t_features> &>(control_problem);
85 
86  const Model<t_features> &model =
87  dynamic_cast <const Model<t_features> &>(model_base);
88 
89 
90  Eigen::MatrixXd &A = getA();
91  Eigen::VectorXd &b = getB();
92 
93  model.getBaseOrientationJacobian(A);
94 
95  b.noalias() = k_orientation_gain_
97  model.getBaseOrientation(),
101 
102  if(! isApproximatelyEqual(1.0, getGain()))
103  {
104  A*=getGain();
105  b*=getGain();
106  }
107  }
108  };
109 
110 
111  /**
112  * @brief base orientation
113  */
114 #ifdef HUMOTO_DOXYGEN_PROCESSING
115  template<>
116  class HUMOTO_LOCAL TaskBaseOrientation<FIXED_WHEELS | ROOT_PLANAR>
117  : public TaskBaseOrientationBase
118 #else
119  // Doxygen chokes on this for some reason
120  template<>
121  class HUMOTO_LOCAL TaskBaseOrientation<ModelFeatures::FIXED_WHEELS | ModelFeatures::ROOT_PLANAR>
122  : public TaskBaseOrientationBase
123 #endif
124  {
125  public:
126  TaskBaseOrientation(const double gain = 1.0,
127  const double k_orientation_gain = 1.0) : TaskBaseOrientationBase( "TaskBaseOrientation",
128  gain,
129  k_orientation_gain) {}
130 
131  /// @copydoc humoto::TaskBase::form
132  void form( const humoto::SolutionStructure &sol_structure,
133  const humoto::Model &model_base,
134  const humoto::ControlProblem &control_problem)
135  {
138 
140  dynamic_cast <const Model<ModelFeatures::FIXED_WHEELS | ModelFeatures::ROOT_PLANAR> &>(model_base);
141 
142 
143  Eigen::MatrixXd &A = getA();
144  Eigen::VectorXd &b = getB();
145 
146  Eigen::MatrixXd J;
147  model.getBaseOrientationJacobian(J);
148  A = J.bottomRows(1);
149 
150  b.resize(1);
151  b(0) = k_orientation_gain_
152  *
154  model.getBaseOrientation(),
158 
159  if(! isApproximatelyEqual(1.0, getGain()))
160  {
161  A*=getGain();
162  b*=getGain();
163  }
164  }
165  };
166  }//pepper
167 }//humoto
Abstract base class (for control problems)
#define HUMOTO_LOCAL
Definition: export_import.h:26
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
TaskBaseOrientation(const double gain=1.0, const double k_orientation_gain=1.0)
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
Definition: task.h:347
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
Definition: logger.h:997
Analog of &#39;sol_structure&#39; struct in Octave code. [determine_solution_structure.m].
Definition: solution.h:33
virtual void setDefaults()
Set members to their default values.
Definition: task.h:332
Represents log entry name.
Definition: logger.h:169
TaskBaseOrientation(const double gain=1.0, const double k_orientation_gain=1.0)
etools::Vector3 getRotationErrorAngleAxis(const etools::Matrix3 &current, const etools::Matrix3 &reference)
Definition: rotary_state.h:123
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
Definition: logger.h:555
The root namespace of HuMoTo.
Definition: config.h:12
humoto::pepper_ik::MotionParameters motion_parameters_
TaskBaseOrientationBase(const std::string &id, const double gain, const double k_orientation_gain)
Instances of this class are passed to a virtual method &#39;humoto::TaskBase::form()&#39;, so even though this class is basically useless in its present form we cannot avoid its definition using a template.
Definition: model.h:41
virtual void setDefaults()
Set members to their default values.
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
LogEntryName & add(const char *name)
extends entry name with a subname
Definition: logger.h:232
bool isApproximatelyEqual(const double var1, const double var2, const double tol=humoto::g_generic_tolerance)
Returns true if the difference between two given variables is below the given tolerance.
Definition: utility.h:87
Task: A*x = b.
Definition: task.h:542
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
etools::Matrix3 convertEulerAnglesToMatrix(const etools::Vector3 &euler_angles, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
Definition: rotary_state.h:71
etools::Vector3 base_orientation_rpy_
Definition: common.h:93