RoboGeeks
TH
$
เข้าสู่ระบบเข้าร่วม

Robotiq Open-Source C++ SDK for Adaptive Grippers - Quick Start

Robotiq · Uploaded · 32:35 · Watch on YouTube

Robotiq engineer Benoit continues his C++ quick start, showing how to connect to an adaptive gripper over a serial port and activate it. He then walks through building a gripper command, reading status bytes, and using wait-for helpers to confirm the gripper reaches its target.

Transcript

Captions as a .vtt fileEmbed with the transcript

  1. 0:00Hello everyone, my name is Benoit. I'm a Physical Engineer for Physical AI at Robotic
  2. 0:06and in this video I'm going to give you a quick start on our C++ library to control
  3. 0:12robotic adaptive grippers. So let's get started. In the previous video we set up the environment
  4. 0:19to compile the C++ code. Now we are actually going to use the different function of the C++
  5. 0:26library to control the robotic adaptive grippers. So let's access again to the
  6. 0:34C++ library documentation from the GitHub of Robotic. I'm going to select the C++ tool here
  7. 0:42and access the documentation. We are going to check the introduction guides and we are going
  8. 0:49now to review the quick start guide. Okay, so on the right I have a VS code with my main.cpp
  9. 1:00file currently open. So this is a hello world code from the previous video. So we are going to modify
  10. 1:08that and actually implement some function of the C++ library. So following the quick start guide,
  11. 1:18first I'm going to place the dependency. We are going to include the different dependencies. So we
  12. 1:27have obviously the dependency for the robotic gripper library. We also add the IO stream library to display
  13. 1:38a few things in the terminal for demo purpose. We also have here a library called chrono. It's used to
  14. 1:47to set some time variable in the program. So in the main I'm going to remove the hello world
  15. 1:58that we did previously. So first of all, before we create a gripper object and we start, we make the gripper move,
  16. 2:06we need to establish the connection with the gripper. So to do that we need to provide, to retrieve the serial
  17. 2:14port name on which is connected the gripper. And we will retrieve it from the terminal in this example.
  18. 2:23So that will be an exact variable, an argument that is provided when we call the executable in the terminal.
  19. 2:34So in the main function, we are going to retrieve the arguments like this.
  20. 2:43So we will check that one argument is provided, at least one argument is provided when the executable
  21. 3:01is launched. And so this single argument will be the comport. So this is a little check here to see if we
  22. 3:10have one argument that has been passed. And if it's not here, we will display a message saying
  23. 3:17that the comport is missing. So then we are going to create
  24. 3:26a connection config object to define the connection with the gripper.
  25. 3:34So in the robotic space name, I will create, select the class connection config and create
  26. 3:47a connection config object like this. And then I will set some parameters on this object.
  27. 3:56So the serial port, I will set it to the argument we retrieve from the terminal like this.
  28. 4:16Actually, you can use tools like VS Code to check what you have in the different objects. So for
  29. 4:25example, in the connection config, like you can see, you can set the modbus slave ID address.
  30. 4:35You can set also the serial object so that we reset just previously. You can set the connection
  31. 4:42frequency. If you check the serial object, you can see that you can adjust the board rate, the latency
  32. 4:50timer. You can adjust the port that we set previously here and the timeout. So it's a good way to navigate
  33. 4:58through object and see what you can do. You can also check the related documentation. Easy way is to
  34. 5:06check the global index here. For example, I'm going to check the documentation for the connection config.
  35. 5:14And here I have a description. I have an example about the different parameters I can set for the connection configuration.
  36. 5:24And I have also the description of the different functions here, the different parameters.
  37. 5:33So I'm going to build this example like this and just execute the file that have been compiled.
  38. 6:02So the file actually is named quickstart.exe. So the cmake list have been adjusted. Here we change the name from
  39. 6:16yourhop to quickstart.exe. So quickstart.exe has been created. I'm going to execute that. So you see, I didn't
  40. 6:30give the comp port. So I get the error message telling me that there is a missing argument. And now I'm going to
  41. 6:39pass like comp port 4. And so it executes without any error. So this configuration, this connection
  42. 6:51is working is working. And so we can continue with the programming. So yeah, so now next step is to
  43. 7:05create our gripper object. So I'm going back to the quickstart guide. And we are going to create the
  44. 7:14the gripper object. So we are going to use in the robotic space name, we are going to use the gripper class.
  45. 7:26And we are going to create an object called gripper. And we are going to construct this
  46. 7:35this gripper object using the connection config that we created previously like this.
  47. 7:43So before we start playing with the gripper object and try to make the gripper move,
  48. 7:50I'm going to explain you a little bit how things are working and how you control the gripper
  49. 7:56through the gripper object. So let's check the documentation. So there is a how it works
  50. 8:05document that that you can check to familiarize yourself with the gripper object. So here is how it
  51. 8:12works. So the gripper object is the object that we communicate with the gripper. So it handles all
  52. 8:21the mode burst communication. So you don't need to worry about it. So the way you control the gripper
  53. 8:31is through the gripper object is like this. So you send command to the gripper object, or you retrieve
  54. 8:39status from the gripper object. So you will ask for the, for example, to the gripper, like move at a
  55. 8:44given position with a given speed. And the gripper will answer you from its status, like I am here at this
  56. 8:54position, moving toward the target. I am at the target. The motion is complete. So it's a, it's kind of the
  57. 9:03dialogue with the gripper object. So there is also some free function around the gripper object
  58. 9:15that help you to do some particular actions. And those functions are the activate function. The job of the
  59. 9:28activation function is to activate the gripper. So the gripper will make a full close, full open to
  60. 9:36find its extreme position. There is also a free function called recover from fault. This function
  61. 9:46will clear the fault that you have on the gripper and if necessary, redo the activation.
  62. 9:56So those functions are free functions, not part of the gripper object,
  63. 10:00but available to perform some specific tasks. So I will also give you some explanation about
  64. 10:12what is a command, what do you have in a command, and also what kind of information you can get from
  65. 10:18the status. All of this is well documented as well in the gripper manual. So I invite you to use the manual
  66. 10:26as a reference to see how you can control and how you can get the status of the gripper. So here is what
  67. 10:36you have in a command. In a command you have six bytes of eight bits and so each byte have a specific
  68. 10:47function. So the first byte here is called action request and inside this byte there are several bits.
  69. 10:56that have a specific function. So you can see here the details and here the description. So
  70. 11:07for example, you will find the byte air act for activate, you have the byte go to, you have the
  71. 11:16byte for the auto release and so on. So this is like to perform specific, to trigger specific function of the
  72. 11:28the gripper. You then have a byte for the position request. So it's just the position you want the
  73. 11:36gripper to move from zero to 255. Then you have the speed of the gripper from zero to 255 and the force
  74. 11:44same from zero to 255. So this is what you have in a command. And you have some examples here on how to build a command.
  75. 12:01So you create a command. For example, if you want to set some bits in the action byte, you can write
  76. 12:13like command dot action and set specific bits inside the action byte using the set command function.
  77. 12:28So here for example, in the action byte, I'm setting the bit activate to true.
  78. 12:40Then there is here the go to byte that is set to true.
  79. 12:48So that's what you have in the command. Then for the status, the status is also made of six bytes.
  80. 13:03Each byte is made of eight bits. The first byte is the gripper status. Here also it's a packed byte.
  81. 13:14There are several bits inside with specific information. In the same way, you have the false status that is also a packed byte,
  82. 13:32where there are some bits with specific information. Then you have the position request echo.
  83. 13:42So actually this is a gripper that just tells you that he received the position request you give to him.
  84. 13:53So he acknowledges that he tells you that he received the position request properly.
  85. 14:04Then there is a position register. So this is the current position of the finger.
  86. 14:11And you can also retrieve the current. So here also in the documentation,
  87. 14:18you find some examples about information you can retrieve from the status.
  88. 14:25We spoke just before about the free function around the gripper object with activate and recover from faults.
  89. 14:34There is also one free function that is quite useful. It's called wait for.
  90. 14:43So wait for is just here to wait for a given, for a certain condition of the gripper.
  91. 14:53So for example, you can wait for the gripper to acknowledge the position request you just sent to him.
  92. 15:03You can wait for the gripper to reach its target position. We are going to use it in our program.
  93. 15:12So now we have our gripper object. We know how to work with it. We know that we can send command to the gripper, retrieve status.
  94. 15:21We know there are some free functions around the gripper object, like the activate function, the retrieve fold function and the wait function.
  95. 15:32So let's use all of this to actually operate the gripper. So first thing we will do is to activate the gripper using the free function activate.
  96. 15:44We give him the gripper object as argument. I'm going to save that and just press on play.
  97. 16:03So you see the gripper perform the activation. You may notice that if I start the program again, nothing happened.
  98. 16:13Actually, it's because the gripper is already activated. So if the gripper is already activated, the activate function just does nothing.
  99. 16:25There is nothing to do. The gripper is already activated.
  100. 16:30So now we are going to build a command and send it to the gripper. So we will request the gripper to move at a certain position.
  101. 16:39So let's create a gripper command object. So we call this command and we will set this command
  102. 16:58with the default command. So you can access the default command from the gripper command object like this.
  103. 17:17And so we are going to set the different parameters from the command. So what we want here is that we want the
  104. 17:27the gripper to move at the position that we will set in the command. So to do that, we need to have the
  105. 17:35goto byte of the gripper set to one. So in the command action byte, we are going to set the goto bit to one.
  106. 17:50So let's do that. I'm in the command. I'm setting in the action bytes. I'm setting the the byte
  107. 18:05called robotic action action request bytes. Go to. So you see here, I have
  108. 18:22the different bits that I can set inside the action bytes. So here I'm just setting the goto byte to one.
  109. 18:39So the set function, actually, you can pass a second argument like set true or false. But actually,
  110. 18:52if you don't provide any argument, set will will set the byte to true by default. So here I don't
  111. 19:00precise the second argument. I want just this to be to true to one. Okay, then I'm going to set
  112. 19:09the position request byte. And I will set the position 100. Then we are going to set the speed byte.
  113. 19:22And we are going to ask for the maximum speed 255. And we will also ask the force byte to be at 255.
  114. 19:40Okay, so we have our command that is ready to be sent to our gripper object. And now we are going to
  115. 19:48send it to our gripper object using the set command function of the gripper object. So
  116. 19:53let's do that. So let's do that. So gripper dot set command. And I'm going to pass the command we just
  117. 20:02previously created like this. So now we prepare the command and we send it to the gripper. If you execute
  118. 20:20this code like this, you notice that nothing happened. The gripper did not move to the position 100.
  119. 20:30And actually, it's normal. The thing is that in this program, we request the gripper to go at position 100.
  120. 20:38We send it to the gripper object. We send it to the gripper object, but then the program complete
  121. 20:44even before the gripper object had the opportunity to communicate this command to the gripper.
  122. 20:51So we need to wait for the gripper to acknowledge you receive the command
  123. 21:00and wait for the command to complete before we actually close the
  124. 21:08the program. So we are going to use the wait for function to wait for three things. So first,
  125. 21:14we are going to wait for the gripper to acknowledge you receive the
  126. 21:19the position request. Then we wait for the gripper to move. And finally, we will wait for the gripper to
  127. 21:27reach its final destination. So let's do that. So I'm going to use the
  128. 21:35wait for function that is in the robotic namespace. So this function takes
  129. 21:46two arguments like your predicate. So this is a condition that we are waiting for. So we are waiting
  130. 21:53for first for the gripper to acknowledge he received the position request. And so the second argument is a
  131. 22:02a timeout. So for the condition you use you set the condition with the nabla function.
  132. 22:14So we are going to check the gripper status.
  133. 22:21So I'm using the getStatus function of the gripper object.
  134. 22:26So in the retrieve status, I'm going to check the byte position request echo.
  135. 22:38So I want the position request echo to be equal to the position request that is in the command that we
  136. 22:49we send to the gripper. Like this. And we are going to make a timeout of let's say like one second.
  137. 23:14So then we are going to wait for the gripper to to be actually moving. So once again I'm using the
  138. 23:24I forget the semicolon here. I'm going to use the wait for function again. And this time
  139. 23:38we are going to wait for the gripper to be moving. And you can check that by looking at the
  140. 23:47the object detection byte in the gripper status. So here we retrieve once again the gripper status.
  141. 24:02We'll check the gripper status byte and and we are going to check the object
  142. 24:11detection. So we want the object detection tell you if you if you detect an object but it also tell you
  143. 24:21if the gripper if the gripper is actually moving toward its target. So we are here we retrieve the object detection
  144. 24:34information and so we are going to check that the the object detection is actually at the status gripper moving.
  145. 24:47So you can see the different value that I can take the object detection
  146. 24:56using the object detection enum. Here we we want to check that the gripper is moving. Then we set timeouts
  147. 25:20say once again once again. And finally
  148. 25:24So I'm going to enlarge here. Finally
  149. 25:30We are going to wait for the gripper to reach its final destination. So wait for
  150. 25:43Nabla function. We are going to wait for the the gripper object detection status to be
  151. 25:57like a gripper at final position. So I retrieve the gripper status
  152. 26:05I'm going to check the gripper status
  153. 26:09bytes and
  154. 26:12retrieve the information
  155. 26:14object detection once again
  156. 26:19and I'm going to check that it's
  157. 26:22equal to
  158. 26:24the
  159. 26:26the enum like
  160. 26:31at requested position
  161. 26:33like this
  162. 26:40Okay, and we set the timeout once again at one second. Okay
  163. 26:53So
  164. 26:55we have everything in place
  165. 26:57so we can now execute the code. So we are going to
  166. 27:01wait for the gripper to acknowledge
  167. 27:04that he received the the position request. We are going to wait for the gripper to be moving
  168. 27:11and finally we are going to wait
  169. 27:15for the gripper to reach its final destination. So let's play this program
  170. 27:24and you can see that the the gripper
  171. 27:27effectively went to the position 100.
  172. 27:30we could modify this
  173. 27:34put position like 50
  174. 27:37and execute
  175. 27:40and you see the gripper it's at position 50.
  176. 27:43To conclude this introduction to the robotic
  177. 27:46C++ library for adaptive grippers
  178. 27:50we are going to retrieve
  179. 27:52some piece of information from the gripper status. So we are going to retrieve the
  180. 27:57actual position of the gripper and display it in the terminal. So let's do that.
  181. 28:03So first
  182. 28:04we are going to
  183. 28:06retrieve the current position
  184. 28:08so let's create a variable current position
  185. 28:15so this will be equal to
  186. 28:20the gripper
  187. 28:22current position in this in the gripper status. So I'm retrieving the the status of the gripper
  188. 28:28with the gate status function and then from the status I'm going to
  189. 28:34retrieve the position byte. So if you go over position you will see that the the type of position
  190. 28:49the position parameter is a unsight int 8. Here I put auto for the
  191. 28:58for the type but I can specify precisely this type here
  192. 29:07u8
  193. 29:17unsight int
  194. 29:19coded on 8 bytes
  195. 29:22that's it. So I have the current position here and we are going to display it
  196. 29:26in the terminal using the stdout function like this. We are going to use the
  197. 29:55static cast function here to convert
  198. 30:02the unsight int variable into something we can actually print in the terminal.
  199. 30:20and here we are. So
  200. 30:23I'm going to change the position back to 100
  201. 30:30and execute. So the gripper move to position 100. I can see like the current position is 101.
  202. 30:44Okay, let's execute it again. I can see that now the position is 100.
  203. 30:53So this is how you retrieve information from the the status of the gripper.
  204. 31:02So we've completed the the this introduction to the robotics C++ library to control adaptive grippers.
  205. 31:11So as you see, so it goes like this. You create your connection.
  206. 31:19With the connection, you object, you create the gripper object.
  207. 31:24You activate the gripper and you feed some command to the gripper and retrieve status
  208. 31:31to control the gripper the way you want.
  209. 31:36So yeah, we send the command. We wait for the command to to be received.
  210. 31:42We wait for the command to be fully executed.
  211. 31:48Then we can retrieve other status like to check the current position,
  212. 31:54check if there is an object detected and so on.
  213. 31:57The C++ library is in continuous development.
  214. 32:02So you can expect to see in the future some more functions coming.
  215. 32:08Probably free function, a little bit like activate or retrieve from fault.
  216. 32:17So we probably will have a free function
  217. 32:21like move to to move the gripper to a given position.
  218. 32:24So stay tuned. Thank you.
Embed this video with its transcript

Paste this into your page. The frame holds the player and the transcript; the link below it says where the transcript comes from.

การสนทนา

คุณจะเลือกชื่อในขั้นตอนถัดไป เป็นสมาชิกอยู่แล้วใช่ไหม? เข้าสู่ระบบ

อีเมลแจ้งเมื่อมีคนแสดงความคิดเห็น ไม่ต้องมีบัญชี

จดหมายข่าว

Get our free newsletter with new robots, prices and robotics news.