robotis_manipulator_common.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2018 ROBOTIS CO., LTD.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 
17 /* Authors: Darby Lim, Hye-Jong KIM, Ryan Shim, Yong-Ho Na */
18 
19 #ifndef ROBOTIS_MANIPULATOR_COMMON_H
20 #define ROBOTIS_MANIPULATOR_COMMON_H
21 
22 #include <unistd.h>
23 #if defined(__OPENCR__)
24  #include <Eigen.h> // Calls main Eigen matrix class library
25  #include <Eigen/LU> // Calls inverse, determinant, LU decomp., etc.
26  #include <WString.h>
27 #else
28  #include <eigen3/Eigen/Eigen>
29  #include <eigen3/Eigen/LU>
30 #endif
31 #include <math.h>
32 #include <vector>
33 //#include <map>
34 #include <map>
37 
38 namespace robotis_manipulator
39 {
40 
41 typedef STRING Name;
42 
43 
44 /*****************************************************************************
45 ** Value Set
46 *****************************************************************************/
47 typedef struct _KinematicPose
48 {
49  Eigen::Vector3d position;
50  Eigen::Matrix3d orientation;
52 
53 typedef struct _Dynamicvector
54 {
55  Eigen::Vector3d velocity;
56  Eigen::Vector3d acceleration;
58 
59 typedef struct _DynamicPose
60 {
63 } DynamicPose;
64 
65 typedef struct _Inertia
66 {
67  double mass;
68  Eigen::Matrix3d inertia_tensor;
69  Eigen::Vector3d center_of_mass;
70 } Inertia;
71 
72 typedef struct _Limit
73 {
74  double maximum;
75  double minimum;
76 } Limit;
77 
78 
79 /*****************************************************************************
80 ** Time Set
81 *****************************************************************************/
82 typedef struct _Time
83 {
85  double present_time;
86  double start_time;
87 } Time;
88 
89 
90 /*****************************************************************************
91 ** Trajectory Set
92 *****************************************************************************/
93 typedef enum _TrajectoryType
94 {
95  NONE = 0,
101 
102 typedef struct _Point
103 {
104  double position;
105  double velocity;
106  double acceleration;
107  double effort; //Torque
109 
110 typedef std::vector<JointValue> JointWaypoint;
111 
112 bool setEffortToValue(std::vector<JointValue> *value, std::vector<double> effort);
113 bool setPositionToValue(std::vector<JointValue> *value, std::vector<double> position);
114 
115 typedef struct _TaskWaypoint
116 {
119 } TaskWaypoint, Pose;
120 
121 /*****************************************************************************
122 ** Component Set
123 *****************************************************************************/
124 typedef enum _ComponentType
125 {
129 } ComponentType;
130 
131 typedef struct _ChainingName
132 {
133  Name parent;
134  std::vector<Name> child;
135 } ChainingName;
136 
137 typedef struct _Relative
138 {
141 } Relative;
142 
143 typedef struct _JointConstant
144 {
145  int8_t id;
146  Eigen::Vector3d axis;
147  double coefficient; // joint angle over actuator angle
149  double torque_coefficient; // torque over current
150 } JointConstant;
151 
152 typedef struct _World
153 {
154  Name name;
155  Name child;
156  Pose pose;
157 } World;
158 
159 typedef struct _Component
160 {
161  //constant
163  ComponentType component_type;
166 
167  //variable
169  JointValue joint_value;
170 
171  //Actuator
173 } Component;
174 
175 /*****************************************************************************
176 ** External environment parameter Set
177 *****************************************************************************/
178 
179 typedef struct _Object
180 {
181  Name tool_name;
183 }Object;
184 
185 typedef struct _Force
186 {
187  double x;
188  double y;
189  double z;
190 }Force;
191 
192 typedef struct _Moment
193 {
194  double x;
195  double y;
196  double z;
197 }Moment;
198 
199 
200 /*****************************************************************************
201 ** Manipulator Class
202 *****************************************************************************/
204 {
205 private:
206  int8_t dof_;
208  std::map<Name, Component> component_;
209 
210 public:
211  Manipulator();
213 
214  /*****************************************************************************
215  ** Add Function
216  *****************************************************************************/
217  void addWorld(Name world_name,
218  Name child_name,
219  Eigen::Vector3d world_position = Eigen::Vector3d::Zero(),
220  Eigen::Matrix3d world_orientation = Eigen::Matrix3d::Identity());
221 
222  void addJoint(Name my_name,
223  Name parent_name,
224  Name child_name,
225  Eigen::Vector3d relative_position,
226  Eigen::Matrix3d relative_orientation,
227  Eigen::Vector3d axis_of_rotation = Eigen::Vector3d::Zero(),
228  int8_t joint_actuator_id = -1,
229  double max_position_limit = M_PI,
230  double min_position_limit = -M_PI,
231  double coefficient = 1.0,
232  double mass = 0.0,
233  Eigen::Matrix3d inertia_tensor = Eigen::Matrix3d::Identity(),
234  Eigen::Vector3d center_of_mass = Eigen::Vector3d::Zero(),
235  double torque_coefficient = 1.0);
236 
237  void addTool(Name my_name,
238  Name parent_name,
239  Eigen::Vector3d relative_position,
240  Eigen::Matrix3d relative_orientation,
241  int8_t tool_id = -1,
242  double max_position_limit = M_PI,
243  double min_position_limit = -M_PI,
244  double coefficient = 1.0,
245  double mass = 0.0,
246  Eigen::Matrix3d inertia_tensor = Eigen::Matrix3d::Identity(),
247  Eigen::Vector3d center_of_mass = Eigen::Vector3d::Zero(),
248  double torque_coefficient = 1.0);
249 
250  void addComponentChild(Name my_name, Name child_name);
251  void printManipulatorSetting();
252 
253 
254  /*****************************************************************************
255  ** Set Function
256  *****************************************************************************/
257  void setTorqueCoefficient(Name component_name, double torque_coefficient);
258 
259  void setWorldPose(Pose world_pose);
260  void setWorldKinematicPose(KinematicPose world_kinematic_pose);
261  void setWorldPosition(Eigen::Vector3d world_position);
262  void setWorldOrientation(Eigen::Matrix3d world_orientation);
263  void setWorldDynamicPose(DynamicPose world_dynamic_pose);
264  void setWorldLinearVelocity(Eigen::Vector3d world_linear_velocity);
265  void setWorldAngularVelocity(Eigen::Vector3d world_angular_velocity);
266  void setWorldLinearAcceleration(Eigen::Vector3d world_linear_acceleration);
267  void setWorldAngularAcceleration(Eigen::Vector3d world_angular_acceleration);
268  void setComponent(Name component_name, Component component);
269  void setComponentActuatorName(Name component_name, Name actuator_name);
270  void setComponentPoseFromWorld(Name component_name, Pose pose_to_world);
271  void setComponentKinematicPoseFromWorld(Name component_name, KinematicPose pose_to_world);
272  void setComponentPositionFromWorld(Name component_name, Eigen::Vector3d position_to_world);
273  void setComponentOrientationFromWorld(Name component_name, Eigen::Matrix3d orientation_to_wolrd);
274  void setComponentDynamicPoseFromWorld(Name component_name, DynamicPose dynamic_pose);
275 
276  void setJointPosition(Name name, double position);
277  void setJointVelocity(Name name, double velocity);
278  void setJointAcceleration(Name name, double acceleration);
279  void setJointEffort(Name name, double effort);
280  void setJointValue(Name name, JointValue joint_value);
281 
282  void setAllActiveJointPosition(std::vector<double> joint_position_vector);
283  void setAllActiveJointValue(std::vector<JointValue> joint_value_vector);
284  void setAllJointPosition(std::vector<double> joint_position_vector);
285  void setAllJointValue(std::vector<JointValue> joint_value_vector);
286  void setAllToolPosition(std::vector<double> tool_position_vector);
287  void setAllToolValue(std::vector<JointValue> tool_value_vector);
288 
289 
290  /*****************************************************************************
291  ** Get Function
292  *****************************************************************************/
293  int8_t getDOF();
294  Name getWorldName();
295  Name getWorldChildName();
296  Pose getWorldPose();
297  KinematicPose getWorldKinematicPose();
298  Eigen::Vector3d getWorldPosition();
299  Eigen::Matrix3d getWorldOrientation();
300  DynamicPose getWorldDynamicPose();
301  int8_t getComponentSize();
302  std::map<Name, Component> getAllComponent();
303  std::map<Name, Component>::iterator getIteratorBegin();
304  std::map<Name, Component>::iterator getIteratorEnd();
305  Component getComponent(Name component_name);
306  Name getComponentActuatorName(Name component_name);
307  Name getComponentParentName(Name component_name);
308  std::vector<Name> getComponentChildName(Name component_name);
309  Pose getComponentPoseFromWorld(Name component_name);
310  KinematicPose getComponentKinematicPoseFromWorld(Name component_name);
311  Eigen::Vector3d getComponentPositionFromWorld(Name component_name);
312  Eigen::Matrix3d getComponentOrientationFromWorld(Name component_name);
313  DynamicPose getComponentDynamicPoseFromWorld(Name component_name);
314  KinematicPose getComponentRelativePoseFromParent(Name component_name);
315  Eigen::Vector3d getComponentRelativePositionFromParent(Name component_name);
316  Eigen::Matrix3d getComponentRelativeOrientationFromParent(Name component_name);
317 
318  int8_t getId(Name component_name);
319  double getCoefficient(Name component_name);
320  double getTorqueCoefficient(Name component_name);
321  Eigen::Vector3d getAxis(Name component_name);
322  double getJointPosition(Name component_name);
323  double getJointVelocity(Name component_name);
324  double getJointAcceleration(Name component_name);
325  double getJointEffort(Name component_name);
326  JointValue getJointValue(Name component_name);
327 
328  double getComponentMass(Name component_name);
329  Eigen::Matrix3d getComponentInertiaTensor(Name component_name);
330  Eigen::Vector3d getComponentCenterOfMass(Name component_name);
331 
332  std::vector<double> getAllJointPosition();
333  std::vector<JointValue> getAllJointValue();
334  std::vector<double> getAllActiveJointPosition();
335  std::vector<JointValue> getAllActiveJointValue();
336  std::vector<double> getAllToolPosition();
337  std::vector<JointValue> getAllToolValue();
338 
339  std::vector<uint8_t> getAllJointID();
340  std::vector<uint8_t> getAllActiveJointID();
341  std::vector<Name> getAllToolComponentName();
342  std::vector<Name> getAllActiveJointComponentName();
343 
344 
345  /*****************************************************************************
346  ** Check Function
347  *****************************************************************************/
348  bool checkJointLimit(Name Component_name, double value);
349  bool checkComponentType(Name component_name, ComponentType component_type);
350 
351 
352  /*****************************************************************************
353  ** Find Function
354  *****************************************************************************/
355  Name findComponentNameUsingId(int8_t id);
356 };
357 
358 }
359 #endif // ROBOTIS_MANIPULATOR_COMMON_H
struct robotis_manipulator::_DynamicPose DynamicPose
enum robotis_manipulator::_TrajectoryType TrajectoryType
struct robotis_manipulator::_Point ToolValue
struct robotis_manipulator::_Limit Limit
struct robotis_manipulator::_World World
bool setEffortToValue(std::vector< JointValue > *value, std::vector< double > effort)
struct robotis_manipulator::_Object Object
struct robotis_manipulator::_Time Time
struct robotis_manipulator::_Component Component
std::vector< JointValue > JointWaypoint
struct robotis_manipulator::_ChainingName ChainingName
struct robotis_manipulator::_TaskWaypoint Pose
struct robotis_manipulator::_Relative Relative
struct robotis_manipulator::_Force Force
struct robotis_manipulator::_Dynamicvector Dynamicvector
struct robotis_manipulator::_JointConstant JointConstant
enum robotis_manipulator::_ComponentType ComponentType
struct robotis_manipulator::_Point JointValue
struct robotis_manipulator::_Moment Moment
struct robotis_manipulator::_Point ActuatorValue
struct robotis_manipulator::_KinematicPose KinematicPose
struct robotis_manipulator::_Inertia Inertia
bool setPositionToValue(std::vector< JointValue > *value, std::vector< double > position)
struct robotis_manipulator::_Point Point
std::string STRING
struct robotis_manipulator::_TaskWaypoint TaskWaypoint


robotis_manipulator
Author(s): Hye-Jong KIM , Darby Lim , Yong-Ho Na , Ryan Shim
autogenerated on Sat Oct 3 2020 03:14:51