humoto
task_tagorient.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 Tag orientation
18  */
19  template <int t_features>
21  {
22  #define HUMOTO_CONFIG_ENTRIES \
23  HUMOTO_CONFIG_PARENT_CLASS(TaskAB) \
24  HUMOTO_CONFIG_SCALAR_(k_orientation_gain) \
25  HUMOTO_CONFIG_SCALAR_(tag_string_id) \
26  HUMOTO_CONFIG_COMPOUND_(reference_rpy)
27  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
28 
29 
30  protected:
32  std::string tag_string_id_;
33  etools::Vector3 reference_rpy_;
34 
36 
37 
38  protected:
39  virtual void setDefaults()
40  {
42  k_orientation_gain_ = 0.0;
43  }
44 
45 
46  /**
47  * @brief Log task.
48  *
49  * @param[in] logger logger
50  * @param[in] parent parent
51  * @param[in] name name
52  */
54  const LogEntryName &parent = LogEntryName(),
55  const std::string &name = "task") const
56  {
57  LogEntryName subname = parent; subname.add(name);
58  TaskAB::logTask(logger, subname, "");
59  logger.log(LogEntryName(subname).add("k_orientation_gain"), k_orientation_gain_);
60  logger.log(LogEntryName(subname).add("tag_string_id"), tag_string_id_);
61  logger.log(LogEntryName(subname).add("reference_rpy"), reference_rpy_);
62  }
63 
64 
65  public:
66  TaskTagOrientation( const std::string &tag_string_id = "",
67  const etools::Vector3 &reference_rpy = etools::Vector3::Zero(),
68  const double gain = 1.0,
69  const double k_orientation_gain = 1.0)
70  : TaskAB(std::string("TaskTagOrientation_") + tag_string_id, gain)
71  {
72  k_orientation_gain_ = k_orientation_gain;
73  tag_string_id_ = tag_string_id;
74  reference_rpy_ = reference_rpy;
75  }
76 
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  {
83  const Model<t_features> &model =
84  dynamic_cast <const Model<t_features> &>(model_base);
85 
86  if(!tag_)
87  {
88  tag_ = model.getLinkTag(tag_string_id_);
89  }
90 
91  Eigen::MatrixXd &A = getA();
92  Eigen::VectorXd &b = getB();
93 
94 
95  model.getTagOrientationJacobian(A, tag_);
96 
97  b.noalias() = k_orientation_gain_
99  model.getTagOrientation(tag_),
101  reference_rpy_,
103 
104  if(! isApproximatelyEqual(1.0, getGain()))
105  {
106  A*=getGain();
107  b*=getGain();
108  }
109  }
110  };
111  }//pepper
112 }//humoto
boost::shared_ptr< const TagLink > TagLinkPtr
Definition: tag.h:44
Abstract base class (for control problems)
#define HUMOTO_LOCAL
Definition: export_import.h:26
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
Definition: task.h:347
STL namespace.
#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
etools::Matrix3 getTagOrientation(const rbdl::TagLinkPtr tag) const
Get tag orientation.
Definition: model.h:464
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
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
rbdl::TagLinkPtr getLinkTag(const std::string &id) const
Get tag.
Definition: model.h:451
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.
TaskTagOrientation(const std::string &tag_string_id="", const etools::Vector3 &reference_rpy=etools::Vector3::Zero(), const double gain=1.0, const double k_orientation_gain=1.0)
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
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
void getTagOrientationJacobian(Eigen::MatrixXd &jacobian, const rbdl::TagLinkPtr tag) const
Get tag orientation Jacobian.
Definition: model.h:489