Skip to content

Commit 3df6e7c

Browse files
committed
修复python运动案例、更新关节限位信息
1 parent 0e433ed commit 3df6e7c

File tree

3 files changed

+235
-7
lines changed

3 files changed

+235
-7
lines changed

10-ApplicationBasePython/10.1_320_PI-ApplicationPython/2_API.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,23 @@ mc.send_angle(1, 40, 20)
170170
</tr>
171171
<tr>
172172
<td style="text-align: center;">1</td>
173-
<td>-170 ~ 170</td>
173+
<td>-168 ~ 168</td>
174174
</tr>
175175
<tr>
176176
<td style="text-align: center;">2</td>
177-
<td>-137 ~ 137</td>
177+
<td>-135 ~ 135</td>
178178
</tr>
179179
<tr>
180180
<td style="text-align: center;">3</td>
181-
<td>-151 ~ 142</td>
181+
<td>-145 ~ 145</td>
182182
</tr>
183183
<tr>
184184
<td style="text-align: center;">4</td>
185-
<td>-148 ~ 184</td>
185+
<td>-148 ~ 148</td>
186186
</tr>
187187
<tr>
188188
<td style="text-align: center;">5</td>
189-
<td>-169 ~ 169</td>
189+
<td>-168 ~ 168</td>
190190
</tr>
191191
<tr>
192192
<td style="text-align: center;">6</td>

10-ApplicationBasePython/10.1_320_PI-ApplicationPython/6_example.md

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,117 @@ mc.send_coord(1, 100, 70)
200200

201201
```
202202

203-
## 6 Controlling Gripper
203+
## 6 Control the robot arm to swing left and right
204+
205+
```python
206+
from pymycobot.mycobot320 import MyCobot320
207+
208+
import time
209+
# Initialize a MyCobot320 object
210+
211+
mc = MyCobot320("/dev/ttyAMA0", 115200)
212+
# Get the coordinates of the current position
213+
angle_datas = mc.get_angles()
214+
print(angle_datas)
215+
216+
# Use a sequence to pass the coordinate parameters and let the robot move to the specified position
217+
mc.send_angles([0, 0, 0, 0, 0, 0], 50)
218+
print(mc.is_paused())
219+
# Set the waiting time to ensure that the robot has reached the specified position
220+
# while not mc.is_paused():
221+
time.sleep(2.5)
222+
223+
# Move joint 1 to the position of 90
224+
mc.send_angle(1, 90, 50)
225+
226+
# Set the waiting time to ensure that the robot has reached the specified position
227+
time.sleep(2)
228+
229+
# Set the number of loops
230+
num = 5
231+
232+
# Let the robot swing left and right
233+
while num > 0:
234+
# Move joint 2 to position 50
235+
mc.send_angle(2, 50, 50)
236+
# Set the waiting time to ensure that the robot has reached the specified position
237+
time.sleep(1.5)
238+
# Move joint 2 to position -50
239+
mc.send_angle(2, -50, 50)
240+
# Set the waiting time to ensure that the robot has reached the specified position
241+
time.sleep(1.5)
242+
num -= 1
243+
# Retract the robot. You can manually swing the robot, and then use the get_angles() function to get the coordinate sequence,
244+
# Use this function to make the robot reach the position you want.
245+
mc.send_angles([88.68, -135, 145, -128.05, -9.93, -15.29], 50)
246+
247+
# Set the waiting time to ensure that the robot arm has reached the specified position
248+
time.sleep(2.5)
249+
# Let the robot arm relax and you can swing it manually
250+
mc.release_all_servos()
251+
```
252+
253+
<video id="my-video" class="video-js" controls preload="auto" width="100%"
254+
poster="" data-setup='{"aspectRatio":"16:9"}'>
255+
256+
<source src="../../resources/10-ApplicationBasePython/myArm/2.5python控制机械臂左右摆动01.mp4"></video>
257+
258+
## 7 Controlling the robotic arm to dance
259+
260+
```python
261+
from pymycobot.mycobot320 import MyCobot320
262+
import time
263+
264+
if __name__ == '__main__':
265+
# MyCobot320 class initialization requires two parameters:
266+
# The first is the serial port string:"/dev/ttyAMA0"
267+
# The second is the baud rate: 115200
268+
#
269+
# Example:
270+
# mc = MyCobot320("/dev/ttyAMA0", 115200)
271+
272+
273+
# Initialize a MyCobot320 object
274+
mc = MyCobot320("/dev/ttyAMA0",115200)
275+
276+
# Set the start time
277+
start = time.time()
278+
# Let the robot reach the specified position
279+
mc.send_angles([-1.49, 115, -145, 30, -33.42, 137.9], 80)
280+
# Determine whether it has reached the specified position
281+
while not mc.is_in_position([-1.49, 115, -145, 30, -33.42, 137.9], 0):
282+
# Let the robot resume movement
283+
mc.resume()
284+
# Let the robot move for 0.5s
285+
time.sleep(0.5)
286+
# Pause the movement of the robot
287+
mc.pause()
288+
# Determine whether the movement has timed out
289+
if time.time() - start > 3:
290+
break
291+
# Set the start time
292+
start = time.time()
293+
# Let the exercise last for 30 seconds
294+
while time.time() - start < 30:
295+
# Let the robot quickly reach this position
296+
mc.send_angles([-1.49, 115, -145, 30, -33.42, 137.9], 80)
297+
# Set the color of the light to [0,0,50]
298+
mc.set_color(0, 0, 50)
299+
time.sleep(0.7)
300+
# Let the robot quickly reach this position
301+
mc.send_angles([-1.49, 55, -145, 80, 33.42, 137.9], 80)
302+
# Set the color of the light to [0,50,0]
303+
mc.set_color(0, 50, 0)
304+
time.sleep(0.7)
305+
```
306+
307+
<video id="my-video" class="video-js" controls preload="auto" width="100%"
308+
poster="" data-setup='{"aspectRatio":"16:9"}'>
309+
310+
<source src="../../resources/10-ApplicationBasePython/myArm/2.6控制机械臂跳舞01.mp4"></video>
311+
312+
313+
## 8 Controlling Gripper
204314

205315
```python
206316
from pymycobot.mycobot320 import MyCobot320

10-ApplicationBasePython/10.2_320_M5-ApplicationPython/5_example.md

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,125 @@ mc.send_coord(Coord.X.value, 100, 70)
214214

215215
```
216216

217-
## 6 Controlling Gripper
217+
## 6 Control the robot arm to swing left and right
218+
219+
```python
220+
from pymycobot.mycobot320 import MyCobot320
221+
222+
import time
223+
# Initialize a MyCobot320 object
224+
225+
# M5 version
226+
mc = MyCobot320("COM3", 115200)
227+
# Get the coordinates of the current position
228+
angle_datas = mc.get_angles()
229+
print(angle_datas)
230+
231+
# Use a sequence to pass the coordinate parameters and let the robot move to the specified position
232+
mc.send_angles([0, 0, 0, 0, 0, 0], 50)
233+
print(mc.is_paused())
234+
# Set the waiting time to ensure that the robot has reached the specified position
235+
# while not mc.is_paused():
236+
time.sleep(2.5)
237+
238+
# Move joint 1 to the position of 90
239+
mc.send_angle(1, 90, 50)
240+
241+
# Set the waiting time to ensure that the robot has reached the specified position
242+
time.sleep(2)
243+
244+
# Set the number of loops
245+
num = 5
246+
247+
# Let the robot swing left and right
248+
while num > 0:
249+
# Move joint 2 to position 50
250+
mc.send_angle(2, 50, 50)
251+
# Set the waiting time to ensure that the robot has reached the specified position
252+
time.sleep(1.5)
253+
# Move joint 2 to position -50
254+
mc.send_angle(2, -50, 50)
255+
# Set the waiting time to ensure that the robot has reached the specified position
256+
time.sleep(1.5)
257+
num -= 1
258+
# Retract the robot. You can manually swing the robot, and then use the get_angles() function to get the coordinate sequence,
259+
# Use this function to make the robot reach the position you want.
260+
mc.send_angles([88.68, -135, 145, -128.05, -9.93, -15.29], 50)
261+
262+
# Set the waiting time to ensure that the robot arm has reached the specified position
263+
time.sleep(2.5)
264+
# Let the robot arm relax and you can swing it manually
265+
mc.release_all_servos()
266+
```
267+
268+
<video id="my-video" class="video-js" controls preload="auto" width="100%"
269+
poster="" data-setup='{"aspectRatio":"16:9"}'>
270+
271+
<source src="../../resources/10-ApplicationBasePython/myArm/2.5python控制机械臂左右摆动01.mp4"></video>
272+
273+
## 7 Controlling the robotic arm to dance
274+
275+
```python
276+
from pymycobot.mycobot320 import MyCobot320
277+
import time
278+
279+
if __name__ == '__main__':
280+
# MyCobot320 class initialization requires two parameters:
281+
# The first is the serial port string, such as:
282+
# Linux: "/dev/ttyUSB0"
283+
# Windows: "COM3"
284+
# The second is the baud rate:
285+
# M5 version: 115200
286+
287+
# Example:
288+
# mycobot-M5:
289+
# Linux:
290+
# mc = MyCobot320("/dev/ttyUSB0", 115200)
291+
# Windows:
292+
# mc = MyCobot320("COM3", 115200)
293+
294+
# Initialize a MyCobot320 object
295+
# M5 version
296+
mc = MyCobot320("COM3",115200)
297+
298+
# Set the start time
299+
start = time.time()
300+
# Let the robot reach the specified position
301+
mc.send_angles([-1.49, 115, -145, 30, -33.42, 137.9], 80)
302+
# Determine whether it has reached the specified position
303+
while not mc.is_in_position([-1.49, 115, -145, 30, -33.42, 137.9], 0):
304+
# Let the robot resume movement
305+
mc.resume()
306+
# Let the robot move for 0.5s
307+
time.sleep(0.5)
308+
# Pause the movement of the robot
309+
mc.pause()
310+
# Determine whether the movement has timed out
311+
if time.time() - start > 3:
312+
break
313+
# Set the start time
314+
start = time.time()
315+
# Let the exercise last for 30 seconds
316+
while time.time() - start < 30:
317+
# Let the robot quickly reach this position
318+
mc.send_angles([-1.49, 115, -145, 30, -33.42, 137.9], 80)
319+
# Set the color of the light to [0,0,50]
320+
mc.set_color(0, 0, 50)
321+
time.sleep(0.7)
322+
# Let the robot quickly reach this position
323+
mc.send_angles([-1.49, 55, -145, 80, 33.42, 137.9], 80)
324+
# Set the color of the light to [0,50,0]
325+
mc.set_color(0, 50, 0)
326+
time.sleep(0.7)
327+
```
328+
329+
<video id="my-video" class="video-js" controls preload="auto" width="100%"
330+
poster="" data-setup='{"aspectRatio":"16:9"}'>
331+
332+
<source src="../../resources/10-ApplicationBasePython/myArm/2.6控制机械臂跳舞01.mp4"></video>
333+
334+
335+
## 8 Controlling Gripper
218336

219337
```python
220338
from pymycobot.mycobot320 import MyCobot320

0 commit comments

Comments
 (0)