Skip to content

Commit 98d8ba7

Browse files
committed
refactor: modify api README.
* Rename _process_bool() -> _process_single() * Fix spelling mistakes.
1 parent a100a73 commit 98d8ba7

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

pymycobot/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ from pymycobot.mycobot import MyCobot
4848

4949
- **Description**
5050

51-
Adjust robot arm wether power on.
51+
Adjust robot arm whether power on.
5252

5353
- **Returns**
5454

55-
- 1: power on
56-
- 0: power off
57-
- -1: error
55+
- `1`: power on
56+
- `0`: power off
57+
- `-1`: error
5858

5959
### set_free_mode()
6060

@@ -82,11 +82,11 @@ from pymycobot.mycobot import MyCobot
8282

8383
- **Parameters**
8484

85-
id: Joint id(common.Angle)
85+
id: Joint id(`genre.Angle`)
8686

87-
degree: degree value(float)
87+
degree: degree value(`float`)
8888

89-
speed: (int)
89+
speed: (`int`)
9090

9191
- **Example**
9292

@@ -107,9 +107,9 @@ from pymycobot.mycobot import MyCobot
107107

108108
- **Parameters**
109109

110-
degrees: a list of degree value(List[float])
110+
degrees: a list of degree value(`List[float]`)
111111

112-
speed: (int)
112+
speed: (`int`)
113113

114114
- **Example**
115115

@@ -140,9 +140,9 @@ from pymycobot.mycobot import MyCobot
140140

141141
- **Parameters**
142142

143-
degrees: a list of radian value(List[float])
143+
degrees: a list of radian value(`List[float]`)
144144

145-
speed: (int)
145+
speed: (`int`)
146146

147147
- **Example**
148148

@@ -173,11 +173,11 @@ from pymycobot.mycobot import MyCobot
173173

174174
- **Parameters**
175175

176-
id: coord name(common.Coord)
176+
id: coord id(`genre.Coord`)
177177

178-
coord: coord value(float)
178+
coord: coord value(`float`)
179179

180-
speed: (int)
180+
speed: (`int`)
181181

182182
- **Example**
183183

@@ -198,9 +198,9 @@ from pymycobot.mycobot import MyCobot
198198

199199
- **Parameters**
200200

201-
coords: a list of coords value(List[float])
201+
coords: a list of coords value(`List[float]`)
202202

203-
speed: (int)
203+
speed: (`int`)
204204

205205
- **Example**
206206

@@ -239,7 +239,7 @@ from pymycobot.mycobot import MyCobot
239239

240240
- **Returns**
241241

242-
bool:
242+
`bool`:
243243

244244
- `1` - paused
245245
- `0` - not paused
@@ -253,7 +253,7 @@ from pymycobot.mycobot import MyCobot
253253

254254
- **Returns**
255255

256-
bool:
256+
`bool`:
257257

258258
- `1` - true
259259
- `0` - false
@@ -267,7 +267,7 @@ from pymycobot.mycobot import MyCobot
267267

268268
- **Returns**
269269

270-
bool: `True` - moving, `False` - not moving.
270+
`bool`: `True` - moving, `False` - not moving.
271271

272272
## JOG mode and operation
273273

@@ -307,7 +307,7 @@ from pymycobot.mycobot import MyCobot
307307

308308
- **Returns**
309309

310-
speed: (int)
310+
speed: (`int`)
311311

312312
### set_speed()
313313

@@ -331,7 +331,7 @@ from pymycobot.mycobot import MyCobot
331331

332332
- **Returns**
333333

334-
angle: (int)
334+
angle: (`float`)
335335

336336
### get_joint_max_angle()
337337

@@ -345,7 +345,7 @@ from pymycobot.mycobot import MyCobot
345345

346346
- **Returns**
347347

348-
angle: (int)
348+
angle: (`float`)
349349

350350
## Servo control
351351

@@ -361,7 +361,7 @@ from pymycobot.mycobot import MyCobot
361361

362362
- **Returns**
363363

364-
speed: (int)
364+
flag: (`int`)
365365

366366
- `0`: disable
367367
- `1`: enbale
@@ -375,7 +375,7 @@ from pymycobot.mycobot import MyCobot
375375

376376
- **Returns**
377377

378-
flag: (int)
378+
flag: (`int`)
379379

380380
- `0`: disable
381381
- `1`: enbale

pymycobot/common.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@ def _process_recived(self, data, genre):
126126
if cmd_id != genre:
127127
return []
128128
data_pos = idx + 4
129-
avild_data = (data[data_pos:data_pos + data_len])
129+
valid_data = (data[data_pos:data_pos + data_len])
130130

131131
res = []
132132
if data_len == 12:
133-
for idx in range(0, len(avild_data), 2):
134-
a = avild_data[idx:idx + 2]
135-
res.append(self._decode_int16(a))
133+
for idx in range(0, len(valid_data), 2):
134+
one = valid_data[idx:idx + 2]
135+
res.append(self._decode_int16(one))
136136
elif data_len == 2:
137-
res.append(self._decode_int16(avild_data))
137+
res.append(self._decode_int16(valid_data))
138138
else:
139-
res.append(self._decode_int8(avild_data))
139+
res.append(self._decode_int8(valid_data))
140140
return res
141141

142-
def _process_bool(self, data):
142+
def _process_single(self, data):
143143
return data[0] if data else -1
144144

145145

pymycobot/mycobot.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def is_power_on(self):
110110
-1: error data
111111
112112
'''
113-
return self._process_bool(
113+
return self._process_single(
114114
self.__mesg(Command.IS_POWER_ON, has_reply=True))
115115

116116
def set_free_mode(self):
@@ -236,7 +236,7 @@ def pause(self):
236236
self.__mesg(Command.PAUSE)
237237

238238
def is_paused(self):
239-
return self._process_bool(self.__mesg(Command.IS_PAUSED,
239+
return self._process_single(self.__mesg(Command.IS_PAUSED,
240240
has_reply=True))
241241

242242
def resume(self):
@@ -273,7 +273,7 @@ def is_in_position(self, data, id):
273273
received = self.__mesg(Command.IS_IN_POSITION,
274274
data=data_list,
275275
has_reply=True)
276-
return self._process_bool(received)
276+
return self._process_single(received)
277277

278278
def is_moving(self):
279279
'''
@@ -283,7 +283,7 @@ def is_moving(self):
283283
1 : is moving
284284
-1: error data
285285
'''
286-
return self._process_bool(self.__mesg(Command.IS_MOVING,
286+
return self._process_single(self.__mesg(Command.IS_MOVING,
287287
has_reply=True))
288288

289289
# JOG mode and operation
@@ -314,7 +314,7 @@ def jog_stop(self):
314314

315315
# Running status and Settings
316316
def get_speed(self):
317-
return self._process_bool(self.__mesg(Command.GET_SPEED,
317+
return self._process_single(self.__mesg(Command.GET_SPEED,
318318
has_reply=True))
319319

320320
def set_speed(self, speed):
@@ -346,11 +346,11 @@ def get_joint_max_angle(self, joint_id):
346346
# Servo control
347347
@check_id
348348
def is_servo_enable(self, servo_id):
349-
return self._process_bool(
349+
return self._process_single(
350350
self.__mesg(Command.IS_SERVO_ENABLE, data=[servo_id]))
351351

352352
def is_all_servo_enable(self):
353-
return self._process_bool(
353+
return self._process_single(
354354
self.__mesg(Command.IS_ALL_SERVO_ENABLE, has_reply=True))
355355

356356
# Atom IO

0 commit comments

Comments
 (0)