Robotis Manipulator  1.0.0
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 
25 #ifndef ROBOTIS_MANIPULATOR_COMMON_H
26 #define ROBOTIS_MANIPULATOR_COMMON_H
27 
28 #include <unistd.h>
29 #if defined(__OPENCR__)
30  #include <Eigen.h> // Calls main Eigen matrix class library
31  #include <Eigen/LU> // Calls inverse, determinant, LU decomp., etc.
32  #include <WString.h>
33 #else
34  #include <eigen3/Eigen/Eigen>
35  #include <eigen3/Eigen/LU>
36 #endif
37 #include <math.h>
38 #include <vector>
39 #include <map>
42 
43 namespace robotis_manipulator
44 {
45 
46 typedef STRING Name;
47 
48 /*****************************************************************************
49 ** Value Set
50 *****************************************************************************/
51 typedef struct KinematicPose
52 {
53  Eigen::Vector3d position;
54  Eigen::Matrix3d orientation;
56 
57 typedef struct Dynamicvector
58 {
59  Eigen::Vector3d velocity;
60  Eigen::Vector3d acceleration;
62 
63 typedef struct DynamicPose
64 {
67 } DynamicPose;
68 
69 typedef struct Inertia
70 {
71  double mass;
72  Eigen::Matrix3d inertia_tensor;
73  Eigen::Vector3d center_of_mass;
74 } Inertia;
75 
76 typedef struct Limit
77 {
78  double maximum;
79  double minimum;
80 } Limit;
81 
82 
83 /*****************************************************************************
84 ** Time Set
85 *****************************************************************************/
86 typedef struct Time
87 {
89  double present_time;
90  double start_time;
91 } Time;
92 
93 
94 /*****************************************************************************
95 ** Trajectory Set
96 *****************************************************************************/
97 typedef enum TrajectoryType
98 {
99  NONE = 0,
105 
106 typedef struct Point
107 {
108  double position;
109  double velocity;
110  double acceleration;
111  double effort;
113 
114 typedef std::vector<JointValue> JointWaypoint;
115 
116 typedef struct Pose
117 {
120 } TaskWaypoint, Pose;
121 
122 
123 /*****************************************************************************
124 ** Component Set
125 *****************************************************************************/
126 typedef enum ComponentType
127 {
131 } ComponentType;
132 
133 typedef struct ChainingName
134 {
135  Name parent;
136  std::vector<Name> child;
137 } ChainingName;
138 
139 typedef struct Relative
140 {
143 } Relative;
144 
145 typedef struct JointConstant
146 {
147  int8_t id;
148  Eigen::Vector3d axis;
149  double coefficient; // joint angle over actuator angle
151 } JointConstant;
152 
153 typedef struct World
154 {
155  Name name;
156  Name child;
157  Pose pose;
158 } World;
159 
160 typedef struct Component
161 {
162  //constant
164  ComponentType component_type;
167 
168  //variable
170  JointValue joint_value;
171 
172  //Actuator
174 } Component;
175 
176 
177 /*****************************************************************************
178 ** Manipulator Class
179 *****************************************************************************/
184 {
185 private:
186  int8_t dof_;
188  std::map<Name, Component> component_;
189 
190 public:
191  Manipulator();
193 
194  /*****************************************************************************
195  ** Add Function
196  *****************************************************************************/
204  void addWorld(Name world_name,
205  Name child_name,
206  Eigen::Vector3d world_position = Eigen::Vector3d::Zero(),
207  Eigen::Matrix3d world_orientation = Eigen::Matrix3d::Identity());
224  void addJoint(Name my_name,
225  Name parent_name,
226  Name child_name,
227  Eigen::Vector3d relative_position,
228  Eigen::Matrix3d relative_orientation,
229  Eigen::Vector3d axis_of_rotation = Eigen::Vector3d::Zero(),
230  int8_t joint_actuator_id = -1,
231  double max_position_limit = M_PI,
232  double min_position_limit = -M_PI,
233  double coefficient = 1.0,
234  double mass = 0.0,
235  Eigen::Matrix3d inertia_tensor = Eigen::Matrix3d::Identity(),
236  Eigen::Vector3d center_of_mass = Eigen::Vector3d::Zero());
251  void addTool(Name my_name,
252  Name parent_name,
253  Eigen::Vector3d relative_position,
254  Eigen::Matrix3d relative_orientation,
255  int8_t tool_id = -1,
256  double max_position_limit = M_PI,
257  double min_position_limit = -M_PI,
258  double coefficient = 1.0,
259  double mass = 0.0,
260  Eigen::Matrix3d inertia_tensor = Eigen::Matrix3d::Identity(),
261  Eigen::Vector3d center_of_mass = Eigen::Vector3d::Zero());
267  void addComponentChild(Name my_name, Name child_name);
271  void printManipulatorSetting();
272 
273 
274  /*****************************************************************************
275  ** Set Function
276  *****************************************************************************/
281  void setWorldPose(Pose world_pose);
286  void setWorldKinematicPose(KinematicPose world_kinematic_pose);
291  void setWorldPosition(Eigen::Vector3d world_position);
296  void setWorldOrientation(Eigen::Matrix3d world_orientation);
301  void setWorldDynamicPose(DynamicPose world_dynamic_pose);
306  void setWorldLinearVelocity(Eigen::Vector3d world_linear_velocity);
311  void setWorldAngularVelocity(Eigen::Vector3d world_angular_velocity);
316  void setWorldLinearAcceleration(Eigen::Vector3d world_linear_acceleration);
321  void setWorldAngularAcceleration(Eigen::Vector3d world_angular_acceleration);
327  void setComponent(Name component_name, Component component);
333  void setComponentActuatorName(Name component_name, Name actuator_name);
339  void setComponentPoseFromWorld(Name component_name, Pose pose_to_world);
345  void setComponentKinematicPoseFromWorld(Name component_name, KinematicPose pose_to_world);
351  void setComponentPositionFromWorld(Name component_name, Eigen::Vector3d position_to_world);
357  void setComponentOrientationFromWorld(Name component_name, Eigen::Matrix3d orientation_to_wolrd);
363  void setComponentDynamicPoseFromWorld(Name component_name, DynamicPose dynamic_pose);
369  void setJointPosition(Name name, double position);
375  void setJointVelocity(Name name, double velocity);
381  void setJointAcceleration(Name name, double acceleration);
387  void setJointEffort(Name name, double effort);
393  void setJointValue(Name name, JointValue joint_value);
398  void setAllActiveJointPosition(std::vector<double> joint_position_vector);
403  void setAllActiveJointValue(std::vector<JointValue> joint_value_vector);
408  void setAllJointPosition(std::vector<double> joint_position_vector);
413  void setAllJointValue(std::vector<JointValue> joint_value_vector);
418  void setAllToolPosition(std::vector<double> tool_position_vector);
423  void setAllToolValue(std::vector<JointValue> tool_value_vector);
424 
425 
426  /*****************************************************************************
427  ** Get Function
428  *****************************************************************************/
433  int8_t getDOF();
438  Name getWorldName();
443  Name getWorldChildName();
448  Pose getWorldPose();
453  KinematicPose getWorldKinematicPose();
458  Eigen::Vector3d getWorldPosition();
463  Eigen::Matrix3d getWorldOrientation();
468  DynamicPose getWorldDynamicPose();
473  int8_t getComponentSize();
478  std::map<Name, Component> getAllComponent();
483  std::map<Name, Component>::iterator getIteratorBegin();
488  std::map<Name, Component>::iterator getIteratorEnd();
494  Component getComponent(Name component_name);
500  Name getComponentActuatorName(Name component_name);
506  Name getComponentParentName(Name component_name);
512  std::vector<Name> getComponentChildName(Name component_name);
518  Pose getComponentPoseFromWorld(Name component_name);
524  KinematicPose getComponentKinematicPoseFromWorld(Name component_name);
530  Eigen::Vector3d getComponentPositionFromWorld(Name component_name);
536  Eigen::Matrix3d getComponentOrientationFromWorld(Name component_name);
542  DynamicPose getComponentDynamicPoseFromWorld(Name component_name);
548  KinematicPose getComponentRelativePoseFromParent(Name component_name);
554  Eigen::Vector3d getComponentRelativePositionFromParent(Name component_name);
560  Eigen::Matrix3d getComponentRelativeOrientationFromParent(Name component_name);
566  int8_t getId(Name component_name);
572  double getCoefficient(Name component_name);
578  Eigen::Vector3d getAxis(Name component_name);
584  double getJointPosition(Name component_name);
590  double getJointVelocity(Name component_name);
596  double getJointAcceleration(Name component_name);
602  double getJointEffort(Name component_name);
608  JointValue getJointValue(Name component_name);
614  double getComponentMass(Name component_name);
620  Eigen::Matrix3d getComponentInertiaTensor(Name component_name);
626  Eigen::Vector3d getComponentCenterOfMass(Name component_name);
631  std::vector<double> getAllJointPosition();
636  std::vector<JointValue> getAllJointValue();
641  std::vector<double> getAllActiveJointPosition();
646  std::vector<JointValue> getAllActiveJointValue();
651  std::vector<double> getAllToolPosition();
656  std::vector<JointValue> getAllToolValue();
661  std::vector<uint8_t> getAllJointID();
666  std::vector<uint8_t> getAllActiveJointID();
671  std::vector<Name> getAllToolComponentName();
676  std::vector<Name> getAllActiveJointComponentName();
677 
678 
679  /*****************************************************************************
680  ** Check Function
681  *****************************************************************************/
688  bool checkJointLimit(Name Component_name, double value);
695  bool checkComponentType(Name component_name, ComponentType component_type);
696 
697 
698  /*****************************************************************************
699  ** Find Function
700  *****************************************************************************/
706  Name findComponentNameUsingId(int8_t id);
707 };
708 
709 }
710 #endif // ROBOTIS_MANIPULATOR_COMMON_H
struct robotis_manipulator::World World
struct robotis_manipulator::DynamicPose DynamicPose
struct robotis_manipulator::JointConstant JointConstant
main namespace
struct robotis_manipulator::Time Time
struct robotis_manipulator::Point JointValue
struct robotis_manipulator::Dynamicvector Dynamicvector
struct robotis_manipulator::Point ActuatorValue
struct robotis_manipulator::Point ToolValue
std::vector< JointValue > JointWaypoint
struct robotis_manipulator::Pose Pose
struct robotis_manipulator::KinematicPose KinematicPose
struct robotis_manipulator::ChainingName ChainingName
struct robotis_manipulator::Relative Relative
struct robotis_manipulator::Component Component
struct robotis_manipulator::Limit Limit
std::string STRING
struct robotis_manipulator::Pose TaskWaypoint
struct robotis_manipulator::Inertia Inertia
struct robotis_manipulator::Point Point