robotiq_3f_gripper_api.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016, Toyota Research Institute. All rights reserved.
2 
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 
9 // 2. Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 
13 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 // POSSIBILITY OF SUCH DAMAGE.
24 
26 
27 using namespace robotiq_3f_gripper_control;
28 using namespace robotiq;
29 
31  :base_(base)
32 {
33  pos_to_ticks_ = 200;
34  pos_offset_ = 0;
35  sci_to_ticks_ = -532;
36  sci_offset_ = 0.22;
37  vel_to_ticks_ = 2.94;
38  vel_offset_ = 22;
39  force_to_ticks_ = 5.7;
40  force_offset_ = 15;
41  cur_to_ticks_ = 10;
42 
44  read();
45  command_.rACT = status_.gACT;
46  command_.rMOD = status_.gMOD;
47  command_.rGTO = status_.gGTO;
48  command_.rPRA = status_.gPRA;
49  command_.rPRB = status_.gPRB;
50  command_.rPRC = status_.gPRC;
51  command_.rPRS = status_.gPRS;
52 }
53 
55 {
56  command_.rACT = (Robotiq3FGripperClientBase::GripperOutput::_rACT_type)mode;
57 }
58 
60 {
61  command_.rMOD = (Robotiq3FGripperClientBase::GripperOutput::_rMOD_type)mode;
62 }
63 
65 {
66  command_.rGTO = (Robotiq3FGripperClientBase::GripperOutput::_rGTO_type)mode;
67 }
68 
70 {
71  command_.rATR = (Robotiq3FGripperClientBase::GripperOutput::_rATR_type)release;
72 }
73 
75 {
76  command_.rICF = (Robotiq3FGripperClientBase::GripperOutput::_rICF_type)fingers;
77  command_.rICS = (Robotiq3FGripperClientBase::GripperOutput::_rICS_type)scissor;
78 }
79 
80 void Robotiq3FGripperAPI::setPosition(const double &posA, const double &posB, const double &posC, const double &posS)
81 {
82  command_.rPRA = limit<Robotiq3FGripperClientBase::GripperOutput::_rPRA_type>(pos_to_ticks_*(posA - pos_offset_));
83  command_.rPRB = limit<Robotiq3FGripperClientBase::GripperOutput::_rPRB_type>(pos_to_ticks_*(posB - pos_offset_));
84  command_.rPRC = limit<Robotiq3FGripperClientBase::GripperOutput::_rPRC_type>(pos_to_ticks_*(posC - pos_offset_));
85  command_.rPRS = limit<Robotiq3FGripperClientBase::GripperOutput::_rPRS_type>(sci_to_ticks_*(posS - sci_offset_));
86 }
87 
88 void Robotiq3FGripperAPI::setVelocity(const double &velA, const double &velB, const double &velC, const double &velS)
89 {
90  command_.rSPA = limit<Robotiq3FGripperClientBase::GripperOutput::_rSPA_type>(vel_to_ticks_*(velA - vel_offset_));
91  command_.rSPB = limit<Robotiq3FGripperClientBase::GripperOutput::_rSPB_type>(vel_to_ticks_*(velB - vel_offset_));
92  command_.rSPC = limit<Robotiq3FGripperClientBase::GripperOutput::_rSPC_type>(vel_to_ticks_*(velC - vel_offset_));
93  command_.rSPS = limit<Robotiq3FGripperClientBase::GripperOutput::_rSPS_type>(vel_to_ticks_*(velS - vel_offset_));
94 }
95 
96 void Robotiq3FGripperAPI::setForce(const double &fA, const double &fB, const double &fC, const double &fS)
97 {
98  command_.rFRA = limit<Robotiq3FGripperClientBase::GripperOutput::_rFRA_type>(force_to_ticks_*(fA - force_offset_));
99  command_.rFRB = limit<Robotiq3FGripperClientBase::GripperOutput::_rFRB_type>(force_to_ticks_*(fB - force_offset_));
100  command_.rFRC = limit<Robotiq3FGripperClientBase::GripperOutput::_rFRC_type>(force_to_ticks_*(fC - force_offset_));
101  command_.rFRS = limit<Robotiq3FGripperClientBase::GripperOutput::_rFRS_type>(force_to_ticks_*(fS - force_offset_));
102 }
103 
105 {
106  command_ = raw;
107 }
108 
109 void Robotiq3FGripperAPI::getPosition(double *posA, double *posB, double *posC, double *posS) const
110 {
111  *posA = (double)status_.gPOA/pos_to_ticks_ + pos_offset_;
112  *posB = (double)status_.gPOB/pos_to_ticks_ + pos_offset_;
113  *posC = (double)status_.gPOC/pos_to_ticks_ + pos_offset_;
114  *posS = (double)status_.gPOS/sci_to_ticks_ + sci_offset_;
115 }
116 
117 void Robotiq3FGripperAPI::getPositionCmd(double *posA, double *posB, double *posC, double *posS) const
118 {
119  *posA = (double)status_.gPRA/pos_to_ticks_ + pos_offset_;
120  *posB = (double)status_.gPRB/pos_to_ticks_ + pos_offset_;
121  *posC = (double)status_.gPRC/pos_to_ticks_ + pos_offset_;
122  *posS = (double)status_.gPRS/sci_to_ticks_ + sci_offset_;
123 }
124 
125 void Robotiq3FGripperAPI::getCurrent(double *curA, double *curB, double *curC, double *curS) const
126 {
127  *curA = (double)status_.gCUA/cur_to_ticks_;
128  *curB = (double)status_.gCUB/cur_to_ticks_;
129  *curC = (double)status_.gCUC/cur_to_ticks_;
130  *curS = (double)status_.gCUS/cur_to_ticks_;
131 }
132 
134 {
135  *gACT = (InitializationMode)status_.gACT;
136  *gMOD = (GraspingMode)status_.gMOD;
137  *gGTO = (ActionMode)status_.gGTO;
138  *gIMC = (GripperStatus)status_.gIMC;
139  *gSTA = (MotionStatus)status_.gSTA;
140 }
141 
143 {
144  *gFLT = (FaultStatus)status_.gFLT;
145 }
146 
148 {
149  *fA = (ObjectStatus)status_.gDTA;
150  *fB = (ObjectStatus)status_.gDTB;
151  *fC = (ObjectStatus)status_.gDTC;
152  *fS = (ObjectStatus)status_.gDTS;
153 }
154 
156 {
157  *raw = status_;
158 }
159 
160 void Robotiq3FGripperAPI::getCommandPos(double *posA, double *posB, double *posC, double *posS) const
161 {
162  *posA = (double)command_.rPRA/pos_to_ticks_ + pos_offset_;
163  *posB = (double)command_.rPRB/pos_to_ticks_ + pos_offset_;
164  *posC = (double)command_.rPRC/pos_to_ticks_ + pos_offset_;
165  *posS = (double)command_.rPRS/sci_to_ticks_ + sci_offset_;
166 }
167 
169 {
170  return ((InitializationMode)status_.gACT == INIT_ACTIVATION);
171 }
172 
174 {
175  return ((GripperStatus)status_.gIMC == GRIPPER_READY);
176 }
177 
179 {
180  return ((GraspingMode)status_.gMOD == mode);
181 }
182 
184 {
185  return ((ActionMode)status_.gGTO == ACTION_STOP);
186 }
187 
189 {
190  return (status_.gSTA == MOTION_STARTED);
191 }
192 
194 {
196 }
197 
199 {
200  status_ = base_->readInputs();
201 }
202 
204 {
205  base_->writeOutputs(command_);
206 }
void getGripperStatus(InitializationMode *gACT, GraspingMode *gMOD, ActionMode *gGTO, GripperStatus *gIMC, MotionStatus *gSTA) const
robotiq_3f_gripper_articulated_msgs::Robotiq3FGripperRobotOutput GripperOutput
boost::shared_ptr< Robotiq3FGripperClientBase > base_
void setPosition(const double &posA, const double &posB=0, const double &posC=0, const double &posS=0)
void getPosition(double *posA, double *posB, double *posC, double *posS) const
void setInidividualControlMode(IndividualControl fingers, IndividualControl scissor)
Robotiq3FGripperClientBase::GripperOutput command_
void setVelocity(const double &velA, const double &velB=0, const double &velC=0, const double &velS=0)
void getCurrent(double *curA, double *curB, double *curC, double *curS) const
void getCommandPos(double *posA, double *posB, double *posC, double *posS) const
Robotiq3FGripperClientBase::GripperInput status_
Robotiq3FGripperAPI(boost::shared_ptr< Robotiq3FGripperClientBase > base)
void getObjectStatus(ObjectStatus *fA, ObjectStatus *fB, ObjectStatus *fC, ObjectStatus *fS) const
robotiq_3f_gripper_articulated_msgs::Robotiq3FGripperRobotInput GripperInput
void setRaw(const Robotiq3FGripperClientBase::GripperOutput &raw)
void getRaw(Robotiq3FGripperClientBase::GripperInput *raw) const
void getPositionCmd(double *posA, double *posB, double *posC, double *posS) const
void setForce(const double &fA, const double &fB=0, const double &fC=0, const double &fS=0)


robotiq_3f_gripper_control
Author(s): Nicolas Lauzier (Robotiq inc.), Allison Thackston
autogenerated on Tue Jun 1 2021 02:29:58