kinematics-dynamics
AsibotConfiguration.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __ASIBOT_CONFIGURATION_HPP__
4 #define __ASIBOT_CONFIGURATION_HPP__
5 
6 #include <vector>
7 #include <string>
8 
9 namespace roboticslab
10 {
11 
20 {
21 public:
23  using JointsIn = const std::vector<double> &;
24 
26  using JointsOut = std::vector<double> &;
27 
34  : _qMin(qMin), _qMax(qMax)
35  {}
36 
38  virtual ~AsibotConfiguration() = default;
39 
57  virtual bool configure(double q1, double q2u, double q2d, double q3, double q4u, double q4d, double q5);
58 
64  virtual bool findOptimalConfiguration(JointsIn qGuess) = 0;
65 
70  virtual void retrieveAngles(JointsOut q) const
71  {
72  optimalPose.retrieveAngles(q);
73  }
74 
75 protected:
79  struct Pose
80  {
82  enum orientation { FORWARD, REVERSED };
83 
85  enum elbow { UP, DOWN };
86 
88  Pose()
89  : _q1(0.0), _q2(0.0), _q3(0.0), _q4(0.0), _q5(0.0), valid(true), _orient(FORWARD), _elb(UP)
90  {}
91 
93  void storeAngles(double q1, double q2, double q3, double q4, double q5, orientation orient, elbow elb);
94 
96  bool checkJointsInLimits(JointsIn qMin, JointsIn qMax) const;
97 
99  void retrieveAngles(JointsOut q) const;
100 
102  std::string toString() const;
103 
104  double _q1, _q2, _q3, _q4, _q5;
105  bool valid;
106 
107  orientation _orient;
108  elbow _elb;
109  };
110 
111  JointsIn _qMin, _qMax;
112 
113  Pose optimalPose;
114 
115  Pose forwardElbowUp;
116  Pose forwardElbowDown;
117  Pose reversedElbowUp;
118  Pose reversedElbowDown;
119 };
120 
132 {
133 public:
140  : AsibotConfiguration(qMin, qMax)
141  {}
142 
143  bool findOptimalConfiguration(JointsIn qGuess) override;
144 
145 private:
147  std::vector<double> getDiffs(JointsIn qGuess, const Pose & pose);
148 };
149 
158 {
159 public:
164  virtual AsibotConfiguration * create() const = 0;
165  virtual ~AsibotConfigurationFactory() = default;
166 
167 protected:
174  : _qMin(qMin), _qMax(qMax)
175  {}
176 
177  AsibotConfiguration::JointsIn _qMin, _qMax;
178 };
179 
187 {
188 public:
195  : AsibotConfigurationFactory(qMin, qMax)
196  {}
197 
198  AsibotConfiguration * create() const override
199  {
201  }
202 };
203 
204 } // namespace roboticslab
205 
206 #endif // __ASIBOT_CONFIGURATION_HPP__
Base factory class for AsibotConfiguration.
Definition: AsibotConfiguration.hpp:158
AsibotConfigurationFactory(AsibotConfiguration::JointsIn qMin, AsibotConfiguration::JointsIn qMax)
Constructor.
Definition: AsibotConfiguration.hpp:173
virtual AsibotConfiguration * create() const =0
Creates an instance of the concrete class.
Implementation factory class for AsibotConfigurationLeastOverallAngularDisplacement.
Definition: AsibotConfiguration.hpp:187
AsibotConfiguration * create() const override
Creates an instance of the concrete class.
Definition: AsibotConfiguration.hpp:198
AsibotConfigurationLeastOverallAngularDisplacementFactory(AsibotConfiguration::JointsIn qMin, AsibotConfiguration::JointsIn qMax)
Constructor.
Definition: AsibotConfiguration.hpp:194
IK solver configuration strategy selector based on the overall angle displacement of all joints.
Definition: AsibotConfiguration.hpp:132
std::vector< double > getDiffs(JointsIn qGuess, const Pose &pose)
Obtains vector of differences between current and desired joint angles [deg].
Definition: AsibotConfigurationLeastOverallAngularDisplacement.cpp:85
AsibotConfigurationLeastOverallAngularDisplacement(JointsIn qMin, JointsIn qMax)
Constructor.
Definition: AsibotConfiguration.hpp:139
bool findOptimalConfiguration(JointsIn qGuess) override
Analyzes available configurations and selects the optimal one.
Definition: AsibotConfigurationLeastOverallAngularDisplacement.cpp:16
Abstract base class for a robot configuration strategy selector.
Definition: AsibotConfiguration.hpp:20
virtual ~AsibotConfiguration()=default
Destructor.
virtual bool findOptimalConfiguration(JointsIn qGuess)=0
Analyzes available configurations and selects the optimal one.
AsibotConfiguration(JointsIn qMin, JointsIn qMax)
Constructor.
Definition: AsibotConfiguration.hpp:33
virtual bool configure(double q1, double q2u, double q2d, double q3, double q4u, double q4d, double q5)
Stores initial values for a specific pose.
Definition: AsibotConfiguration.cpp:47
virtual void retrieveAngles(JointsOut q) const
Queries computed angles for the optimal configuration.
Definition: AsibotConfiguration.hpp:70
const std::vector< double > & JointsIn
Const vector of joint angles (input parameter).
Definition: AsibotConfiguration.hpp:23
std::vector< double > & JointsOut
Vector of joint angles (output parameter).
Definition: AsibotConfiguration.hpp:26
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6
Helper class to store a specific robot configuration.
Definition: AsibotConfiguration.hpp:80
void retrieveAngles(JointsOut q) const
Returns stored angles.
Definition: AsibotConfiguration.cpp:126
bool checkJointsInLimits(JointsIn qMin, JointsIn qMax) const
Checks whether current configuration is reachable.
Definition: AsibotConfiguration.cpp:107
void storeAngles(double q1, double q2, double q3, double q4, double q5, orientation orient, elbow elb)
Initializes angle values (in degrees).
Definition: AsibotConfiguration.cpp:95
orientation
Orientation of axis 1 ('forward' or 180ยบ offset).
Definition: AsibotConfiguration.hpp:82
Pose()
Constructor.
Definition: AsibotConfiguration.hpp:88
elbow
Orientation of axes 2-3 (elbow up/down).
Definition: AsibotConfiguration.hpp:85
std::string toString() const
Serializes stored data.
Definition: AsibotConfiguration.cpp:131