Skip to content

Commit d616ea3

Browse files
committed
fix: bug, imporve compatibility.
1 parent b52a807 commit d616ea3

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2021.3.29
2+
3+
- release v2.3.1
4+
- fix error bug
5+
- add new method `set_encoder`, `get_encoder`, `set_encoders`
6+
17
# 2021.3.26
28

39
- release **v2.3**

pymycobot/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class Command():
3333
JOG_ANGLE = 0x30
3434
JOG_COORD = 0x32
3535
JOG_STOP = 0x34
36+
SET_ENCODER = 0x3a
37+
GET_ENCODER = 0x3b
38+
SET_ENCODERS = 0x3c
3639

3740
# RUNNING STATUS AND SETTINGS
3841
GET_SPEED = 0x40
@@ -98,7 +101,7 @@ def _process_data_command(self, args):
98101
return []
99102

100103
return self._flatten([
101-
[self._encode_int16(i) for i in x]
104+
[self._encode_int16(int(i)) for i in x]
102105
if isinstance(x, list) else x
103106
for x in args])
104107

pymycobot/error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def check_id(id):
8888

8989

9090
def check_angle(v):
91-
if not check_range(id, [-180, 180]):
91+
if not check_range(v, [-180, 180]):
9292
raise MyCobotDataException(
9393
'angle value not right, should be -180 ~ 180')
9494

@@ -104,7 +104,7 @@ def check_coord(id, v):
104104
if id < 3:
105105
pass
106106
else:
107-
if not check_range(id, [-180, 180]):
107+
if not check_range(v, [-180, 180]):
108108
raise MyCobotDataException(
109109
'{} value not right, should be -180 ~ 180'.format(coords[id]))
110110

pymycobot/mycobot.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class MyCobot(MyCobotData):
3939
jog_angle()
4040
jog_coord()
4141
jog_stop()
42+
set_encoder()
43+
get_encoder()
44+
set_encoders()
4245
4346
# Running status and Settings
4447
get_speed()
@@ -395,6 +398,15 @@ def jog_coord(self, coord_id, direction, speed):
395398
def jog_stop(self):
396399
self.__mesg(Command.JOG_STOP)
397400

401+
def set_encoder(self, joint_id, encoder):
402+
self.__mesg(Command.SET_ENCODER, joint_id, [encoder])
403+
404+
def get_encoder(self, joint_id):
405+
return self.__mesg(Command.GET_ENCODER, joint_id, has_reply=True)
406+
407+
def set_encoders(self, encoders, sp):
408+
self.__mesg(Command.SET_ENCODERS, encoders, sp)
409+
398410
# Running status and Settings
399411
def get_speed(self):
400412
return self._process_single(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22

3-
VERSION = "2.3"
3+
VERSION = "2.3.2"
44

55
PYTHON_VERSION = sys.version_info[:2]
66
if (2, 7) != PYTHON_VERSION < (3, 5):

0 commit comments

Comments
 (0)