robotiq_2f_gripper_ethercat_client.cpp
Go to the documentation of this file.
2 
4 
5 // See Robotiq's documentation for the register mapping
6 
7 // An effort to keep the lines less than 100 char long
9 {
10 
12  int slave_no)
13  : manager_(manager)
14  , slave_no_(slave_no)
15 {}
16 
17 /*
18  See support.robotiq.com -> manual for the register output meanings
19 */
21 {
22  uint8_t map[6] = {0}; // array containing all 6 output registers
23 
24  // Pack the Action Request register byte
25  map[0] = (output.rACT & 0x1) | ((output.rGTO << 0x3) & 0x8) | ((output.rATR << 0x4) & 0x10);
26  // registers 1 & 2 reserved by Robotiq
27  map[3] = output.rPR;
28  map[4] = output.rSP;
29  map[5] = output.rFR;
30 
31  for (unsigned i = 0; i < 6; ++i)
32  {
33  manager_.write(slave_no_, i, map[i]);
34  }
35 }
36 
38 {
39  uint8_t map[6];
40 
41  for (unsigned i = 0; i < 6; ++i)
42  {
43  map[i] = manager_.readInput(slave_no_, i);
44  }
45 
46  // Decode Input Registers
47  GripperInput input;
48  input.gACT = map[0] & 0x1;
49  input.gGTO = (map[0] >> 0x3) & 0x1;
50  input.gSTA = (map[0] >> 0x4) & 0x3;
51  input.gOBJ = (map[0] >> 0x6) & 0x3;
52  // map[1] is reserved by the protocol
53  input.gFLT = map[2] & 0xF;
54  input.gPR = map[3];
55  input.gPO = map[4];
56  input.gCU = map[5];
57 
58  return input;
59 }
60 
62 {
63  uint8_t map[6];
64  for (unsigned i = 0; i < 6; ++i)
65  {
66  map[i] = manager_.readOutput(slave_no_, i);
67  }
68 
69  GripperOutput output;
70  output.rACT = map[0] & 1;
71  output.rGTO = (map[0] >> 0x3) & 0x1;
72  output.rATR = (map[0] >> 0x4) & 0x1;
73  output.rPR = map[3];
74  output.rSP = map[4];
75  output.rFR = map[5];
76 
77  return output;
78 }
79 } // end of robotiq_2f_gripper_control namespace
GripperOutput readOutputs() const
Reads set of output-register values from the gripper.
unsigned char uint8_t
robotiq_2f_gripper_control::Robotiq2FGripper_robot_output GripperOutput
uint8_t readOutput(int slave_no, uint8_t channel) const
Robotiq2FGripperEtherCatClient(robotiq_ethercat::EtherCatManager &manager, int slave_no)
Constructs a control interface to a 2F Robotiq gripper on the given ethercat network and the given sl...
void write(int slave_no, uint8_t channel, uint8_t value)
uint8_t readInput(int slave_no, uint8_t channel) const
void writeOutputs(const GripperOutput &output)
Write the given set of control flags to the memory of the gripper.
robotiq_2f_gripper_control::Robotiq2FGripper_robot_input GripperInput
GripperInput readInputs() const
Reads set of input-register values from the gripper.


robotiq_2f_gripper_control
Author(s): Nicolas Lauzier (Robotiq inc.)
autogenerated on Tue Jun 1 2021 02:29:54