Skip to content

Commit 9871621

Browse files
Zachary ZhangZachary Zhang
authored andcommitted
Merge remote-tracking branch 'origin/pythonAPI' into main
2 parents 9623b03 + 2ae5088 commit 9871621

File tree

8 files changed

+564
-38
lines changed

8 files changed

+564
-38
lines changed

API/Python/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ cd <your-path>/myCobot/API/Python
1010
python3 setup install
1111
```
1212

13+
**_`example/test.py` is a test file, you can find out which interfaces pymycobot provides in `pymycobot/README.md`._**
14+
15+
**Notes**:
16+
17+
<!-- This is the mycobot Python API package designed by Zhang Lijun([[email protected]]()) -->
18+
19+
> Make sure that `Atom2.3` is flashed into the top Atom <br> > `Transponder` is flashed into the base Basic <br>
20+
> The firmware `Atom2.3` and `Transponder` download address: [https://github.com/elephantrobotics/myCobot/tree/main/Software](https://github.com/elephantrobotics/myCobot/tree/main/Software)<br>
21+
> Python 2: use mycobot.py <br>
22+
> Python 3: use mycobot3.py
23+
24+
-

API/Python/pymycobot/README.md

Lines changed: 368 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,368 @@
1+
# ros-python-api
2+
3+
**This is python API for mycobot.**
4+
5+
We support Python2, Python3.5 or later. If you want to use the api, make sure `pyserial` is installed.
6+
7+
```bash
8+
pip2 install pyserial
9+
# or
10+
pip3 install pyserial
11+
```
12+
13+
**Class**:
14+
15+
- [MyCobot](##MyCobot)
16+
- [Angle](##Angle)
17+
- [Coord](##Coord)
18+
19+
## MyCobot
20+
21+
### MyCobot.power_on()
22+
23+
- **Description**
24+
25+
Robot arm power up.
26+
27+
- **Parameters**
28+
29+
None
30+
31+
- **Returns**
32+
33+
None
34+
35+
### MyCobot.power_off()
36+
37+
- **Description**
38+
39+
Robot arm power down.
40+
41+
- **Parameters**
42+
43+
None
44+
45+
- **Returns**
46+
47+
None
48+
49+
### MyCobot.set_free_mode()
50+
51+
- **Description**
52+
53+
Robot arm into free moving mode.
54+
55+
- **Parameters**
56+
57+
None
58+
59+
- **Returns**
60+
61+
None
62+
63+
### MyCobot.get_angles()
64+
65+
- **Description**
66+
67+
Get the degree of all joints.
68+
69+
- **Parameters**
70+
71+
None
72+
73+
- **Returns**
74+
75+
A float list of degree.
76+
77+
### MyCobot.get_angles_by_radian()
78+
79+
- **Description**
80+
81+
Get the radians of all joints.
82+
83+
- **Parameters**
84+
85+
None
86+
87+
- **Returns**
88+
89+
A float list of radian.
90+
91+
### MyCobot.send_angle()
92+
93+
- **Description**
94+
95+
Send one degree of joint to robot arm.
96+
97+
- **Parameters**
98+
99+
id: Joint id(common.Angle)
100+
101+
degree: degree value(float)
102+
103+
speed: (int)
104+
105+
- **Returns**
106+
107+
None
108+
109+
- **Example**
110+
111+
```python
112+
from pymycobot.mycobot import MyCobot
113+
from pymycobot.common import Angle
114+
115+
116+
mycobot = MyCobot('/dev/ttyUSB0')
117+
mycobot.send_angle(Angle.J2.value, 10, 50)
118+
```
119+
120+
### MyCobot.send_angles()
121+
122+
- **Description**
123+
124+
Send the degrees of all joints to robot arm.
125+
126+
- **Parameters**
127+
128+
degrees: a list of degree value(List[float])
129+
130+
speed: (int)
131+
132+
- **Returns**
133+
134+
None
135+
136+
- **Example**
137+
138+
```python
139+
from pymycobot.mycobot import MyCobot
140+
from pymycobot.common import Angle
141+
142+
143+
mycobot = MyCobot('/dev/ttyUSB0')
144+
mycobot.send_angles([0,0,0,0,0,0], 80)
145+
```
146+
147+
### MyCobot.send_angles_by_radian()
148+
149+
- **Description**
150+
151+
Send the radians of all joint to robot arm.
152+
153+
- **Parameters**
154+
155+
degrees: a list of radian value(List[float])
156+
157+
speed: (int)
158+
159+
- **Returns**
160+
161+
None
162+
163+
- **Example**
164+
165+
```python
166+
from pymycobot.mycobot import MyCobot
167+
from pymycobot.common import Angle
168+
169+
170+
mycobot = MyCobot('/dev/ttyUSB0')
171+
mycobot.send_angles_by_radian([1,1,1,1,1,1], 70)
172+
```
173+
174+
### MyCobot.get_coords()
175+
176+
- **Description**
177+
178+
Get the Coords from robot arm.
179+
180+
- **Parameters**
181+
182+
None
183+
184+
- **Returns**
185+
186+
A float list of coord.
187+
188+
### MyCobot.send_coord()
189+
190+
- **Description**
191+
192+
Send one coord to robot arm.
193+
194+
- **Parameters**
195+
196+
id: coord name(common.Coord)
197+
198+
coord: coord value(float)
199+
200+
speed: (int)
201+
202+
- **Returns**
203+
204+
None
205+
206+
- **Example**
207+
208+
```python
209+
from pymycobot.mycobot import MyCobot
210+
from pymycobot.common import Coord
211+
212+
213+
mycobot = MyCobot('/dev/ttyUSB0')
214+
mycobot.send_coord(Coord.X.value, -40, 70)
215+
```
216+
217+
### MyCobot.send_coords()
218+
219+
- **Description**
220+
221+
Send all coords to robot arm.
222+
223+
- **Parameters**
224+
225+
coords: a list of coords value(List[float])
226+
227+
speed: (int)
228+
229+
- **Returns**
230+
231+
None
232+
233+
- **Example**
234+
235+
```python
236+
from pymycobot.mycobot import MyCobot
237+
from pymycobot.common import Coord
238+
239+
240+
mycobot = MyCobot('/dev/ttyUSB0')
241+
mycobot.send_coords([160, 160, 160, 0, 0, 0], 70, 0)
242+
```
243+
244+
### MyCobot.set_color()
245+
246+
- **Description**
247+
248+
Set the color of the light on the top of the robot arm.
249+
250+
- **Parameters**
251+
252+
rgb: (string) like: "FF0000"
253+
254+
- **Returns**
255+
256+
None
257+
258+
### MyCobot.is_moving()
259+
260+
- **Description**
261+
262+
Judge whether the manipulator is moving or not.
263+
264+
- **Parameters**
265+
266+
None
267+
268+
- **Returns**
269+
270+
bool: `True` - moving, `False` - not moving.
271+
272+
### MyCobot.pause()
273+
274+
- **Description**
275+
276+
Pause movement.
277+
278+
- **Parameters**
279+
280+
None
281+
282+
- **Returns**
283+
284+
None
285+
286+
### MyCobot.resume()
287+
288+
- **Description**
289+
290+
Recovery movement.
291+
292+
- **Parameters**
293+
294+
None
295+
296+
- **Returns**
297+
298+
None
299+
300+
### MyCobot.stop()
301+
302+
- **Description**
303+
304+
Stop moving.
305+
306+
- **Parameters**
307+
308+
None
309+
310+
- **Returns**
311+
312+
None
313+
314+
### MyCobot.is_pause()
315+
316+
- **Description**
317+
318+
Judge whether the manipulator pauses or not.
319+
320+
- **Parameters**
321+
322+
None
323+
324+
- **Returns**
325+
326+
bool: `True` - pause, `False` - not pause.
327+
328+
### MyCobot.get_speed()
329+
330+
- **Description**
331+
332+
Get speed.
333+
334+
- **Parameters**
335+
336+
None
337+
338+
- **Returns**
339+
340+
speed: (int)
341+
342+
### MyCobot.set_speed()
343+
344+
- **Description**
345+
346+
Set speed.
347+
348+
- **Parameters**
349+
350+
speed: (int)
351+
352+
- **Returns**
353+
354+
None
355+
356+
## Angle
357+
358+
**Description**
359+
360+
Instance class of joint. It's recommended to use this class to select joint.
361+
362+
## Coord
363+
364+
**Description**
365+
366+
Instance class of coord. It's recommended to use this class to select coord.
367+
368+
---

API/Python/pymycobot/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import absolute_import
22

3-
__all__ = ['mycobot', 'common']
3+
__all__ = ['mycobot', 'mycobot3', 'common']
44

5+
#

0 commit comments

Comments
 (0)