Robotis Manipulator  1.0.0
robotis_manipulator.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_H_
26 #define ROBOTIS_MANIPULATOR_H_
27 
33 
34 #include <algorithm>
39 namespace robotis_manipulator
40 {
45 {
46 private:
50  std::map<Name, JointActuator *> joint_actuator_;
51  std::map<Name, ToolActuator *> tool_actuator_;
52 
57 
58 private:
62  void startMoving();
68  JointWaypoint getTrajectoryJointValue(double tick_time);
69 
70 public:
72  virtual ~RobotisManipulator();
73 
74 
75  /*****************************************************************************
76  ** Initialize Function
77  *****************************************************************************/
85  void addWorld(Name world_name,
86  Name child_name,
87  Eigen::Vector3d world_position = Eigen::Vector3d::Zero(),
88  Eigen::Matrix3d world_orientation = Eigen::Matrix3d::Identity());
105  void addJoint(Name my_name,
106  Name parent_name,
107  Name child_name,
108  Eigen::Vector3d relative_position,
109  Eigen::Matrix3d relative_orientation,
110  Eigen::Vector3d axis_of_rotation = Eigen::Vector3d::Zero(),
111  int8_t joint_actuator_id = -1,
112  double max_position_limit = M_PI,
113  double min_position_limit = -M_PI,
114  double coefficient = 1.0,
115  double mass = 0.0,
116  Eigen::Matrix3d inertia_tensor = Eigen::Matrix3d::Identity(),
117  Eigen::Vector3d center_of_mass = Eigen::Vector3d::Zero());
132  void addTool(Name my_name,
133  Name parent_name,
134  Eigen::Vector3d relative_position,
135  Eigen::Matrix3d relative_orientation,
136  int8_t tool_id = -1,
137  double max_position_limit =M_PI,
138  double min_position_limit = -M_PI,
139  double coefficient = 1.0,
140  double mass = 0.0,
141  Eigen::Matrix3d inertia_tensor = Eigen::Matrix3d::Identity(),
142  Eigen::Vector3d center_of_mass = Eigen::Vector3d::Zero());
148  void addComponentChild(Name my_name, Name child_name);
157  void addKinematics(Kinematics *kinematics);
165  void addJointActuator(Name actuator_name, JointActuator *joint_actuator, std::vector<uint8_t> id_array, const void *arg);
173  void addToolActuator(Name tool_name, ToolActuator *tool_actuator, uint8_t id, const void *arg);
179  void addCustomTrajectory(Name trajectory_name, CustomJointTrajectory *custom_trajectory);
185  void addCustomTrajectory(Name trajectory_name, CustomTaskTrajectory *custom_trajectory);
186 
187 
188  /*****************************************************************************
189  ** Manipulator Function
190  *****************************************************************************/
201  JointValue getJointValue(Name joint_name);
207  JointValue getToolValue(Name tool_name);
212  std::vector<JointValue> getAllActiveJointValue();
217  std::vector<JointValue> getAllJointValue();
222  std::vector<double> getAllToolPosition();
227  std::vector<JointValue> getAllToolValue();
233  KinematicPose getKinematicPose(Name component_name);
239  DynamicPose getDynamicPose(Name component_name);
245  Pose getPose(Name component_name);
246 
247 
248  /*****************************************************************************
249  ** Kinematics Function (Including Virtual Function)
250  *****************************************************************************/
256  Eigen::MatrixXd jacobian(Name tool_name);
260  void solveForwardKinematics();
268  bool solveInverseKinematics(Name tool_name, Pose goal_pose, std::vector<JointValue> *goal_joint_value);
273  void setKinematicsOption(const void* arg);
274 
275 
276  /*****************************************************************************
277  ** Actuator Function (Including Virtual Function)
278  *****************************************************************************/
285  void setJointActuatorMode(Name actuator_name, std::vector<uint8_t> id_array, const void *arg);
291  void setToolActuatorMode(Name actuator_name, const void *arg);
297  std::vector<uint8_t> getJointActuatorId(Name actuator_name);
303  uint8_t getToolActuatorId(Name actuator_name);
308  void enableActuator(Name actuator_name);
313  void disableActuator(Name actuator_name);
317  void enableAllJointActuator();
325  void enableAllToolActuator();
329  void disableAllToolActuator();
333  void enableAllActuator();
337  void disableAllActuator();
343  bool getActuatorEnabledState(Name actuator_name);
350  bool sendJointActuatorValue(Name joint_component_name, JointValue value);
357  bool sendMultipleJointActuatorValue(std::vector<Name> joint_component_name, std::vector<JointValue> value_vector);
363  bool sendAllJointActuatorValue(std::vector<JointValue> value_vector);
369  JointValue receiveJointActuatorValue(Name joint_component_name);
375  std::vector<JointValue> receiveMultipleJointActuatorValue(std::vector<Name> joint_component_name);
380  std::vector<JointValue> receiveAllJointActuatorValue();
387  bool sendToolActuatorValue(Name tool_component_name, JointValue value);
394  bool sendMultipleToolActuatorValue(std::vector<Name> tool_component_name, std::vector<JointValue> value_vector);
400  bool sendAllToolActuatorValue(std::vector<JointValue> value_vector);
406  JointValue receiveToolActuatorValue(Name tool_component_name);
412  std::vector<JointValue> receiveMultipleToolActuatorValue(std::vector<Name> tool_component_name);
417  std::vector<JointValue> receiveAllToolActuatorValue();
418 
419 
420  /*****************************************************************************
421  ** Time Function
422  *****************************************************************************/
427  double getTrajectoryMoveTime();
432  bool getMovingState();
433 
434 
435  /*****************************************************************************
436  ** Check Joint Limit Function
437  *****************************************************************************/
444  bool checkJointLimit(Name component_name, double position);
451  bool checkJointLimit(Name component_name, JointValue value);
458  bool checkJointLimit(std::vector<Name> component_name, std::vector<double> position_vector);
465  bool checkJointLimit(std::vector<Name> component_name, std::vector<JointValue> value_vector);
466 
467 
468  /*****************************************************************************
469  ** Trajectory Control Fuction
470  *****************************************************************************/
482  void makeJointTrajectoryFromPresentPosition(std::vector<double> delta_goal_joint_position, double move_time, std::vector<JointValue> present_joint_value = {});
489  void makeJointTrajectory(std::vector<double> goal_joint_position, double move_time, std::vector<JointValue> present_joint_value = {});
496  void makeJointTrajectory(std::vector<JointValue> goal_joint_value, double move_time, std::vector<JointValue> present_joint_value = {});
504  void makeJointTrajectory(Name tool_name, Eigen::Vector3d goal_position, double move_time, std::vector<JointValue> present_joint_value = {});
512  void makeJointTrajectory(Name tool_name, Eigen::Matrix3d goal_orientation, double move_time, std::vector<JointValue> present_joint_value = {});
520  void makeJointTrajectory(Name tool_name, KinematicPose goal_pose, double move_time, std::vector<JointValue> present_joint_value = {});
528  void makeTaskTrajectoryFromPresentPose(Name tool_name, Eigen::Vector3d position_meter, double move_time, std::vector<JointValue> present_joint_value = {});
536  void makeTaskTrajectoryFromPresentPose(Name tool_name, Eigen::Matrix3d orientation_meter, double move_time, std::vector<JointValue> present_joint_value = {});
544  void makeTaskTrajectoryFromPresentPose(Name tool_name, KinematicPose goal_pose_delta, double move_time, std::vector<JointValue> present_joint_value = {});
552  void makeTaskTrajectory(Name tool_name, Eigen::Vector3d goal_position, double move_time, std::vector<JointValue> present_joint_value = {});
560  void makeTaskTrajectory(Name tool_name, Eigen::Matrix3d goal_orientation, double move_time, std::vector<JointValue> present_joint_value = {});
568  void makeTaskTrajectory(Name tool_name, KinematicPose goal_pose, double move_time, std::vector<JointValue> present_joint_value = {});
569 
575  void setCustomTrajectoryOption(Name trajectory_name, const void* arg);
584  void makeCustomTrajectory(Name trajectory_name, Name tool_name, const void *arg, double move_time, std::vector<JointValue> present_joint_value = {});
592  void makeCustomTrajectory(Name trajectory_name, const void *arg, double move_time, std::vector<JointValue> present_joint_value = {});
598  void sleepTrajectory(double wait_time, std::vector<JointValue> present_joint_value = {});
604  void makeToolTrajectory(Name tool_name, double tool_goal_position);
610  std::vector<JointValue> getJointGoalValueFromTrajectory(double present_time);
615  std::vector<JointValue> getToolGoalValue();
621  std::vector<JointValue> getJointGoalValueFromTrajectoryTickTime(double tick_time);
622 };
623 } // namespace ROBOTIS_MANIPULATOR
624 
625 #endif
uint8_t getToolActuatorId(Name actuator_name)
getToolActuatorId
void enableAllToolActuator()
enableAllToolActuator
void makeToolTrajectory(Name tool_name, double tool_goal_position)
makeToolTrajectory
std::vector< JointValue > getToolGoalValue()
getToolGoalValue
std::vector< JointValue > receiveMultipleToolActuatorValue(std::vector< Name > tool_component_name)
receiveMultipleToolActuatorValue
std::vector< JointValue > getAllToolValue()
getAllToolValue
bool getActuatorEnabledState(Name actuator_name)
getActuatorEnabledState
void disableActuator(Name actuator_name)
disableActuator
std::vector< JointValue > receiveAllJointActuatorValue()
receiveAllJointActuatorValue
void addJoint(Name my_name, Name parent_name, Name child_name, Eigen::Vector3d relative_position, Eigen::Matrix3d relative_orientation, Eigen::Vector3d axis_of_rotation=Eigen::Vector3d::Zero(), int8_t joint_actuator_id=-1, double max_position_limit=M_PI, double min_position_limit=-M_PI, double coefficient=1.0, double mass=0.0, Eigen::Matrix3d inertia_tensor=Eigen::Matrix3d::Identity(), Eigen::Vector3d center_of_mass=Eigen::Vector3d::Zero())
addJoint
void disableAllJointActuator()
disableAllJointActuator
bool sendAllToolActuatorValue(std::vector< JointValue > value_vector)
sendAllToolActuatorValue
JointValue getToolValue(Name tool_name)
getToolValue
KinematicPose getKinematicPose(Name component_name)
getKinematicPose
main namespace
bool sendMultipleJointActuatorValue(std::vector< Name > joint_component_name, std::vector< JointValue > value_vector)
sendMultipleJointActuatorValue
void addWorld(Name world_name, Name child_name, Eigen::Vector3d world_position=Eigen::Vector3d::Zero(), Eigen::Matrix3d world_orientation=Eigen::Matrix3d::Identity())
addWorld
std::vector< JointValue > receiveMultipleJointActuatorValue(std::vector< Name > joint_component_name)
receiveMultipleJointActuatorValue
JointValue receiveToolActuatorValue(Name tool_component_name)
receiveToolActuatorValue
void setToolActuatorMode(Name actuator_name, const void *arg)
setToolActuatorMode
std::vector< JointValue > getJointGoalValueFromTrajectoryTickTime(double tick_time)
getJointGoalValueFromTrajectoryTickTime
std::vector< JointValue > receiveAllToolActuatorValue()
receiveAllToolActuatorValue
std::vector< JointValue > JointWaypoint
void makeJointTrajectory(std::vector< double > goal_joint_position, double move_time, std::vector< JointValue > present_joint_value={})
makeJointTrajectory
Trajectory * getTrajectory()
getTrajectory
void addToolActuator(Name tool_name, ToolActuator *tool_actuator, uint8_t id, const void *arg)
addToolActuator
void sleepTrajectory(double wait_time, std::vector< JointValue > present_joint_value={})
sleepTrajectory
std::vector< JointValue > getAllJointValue()
getAllJointValue
JointValue getJointValue(Name joint_name)
getJointValue
std::vector< JointValue > getJointGoalValueFromTrajectory(double present_time)
getJointGoalValueFromTrajectory
bool sendAllJointActuatorValue(std::vector< JointValue > value_vector)
sendAllJointActuatorValue
void addComponentChild(Name my_name, Name child_name)
addComponentChild
void enableAllJointActuator()
enableAllJointActuator
void solveForwardKinematics()
solveForwardKinematics
The RobotisManipulator class.
double getTrajectoryMoveTime()
getTrajectoryMoveTime
bool sendMultipleToolActuatorValue(std::vector< Name > tool_component_name, std::vector< JointValue > value_vector)
sendMultipleToolActuatorValue
void disableAllToolActuator()
disableAllToolActuator
bool checkJointLimit(Name component_name, double position)
checkJointLimit
void makeTaskTrajectoryFromPresentPose(Name tool_name, Eigen::Vector3d position_meter, double move_time, std::vector< JointValue > present_joint_value={})
makeTaskTrajectoryFromPresentPose
std::vector< JointValue > getAllActiveJointValue()
getAllActiveJointValue
std::map< Name, ToolActuator * > tool_actuator_
void setJointActuatorMode(Name actuator_name, std::vector< uint8_t > id_array, const void *arg)
setJointActuatorMode
DynamicPose getDynamicPose(Name component_name)
getDynamicPose
std::vector< uint8_t > getJointActuatorId(Name actuator_name)
getJointActuatorId
void addKinematics(Kinematics *kinematics)
addKinematics
void enableActuator(Name actuator_name)
enableActuator
void makeJointTrajectoryFromPresentPosition(std::vector< double > delta_goal_joint_position, double move_time, std::vector< JointValue > present_joint_value={})
makeJointTrajectoryFromPresentPosition
std::vector< double > getAllToolPosition()
getAllToolPosition
bool sendToolActuatorValue(Name tool_component_name, JointValue value)
sendToolActuatorValue
void setKinematicsOption(const void *arg)
setKinematicsOption
void addTool(Name my_name, Name parent_name, Eigen::Vector3d relative_position, Eigen::Matrix3d relative_orientation, int8_t tool_id=-1, double max_position_limit=M_PI, double min_position_limit=-M_PI, double coefficient=1.0, double mass=0.0, Eigen::Matrix3d inertia_tensor=Eigen::Matrix3d::Identity(), Eigen::Vector3d center_of_mass=Eigen::Vector3d::Zero())
addTool
JointWaypoint getTrajectoryJointValue(double tick_time)
getTrajectoryJointValue
bool solveInverseKinematics(Name tool_name, Pose goal_pose, std::vector< JointValue > *goal_joint_value)
solveInverseKinematics
void makeTaskTrajectory(Name tool_name, Eigen::Vector3d goal_position, double move_time, std::vector< JointValue > present_joint_value={})
makeTaskTrajectory
Eigen::MatrixXd jacobian(Name tool_name)
jacobian
std::map< Name, JointActuator * > joint_actuator_
void addCustomTrajectory(Name trajectory_name, CustomJointTrajectory *custom_trajectory)
addCustomTrajectory
Manipulator * getManipulator()
getManipulator
void setCustomTrajectoryOption(Name trajectory_name, const void *arg)
setCustomTrajectoryOption
void printManipulatorSetting()
printManipulatorSetting
void makeCustomTrajectory(Name trajectory_name, Name tool_name, const void *arg, double move_time, std::vector< JointValue > present_joint_value={})
makeCustomTrajectory
Pose getPose(Name component_name)
getPose
void addJointActuator(Name actuator_name, JointActuator *joint_actuator, std::vector< uint8_t > id_array, const void *arg)
addJointActuator
JointValue receiveJointActuatorValue(Name joint_component_name)
receiveJointActuatorValue
bool sendJointActuatorValue(Name joint_component_name, JointValue value)
sendJointActuatorValue