Skip to content

Commit 62aa3d1

Browse files
committed
2 parents f5dbcb8 + bfc487a commit 62aa3d1

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

pymycobot/elephantrobot.py

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def string_to_coords(self, data):
5656
coords_4 = float(data_arr[3])
5757
coords_5 = float(data_arr[4])
5858
coords_6 = float(data_arr[5])
59-
coords = [coords_1, coords_2, coords_3, coords_4, coords_5, coords_6]
59+
coords = [coords_1, coords_2, coords_3,
60+
coords_4, coords_5, coords_6]
6061
return coords
6162
except:
6263
return self.invalid_coords()
@@ -215,13 +216,15 @@ def task_stop(self):
215216

216217
def jog_angle(self, joint_str, direction, speed):
217218
command = (
218-
"jog_angle(" + joint_str + "," + str(direction) + "," + str(speed) + ")\n"
219+
"jog_angle(" + joint_str + "," + str(direction) +
220+
"," + str(speed) + ")\n"
219221
)
220222
self.send_command(command)
221223

222224
def jog_coord(self, axis_str, direction, speed):
223225
command = (
224-
"jog_coord(" + axis_str + "," + str(direction) + "," + str(speed) + ")\n"
226+
"jog_coord(" + axis_str + "," + str(direction) +
227+
"," + str(speed) + ")\n"
225228
)
226229
self.send_command(command)
227230

@@ -278,7 +281,45 @@ def get_variable(self, var_name):
278281
return self.send_command(command)
279282

280283
def jog_relative(self, joint_id, angle, speed):
281-
command = 'SendJogIncrement("{}","{}","{}")\n'.format(joint_id, angle, speed)
284+
command = 'SendJogIncrement("{}","{}","{}")\n'.format(
285+
joint_id, angle, speed)
286+
return self.send_command(command)
287+
288+
def set_init_gripper(self, gripper_type):
289+
"""
290+
gripper_type:CAG-1
291+
"""
292+
command = "set_init_gripper(" + str(gripper_type) + ")\n"
293+
return self.send_command(command)
294+
295+
def set_cag_gripper_mode(self, mode):
296+
"""
297+
mode:0 / 1
298+
"""
299+
300+
command = "set_cag_gripper_mode("+str(mode) + ")\n"
301+
return self.send_command(command)
302+
303+
def set_cag_gripper_value(self, value, speed):
304+
"""
305+
value: 0-100
306+
speed: 1-100
307+
"""
308+
command = "set_cag_gripper_value( " + \
309+
str(value) + ',' + str(speed) + " )\n"
310+
return self.send_command(command)
311+
312+
def get_cag_gripper_value(self):
313+
command = "get_cag_gripper_value()\n"
314+
return self.send_command(command)
315+
316+
def set_cag_gripper_enabled(self, mode):
317+
"""
318+
mode:
319+
0: unabled
320+
1: enabled
321+
"""
322+
command = "set_cag_gripper_enabled(" + str(mode) + ")\n"
282323
return self.send_command(command)
283324

284325

@@ -324,6 +365,25 @@ def jog_relative(self, joint_id, angle, speed):
324365
print(ep.assign_variable("ss", '"eee"'))
325366
print(ep.get_joint_current(1))
326367

368+
print(ep.set_init_gripper("CAG-1"))
369+
print(ep.wait(2))
370+
print(ep.set_cag_gripper_mode(1))
371+
print(ep.set_cag_gripper_mode(0))
372+
373+
print(ep.set_cag_gripper_value(100, 20))
374+
print(ep.wait(2))
375+
print(ep.get_cag_gripper_value())
376+
print(ep.set_cag_gripper_value(50, 20))
377+
print(ep.wait(2))
378+
print(ep.get_cag_gripper_value())
379+
print(ep.set_cag_gripper_value(0, 20))
380+
print(ep.wait(2))
381+
print(ep.get_cag_gripper_value())
382+
383+
print(ep.set_cag_gripper_enabled(1))
384+
print(ep.wait(2))
385+
print(ep.set_cag_gripper_enabled(0))
386+
327387
ep.stop_client()
328388

329389
name = input("input:")

0 commit comments

Comments
 (0)