Skip to content

Commit 0d919a5

Browse files
committed
push code
1 parent 2149bdb commit 0d919a5

File tree

7 files changed

+85
-25
lines changed

7 files changed

+85
-25
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"yview",
1717
"zhang"
1818
],
19-
"restructuredtext.confPath": ""
19+
"restructuredtext.confPath": "",
20+
"python.formatting.provider": "black"
2021
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog for pymycobot
22

3+
## v2.7.5 (2022-4-29)
4+
5+
- release v2.7.5
6+
- Fixed an issue where the M5 would restart when the serial port was initialized for the first time.
7+
- New interface: `get_tool_reference`,`set_tool_reference`,`set_world_reference`,`get_world_reference`,`set_reference_frame`,`get_reference_frame`,`set_movement_type`,`get_movement_type`,`set_end_type`,`get_end_type`,`get_plan_speed`,`get_plan_acceleration`,`set_plan_speed`,`set_plan_acceleration`,`get_servo_speeds`,`get_servo_currents`,`get_servo_voltages`,`get_servo_status`,`get_servo_temps`.
8+
39
## v2.7.4 (2021-12-15)
410

511
- release v2.7.4

demo/350servo_info.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# encoding=utf-8
2+
import matplotlib.pyplot as plt
3+
import matplotlib.font_manager as font_manager
4+
from pymycobot import MyCobot
5+
6+
mc = MyCobot("COM12", 115200)
7+
8+
POINTS = 7
9+
sin_list = [0] * (POINTS -1)
10+
indx = 0
11+
12+
fig, ax = plt.subplots()
13+
ax.set_ylim([0, 3250])
14+
ax.set_xlim([1, 6])
15+
ax.set_autoscale_on(False)
16+
ax.set_xticks(range(0, 3250, 500))
17+
ax.set_yticks(range(0, 11, 1))
18+
ax.grid(True)
19+
20+
line_sin, = ax.plot([i for i in range(1,POINTS)], sin_list, label='Current', color='cornflowerblue')
21+
ax.legend(loc='upper center', ncol=4, prop=font_manager.FontProperties(size=10))
22+
23+
def sin_output(ax):
24+
global sin_list, line_sin
25+
sin_list = sin_list[1:] + mc.get_servo_currents() # get current
26+
# print(sin_list)
27+
line_sin.set_ydata(sin_list)
28+
ax.draw_artist(line_sin)
29+
ax.figure.canvas.draw()
30+
31+
timer = fig.canvas.new_timer(interval=100)
32+
timer.add_callback(sin_output, ax)
33+
timer.start()
34+
plt.show()

pymycobot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"MyCobotSocket"
2121
]
2222

23-
__version__ = "2.7.4"
23+
__version__ = "2.7.5"
2424
__author__ = "Elephantrobotics"
2525
__email__ = "[email protected]"
2626
__git_url__ = "https://github.com/elephantrobotics/pymycobot"

pymycobot/common.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ def write(self, command, method=None):
261261
self.log.debug("_write: {}".format(command))
262262
self._serial_port.write(command)
263263
self._serial_port.flush()
264-
time.sleep(0.05)
265-
266264

267265
def read(self):
268266
time.sleep(0.1)

pymycobot/generate.py

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ def send_angle(self, id, degree, speed):
187187
"""Send one degree of joint to robot arm.
188188
189189
Args:
190-
id : Joint id(genre.Angle), int 1-6
190+
id : Joint id(genre.Angle)\n
191+
For mycobot: int 1-6.\n
192+
For mypalletizer: int 1-4.
191193
degree : degree value(float)(about -170 ~ 170).
192194
speed : (int) 0 ~ 100
193195
"""
@@ -199,9 +201,9 @@ def send_angles(self, degrees, speed):
199201
"""Send the degrees of all joints to robot arm.
200202
201203
Args:
202-
degrees : a list of degree values(List[float]), length 6.
203-
example for mycobot [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
204-
example for mypalletizer [0.0, 0.0, 0.0, 0.0]
204+
degrees: a list of degree values(List[float]), length 6 or 4.\n
205+
for mycobot: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0].\n
206+
for mypalletizer: [0.0, 0.0, 0.0, 0.0]
205207
speed : (int) 0 ~ 100
206208
"""
207209
self.calibration_parameters(degrees=degrees, speed=speed)
@@ -213,16 +215,18 @@ def get_coords(self):
213215
214216
Return:
215217
list : A float list of coord
216-
for mycobot -[x, y, z, rx, ry, rz],
217-
for mypalletizer -[x, y, z, θ]
218+
for mycobot: [x, y, z, rx, ry, rz]\n
219+
for mypalletizer: [x, y, z, θ]
218220
"""
219221
return self._mesg(ProtocolCode.GET_COORDS, has_reply=True)
220222

221223
def send_coord(self, id, coord, speed):
222224
"""Send one coord to robot arm.
223225
224226
Args:
225-
id(int) : coord id(genre.Coord), 1 ~ 6
227+
id(int) : coord id(genre.Coord)\n
228+
For mycobot: int 1-6.\n
229+
For mypalletizer: int 1-4.
226230
coord(float) : coord value, mm
227231
speed(int) : 0 ~ 100
228232
"""
@@ -234,9 +238,9 @@ def send_coords(self, coords, speed, mode):
234238
"""Send all coords to robot arm.
235239
236240
Args:
237-
coords: a list of coords value(List[float]), length 6.
238-
for mycobot :[x(mm), y, z, rx(angle), ry, rz]
239-
for mypalletizer: [x, y, z, θ]
241+
coords: a list of coords value(List[float]), length 6 or 4.
242+
for mycobot :[x(mm), y, z, rx(angle), ry, rz]\n
243+
for mypalletizer: [x, y, z, θ]
240244
speed : (int) 0 ~ 100
241245
mode : (int) 0 - angluar, 1 - linear
242246
"""
@@ -290,7 +294,9 @@ def jog_angle(self, joint_id, direction, speed):
290294
"""Jog control angle.
291295
292296
Args:
293-
joint_id: (int) 1 ~ 6.
297+
joint_id:
298+
For mycobot: int 1-6.\n
299+
For mypalletizer: int 1-4.
294300
direction: 0 - decrease, 1 - increase
295301
speed: int (0 - 100)
296302
"""
@@ -300,7 +306,9 @@ def jog_coord(self, coord_id, direction, speed):
300306
"""Jog control coord.
301307
302308
Args:
303-
coord_id: (int) 1 ~ 6
309+
coord_id:
310+
For mycobot: int 1-6.\n
311+
For mypalletizer: int 1-4.
304312
direction: 0 - decrease, 1 - increase
305313
speed: int (0 - 100)
306314
"""
@@ -493,17 +501,19 @@ def release_servo(self, servo_id):
493501
"""Power off designated servo
494502
495503
Args:
496-
for mycobot: servo_id: 1 - 6
497-
for mypalletizer: servo_id: 1 - 4
504+
servo_id:
505+
for mycobot: 1 - 6.\n
506+
for mypalletizer: 1 - 4
498507
"""
499508
return self._mesg(ProtocolCode.RELEASE_SERVO, servo_id)
500509

501510
def focus_servo(self, servo_id):
502511
"""Power on designated servo
503512
504513
Args:
505-
for mycobot: servo_id: 1 - 6
506-
for mypalletizer: servo_id: 1 - 4
514+
servo_id:
515+
for mycobot: 1 - 6\n
516+
for mypalletizer: 1 - 4
507517
"""
508518
return self._mesg(ProtocolCode.FOCUS_SERVO, servo_id)
509519

@@ -774,11 +784,17 @@ def get_servo_speeds(self):
774784
return self._mesg(ProtocolCode.GET_SERVO_SPEED, has_reply=True)
775785

776786
def get_servo_currents(self):
777-
"""Get joint current (Only for mycobot 350)"""
787+
"""Get joint current (Only for mycobot 350)
788+
789+
return: mA
790+
"""
778791
return self._mesg(ProtocolCode.GET_SERVO_CURRENTS, has_reply=True)
779792

780793
def get_servo_voltages(self):
781-
"""Get joint voltages (Only for mycobot 350)"""
794+
"""Get joint voltages (Only for mycobot 350)
795+
796+
return: volts
797+
"""
782798
return self._mesg(ProtocolCode.GET_SERVO_VOLTAGES, has_reply=True)
783799

784800
def get_servo_status(self):
@@ -793,7 +809,9 @@ def set_joint_max(self, id, angle):
793809
"""Set the joint maximum angle
794810
795811
Args:
796-
id: 1 - 6
812+
id:
813+
For mycobot: int 1-6.\n
814+
For mypalletizer: int 1-4.
797815
angle: 0 ~ 180
798816
"""
799817
return self._mesg(ProtocolCode.SET_JOINT_MAX, id, angle)
@@ -802,7 +820,9 @@ def set_joint_min(self, id, angle):
802820
"""Set the joint minimum angle
803821
804822
Args:
805-
id: 1 - 6
823+
id:
824+
For mycobot: int 1-6.\n
825+
For mypalletizer: int 1-4.
806826
angle: 0 ~ 180
807827
"""
808828
return self._mesg(ProtocolCode.SET_JOINT_MIN, id, angle)

pymycobot/mycobot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ def _mesg(self, genre, *args, **kwargs):
121121
return r
122122
else:
123123
return res
124-
124+
elif genre in [ProtocolCode.GET_SERVO_VOLTAGES]:
125+
return [self._int2coord(angle) for angle in res]
125126
else:
126127
return res
127128
return None

0 commit comments

Comments
 (0)