Skip to content

Commit ad2536a

Browse files
committed
add new api.
1 parent 864a5e3 commit ad2536a

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

pymycobot/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Command(object):
4040
SET_ENCODER = 0x3A
4141
GET_ENCODER = 0x3B
4242
SET_ENCODERS = 0x3C
43+
GET_ENCODERS = 0x3D
4344

4445
# RUNNING STATUS AND SETTINGS
4546
GET_SPEED = 0x40
@@ -73,6 +74,7 @@ class Command(object):
7374

7475
# Basic
7576
SET_BASIC_OUTPUT = 0xA0
77+
GET_BASIC_OUTPUT = 0xA1
7678

7779

7880
class DataProcessor(object):

pymycobot/generate.py

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ class MycobotCommandGenerater(DataProcessor):
2525
send_angles()
2626
get_coords()
2727
send_coords()
28-
pause()
29-
resume()
30-
stop()
31-
is_paused()
3228
is_in_position()
3329
is_moving() x
3430
@@ -39,8 +35,16 @@ class MycobotCommandGenerater(DataProcessor):
3935
set_encoder()
4036
get_encoder()
4137
set_encoders()
38+
pause()
39+
resume()
40+
stop()
41+
is_paused()
4242
4343
# Running status and Settings
44+
get_encoder()
45+
set_encoder()
46+
get_encoders()
47+
set_encoders()
4448
get_speed()
4549
set_speed() *
4650
get_joint_min_angle()
@@ -70,7 +74,8 @@ class MycobotCommandGenerater(DataProcessor):
7074
is_gripper_moving()
7175
7276
# Basic
73-
set_basic_output() *
77+
set_basic_output()
78+
get_basic_input()
7479
"""
7580

7681
def __init__(self, debug=False):
@@ -228,18 +233,6 @@ def send_coords(self, coords, speed, mode):
228233
coord_list.append(self._angle_to_int(coords[idx]))
229234
return self._mesg(Command.SEND_COORDS, coord_list, speed, mode)
230235

231-
def pause(self):
232-
return self._mesg(Command.PAUSE)
233-
234-
def is_paused(self):
235-
return self._mesg(Command.IS_PAUSED, has_reply=True)
236-
237-
def resume(self):
238-
return self._mesg(Command.RESUME)
239-
240-
def stop(self):
241-
return self._mesg(Command.STOP)
242-
243236
def is_in_position(self, data, id):
244237
"""
245238
@@ -299,6 +292,18 @@ def jog_coord(self, coord_id, direction, speed):
299292
def jog_stop(self):
300293
return self._mesg(Command.JOG_STOP)
301294

295+
def pause(self):
296+
return self._mesg(Command.PAUSE)
297+
298+
def is_paused(self):
299+
return self._mesg(Command.IS_PAUSED, has_reply=True)
300+
301+
def resume(self):
302+
return self._mesg(Command.RESUME)
303+
304+
def stop(self):
305+
return self._mesg(Command.STOP)
306+
302307
def set_encoder(self, joint_id, encoder):
303308
"""Set joint encoder value.
304309
@@ -314,6 +319,9 @@ def get_encoder(self, joint_id):
314319
def set_encoders(self, encoders, sp):
315320
return self._mesg(Command.SET_ENCODERS, encoders, sp)
316321

322+
def set_encoders(self):
323+
return self._mesg(Command.GET_ENCODERS, has_reply=True)
324+
317325
# Running status and Settings
318326
def get_speed(self):
319327
return self._mesg(Command.GET_SPEED, has_reply=True)
@@ -466,6 +474,15 @@ def set_basic_output(self, pin_no, pin_signal):
466474
"""Set basic output for M5 version.
467475
468476
Args:
477+
pin_no: pin port number.
469478
pin_signal: 0 / 1
470479
"""
471480
return self._mesg(Command.SET_BASIC_OUTPUT, pin_no, pin_signal)
481+
482+
def get_basic_input(self, pin_no):
483+
"""Get basic input for M5 version.
484+
485+
Args:
486+
pin_no: pin port number.
487+
"""
488+
return self._mesg(Command.GET_BASIC_OUTPUT, pin_no, has_reply=True)

0 commit comments

Comments
 (0)