humoto
task_tagpose3dof.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Jan Michalczyk
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 pose with 3dofs (around x axis, around y axis, along z axis)
18  * This task is used when moving the base using visual servoing
19  *
20  */
21  template <int t_features>
23  {
24  protected:
25  double k_pose_gain_;
26  std::string tag_string_id_;
27 
29 
30 
31  protected:
32  #define HUMOTO_CONFIG_ENTRIES \
33  HUMOTO_CONFIG_PARENT_CLASS(TaskAB) \
34  HUMOTO_CONFIG_SCALAR_(k_pose_gain) \
35  HUMOTO_CONFIG_SCALAR_(tag_string_id)
36  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
37 
38 
39  virtual void setDefaults()
40  {
42  k_pose_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_pose_gain"), k_pose_gain_);
60  logger.log(LogEntryName(subname).add("tag_string_id"), tag_string_id_);
61  }
62 
63 
64  public:
65  TaskTagPose3Dof(const std::string& tag_string_id = "",
66  const double gain = 1.0,
67  const double k_pose_gain = 1.0)
68  : TaskAB(std::string("TaskTagPose3Dof_") + tag_string_id, gain)
69  {
70  k_pose_gain_ = k_pose_gain;
71  tag_string_id_ = tag_string_id;
72  }
73 
74 
75  /// @copydoc humoto::TaskBase::form
76  void form(const humoto::SolutionStructure &sol_structure,
77  const humoto::Model &model_base,
78  const humoto::ControlProblem &control_problem)
79  {
80  const Model<t_features>& model =
81  dynamic_cast <const Model<t_features>& >(model_base);
82 
83  const WholeBodyController<t_features>& wb_controller =
84  dynamic_cast <const WholeBodyController<t_features>& >(control_problem);
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  model.getTagCompleteJacobian(A, tag_);
95 
96  b.noalias() = k_pose_gain_ * wb_controller.getTagPoseErrorInGlobal(model, tag_string_id_);
97  b.segment(2, 3) *= 0.0;
98 
99  if(!isApproximatelyEqual(1.0, getGain()))
100  {
101  A*=getGain();
102  b*=getGain();
103  }
104  }
105  };
106  }//pepper
107 }//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
Tag pose with 3dofs (around x axis, around y axis, along z axis) This task is used when moving the ba...
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
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
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
virtual void setDefaults()
Set members to their default values.
void getTagCompleteJacobian(Eigen::MatrixXd &jacobian, const rbdl::TagLinkPtr tag) const
Get tag complete Jacobian.
Definition: model.h:502
TaskTagPose3Dof(const std::string &tag_string_id="", const double gain=1.0, const double k_pose_gain=1.0)
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
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.