robot_interface
Native robot interface for making the visual manipulation
control_base.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Intel Corporation. All Rights Reserved
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
27 #pragma once
28 
29 #include <mutex>
30 #include <Eigen/Geometry>
31 #include <rclcpp/rclcpp.hpp>
32 #include <tf2_eigen/tf2_eigen.h>
33 #include <sensor_msgs/msg/joint_state.hpp>
34 #include <geometry_msgs/msg/pose_stamped.hpp>
35 
42 struct TcpPose
43 {
44  double x;
45  double y;
46  double z;
47  double alpha;
48  double beta;
49  double gamma;
50 };
51 
55 class ArmControlBase: public rclcpp::Node
56 {
57 public:
58 
64  ArmControlBase(const std::string node_name, const rclcpp::NodeOptions & options)
65  : Node(node_name, options)
66  {
67  joint_pub_ = this->create_publisher<sensor_msgs::msg::JointState>("/joint_states", 1);
68  time_out_ = 15.0;
69  }
70 
74  virtual ~ArmControlBase()
75  {
76  }
77 
90  virtual bool moveToTcpPose(double x, double y, double z,
91  double alpha, double beta, double gamma,
92  double vel, double acc) = 0;
93 
101  virtual bool moveToTcpPose(const Eigen::Isometry3d& pose, double vel, double acc);
102 
108  virtual bool open(const double distance = 0) = 0;
109 
115  virtual bool close(const double distance = 0) = 0;
116 
140  virtual bool pick(double x, double y, double z,
141  double alpha, double beta, double gamma,
142  double vel, double acc, double vel_scale, double approach);
143 
162  virtual bool pick(const geometry_msgs::msg::PoseStamped& pose_stamped,
163  double vel, double acc, double vel_scale, double approach);
164 
187  virtual bool place(double x, double y, double z,
188  double alpha, double beta, double gamma,
189  double vel, double acc, double vel_scale, double retract);
190 
208  virtual bool place(const geometry_msgs::msg::PoseStamped& pose_stamped,
209  double vel, double acc, double vel_scale, double retract);
210 
217  void toTcpPose(const geometry_msgs::msg::PoseStamped& pose_stamped, TcpPose& tcp_pose);
218 
225  void toTcpPose(const Eigen::Isometry3d& pose, TcpPose& tcp_pose);
226 
233  virtual bool checkTcpGoalArrived(Eigen::Isometry3d& tcp_goal);
234 
238  virtual void parseArgs() = 0;
239 
243  virtual bool startLoop() = 0;
244 
245 protected:
247  rclcpp::Publisher<sensor_msgs::msg::JointState>::SharedPtr joint_pub_;
249  std::vector<std::string> joint_names_;
253  std::mutex m_;
255  double time_out_;
256 };
ArmControlBase(const std::string node_name, const rclcpp::NodeOptions &options)
Constructor of class ArmControlBase.
Definition: control_base.hpp:64
TcpPose tcp_pose_
Current end-effctor pose.
Definition: control_base.hpp:251
Data type to represent robot arm&#39;s end-effector pose in 3D cartesian space.
Definition: control_base.hpp:42
Robot arm control interface.
Definition: control_base.hpp:55
double y
Definition: control_base.hpp:45
double x
Definition: control_base.hpp:44
double beta
Definition: control_base.hpp:48
rclcpp::Publisher< sensor_msgs::msg::JointState >::SharedPtr joint_pub_
Joint state publisher.
Definition: control_base.hpp:247
virtual ~ArmControlBase()
Default destructor of class ArmControlBase.
Definition: control_base.hpp:74
double gamma
Definition: control_base.hpp:49
double alpha
Definition: control_base.hpp:47
double z
Definition: control_base.hpp:46
std::mutex m_
Mutex to guard the tcp_pose usage.
Definition: control_base.hpp:253
double time_out_
Time duration to finish a pick or place task.
Definition: control_base.hpp:255
std::vector< std::string > joint_names_
Joint names.
Definition: control_base.hpp:249