Skip to content

Commit 09847e0

Browse files
committed
fix bug
1 parent b4b771a commit 09847e0

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

pymycobot/error.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def check_coords(value, robot_limit, class_name, exception_class):
6060
for idx, coord in enumerate(value):
6161
if not robot_limit[class_name]["coords_min"][idx] <= coord <= robot_limit[class_name]["coords_max"][idx]:
6262
raise exception_class(
63-
"Has invalid coord value, error on index {0}. angle should be {1} ~ {2}.".format(
64-
idx, robot_limit[class_name]["coords_min"][idx], robot_limit[class_name]["coords_max"][idx]
63+
"Has invalid coord value, error on index {0}. received {3} .but angle should be {1} ~ {2}.".format(
64+
idx, robot_limit[class_name]["coords_min"][idx], robot_limit[class_name]["coords_max"][idx], coord
6565
)
6666
)
6767

@@ -132,11 +132,11 @@ def public_check(parameter_list, kwargs, robot_limit, class_name, exception_clas
132132
)
133133
elif parameter == 'angle':
134134
id = kwargs.get('id', None)
135-
index = robot_limit[class_name]['id'][id-1]
136-
if index < robot_limit[class_name]["angles_min"][index] or index > robot_limit[class_name]["angles_max"][index]:
135+
index = robot_limit[class_name]['id'][id-1] - 1
136+
if value < robot_limit[class_name]["angles_min"][index] or value > robot_limit[class_name]["angles_max"][index]:
137137
raise exception_class(
138138
"angle value not right, should be {0} ~ {1}, but received {2}".format(
139-
robot_limit[class_name]["angles_min"], robot_limit[class_name]["angles_max"][index], value
139+
robot_limit[class_name]["angles_min"][index], robot_limit[class_name]["angles_max"][index], value
140140
)
141141
)
142142
elif parameter == 'encoders':
@@ -193,11 +193,11 @@ def calibration_parameters(**kwargs):
193193
check_id(value, robot_limit[class_name][parameter], CobotXDataException)
194194
elif parameter == 'angle':
195195
id = kwargs.get('id', None)
196-
index = robot_limit[class_name]['id'][id-1]
197-
if index < robot_limit[class_name]["angles_min"][index] or index > robot_limit[class_name]["angles_max"][index]:
196+
index = robot_limit[class_name]['id'][id-1] - 1
197+
if value < robot_limit[class_name]["angles_min"][index] or value > robot_limit[class_name]["angles_max"][index]:
198198
raise CobotXDataException(
199199
"angle value not right, should be {0} ~ {1}, but received {2}".format(
200-
robot_limit[class_name]["angles_min"], robot_limit[class_name]["angles_max"][index], value
200+
robot_limit[class_name]["angles_min"][index], robot_limit[class_name]["angles_max"][index], value
201201
)
202202
)
203203
# elif parameter == 'angles':
@@ -212,11 +212,12 @@ def calibration_parameters(**kwargs):
212212
# )
213213

214214
elif parameter == 'coord':
215-
index = robot_limit[class_name][kwargs.get('id', None)-1]
216-
if index < robot_limit[class_name]["coords_min"][index] or index > robot_limit[class_name]["coords_max"][index]:
215+
216+
index = kwargs.get('id', None) - 1
217+
if value < robot_limit[class_name]["coords_min"][index] or value > robot_limit[class_name]["coords_max"][index]:
217218
raise CobotXDataException(
218219
"coord value not right, should be {0} ~ {1}, but received {2}".format(
219-
robot_limit[class_name]["coords_min"], robot_limit[class_name]["coords_max"][index], value
220+
robot_limit[class_name]["coords_min"][index], robot_limit[class_name]["coords_max"][index], value
220221
)
221222
)
222223
elif parameter == 'coords':

pymycobot/robot_limit.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"id":[1,2,3,4,5,6,7,11,12,13],
44
"angles_min":[-165, -100, -165, -175, -165, -1, -165],
55
"angles_max":[165, 100, 165, 1, 165, 215, 165],
6-
"coords_min":[-466, -466, -290, -179, -179, -179],
7-
"coords_max":[466, 466, 641, 179, 179, 179]
6+
"coords_min":[-466, -466, -290, -180, -180, -180],
7+
"coords_max":[466, 466, 641, 180, 180, 180]
88
},
99
"CobotXSocket":{
1010
"id":[1,2,3,4,5,6,7,11,12,13],
1111
"angles_min":[-165, -100, -165, -175, -165, -1, -165],
1212
"angles_max":[165, 100, 165, 1, 165, 215, 165],
13-
"coords_min":[-466, -466, -290, -179, -179, -179],
14-
"coords_max":[466, 466, 641, 179, 179, 179]
13+
"coords_min":[-466, -466, -290, -180, -180, -180],
14+
"coords_max":[466, 466, 641, 180, 180, 180]
1515
},
1616
"MyCobot":{
1717
"id":[1,2,3,4,5,6],

0 commit comments

Comments
 (0)