humoto
task_jointsref.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 maintain reference joint angles
18  */
19  template <int t_features>
21  {
22  #define HUMOTO_CONFIG_ENTRIES \
23  HUMOTO_CONFIG_PARENT_CLASS(TaskGIB) \
24  HUMOTO_CONFIG_SCALAR_(k_position_gain) \
25  HUMOTO_CONFIG_COMPOUND_(joint_angles_reference)
26  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
27 
28 
29  private:
31  EIGENTOOLS_CONSTANT_SIZE_VECTOR(ModelDescription<t_features>::JOINTS_DOF_NUMBER) joint_angles_reference_;
32 
33 
34  protected:
35  virtual void setDefaults()
36  {
38  k_position_gain_ = 0.0;
39  ModelDescription<t_features>::getDefaultJointAngles(joint_angles_reference_);
40  }
41 
42 
43  /**
44  * @brief Log task.
45  *
46  * @param[in] logger logger
47  * @param[in] parent parent
48  * @param[in] name name
49  */
51  const LogEntryName &parent = LogEntryName(),
52  const std::string &name = "task") const
53  {
54  LogEntryName subname = parent; subname.add(name);
55  TaskGIB::logTask(logger, subname, "");
56 
57  logger.log(LogEntryName(subname).add("k_position_gain"), k_position_gain_);
58  logger.log(LogEntryName(subname).add("joint_angles_reference"), joint_angles_reference_);
59  }
60 
61 
62  public:
63  TaskJointsReference(const double gain = 1.0,
64  const double k_position_gain = 1.0) : TaskGIB("TaskJointsReference", gain)
65  {
66  k_position_gain_ = k_position_gain;
67 
68  ModelDescription<t_features>::getDefaultJointAngles(joint_angles_reference_);
69  }
70 
71 
72  /// @copydoc humoto::TaskBase::form
73  void form( const humoto::SolutionStructure &sol_structure,
74  const humoto::Model &model_base,
75  const humoto::ControlProblem &control_problem)
76  {
78  dynamic_cast <const humoto::pepper_ik::Model<t_features> &>(model_base);
79 
81 
82  humoto::IndexVector &I = getIndices();
83  Eigen::VectorXd &b = getB();
84  Eigen::VectorXd &gains = getIGains();
85 
86  I.resize(loc_var.length_);
87  b.resize(loc_var.length_);
88  gains.setConstant(loc_var.length_, getGain());
89 
90  for (std::size_t i = 0; i < loc_var.length_; ++i)
91  {
92  I[i] = loc_var.offset_ + i;
93  }
94 
95  b.noalias() = k_position_gain_*getGain()*(joint_angles_reference_ - model.getState().joint_angles_);
96  }
97  };
98  } //pepper
99 } //humoto
Abstract base class (for control problems)
static const char * JOINTS_VARIABLES_ID
Joint angles.
Definition: common.h:19
#define HUMOTO_LOCAL
Definition: export_import.h:26
#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.
Represents log entry name.
Definition: logger.h:169
Eigen::Matrix< unsigned int, Eigen::Dynamic, 1 > IndexVector
Definition: utility.h:19
void form(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Form the task.
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
Definition: task.h:438
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
Definition: logger.h:555
Location getSolutionPartLocation(const std::string &id) const
Get location of a data in the solution vector.
Definition: solution.h:122
The root namespace of HuMoTo.
Definition: config.h:12
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
const GeneralizedCoordinates< t_features > & getState() const
Return current model state.
Definition: model.h:733
virtual void setDefaults()
Set members to their default values.
Definition: task.h:424
maintain reference joint angles
TaskJointsReference(const double gain=1.0, const double k_position_gain=1.0)
LogEntryName & add(const char *name)
extends entry name with a subname
Definition: logger.h:232
Location of a data chunk (offset + length).
Definition: utility.h:146
#define EIGENTOOLS_CONSTANT_SIZE_VECTOR(rows)
Definition: eigentools.h:58
Task: diag(G)*x[I] = b.
Definition: task.h:566