Skip to content

Commit 4b171b7

Browse files
committed
add set_gservo_round() function
1 parent 196fd64 commit 4b171b7

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

docs/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ We support Python2, Python3.5 or later.
9292
- [get\_plan\_acceleration](#get_plan_acceleration)
9393
- [set\_plan\_speed](#set_plan_speed)
9494
- [set\_plan\_acceleration](#set_plan_acceleration)
95+
- [set\_gservo\_round](#set_gservo_round)
9596
- [get\_servo\_speeds](#get_servo_speeds)
9697
- [get\_servo\_currents](#get_servo_currents)
9798
- [get\_servo\_voltages](#get_servo_voltages)
@@ -200,7 +201,7 @@ We support Python2, Python3.5 or later.
200201
- [set\_pin\_mode(id, pin\_no, pin\_mode)](#set_pin_modeid-pin_no-pin_mode)
201202
- [set\_plan\_acceleration(id, acceleration)](#set_plan_accelerationid-acceleration)
202203
- [set\_plan\_speed(id, speed)](#set_plan_speedid-speed)
203-
- [set\_pwm\_output(id, channel, frequency, pin\_val)](#set_pwm_outputid-channel-frequency-pin_val)
204+
- [set\_pwm\_output()](#set_pwm_output-1)
204205
- [set\_reference\_frame(id, rftype)](#set_reference_frameid-rftype)
205206
- [set\_robot\_id(id, new\_id)](#set_robot_idid-new_id)
206207
- [set\_servo\_calibration(id, servo\_no)](#set_servo_calibrationid-servo_no)
@@ -1050,6 +1051,13 @@ Set command refresh mode
10501051
- `acceleration` (`int`) 0 - 100.
10511052
- `is_linear` (`int`): 0 / 1 (0 ->joint, 1 -> line)
10521053

1054+
1055+
### set_gservo_round
1056+
1057+
- **Prototype**: `set_gservo_round()`
1058+
1059+
- **Description**: Drive the 9g steering gear clockwise for one revolution.
1060+
10531061
### get_servo_speeds
10541062

10551063
- **Prototype**: `get_servo_speeds()`
@@ -2235,19 +2243,9 @@ Set planning speed
22352243

22362244
* **speed** (_int_) – (0 ~ 100).
22372245

2238-
### set_pwm_output(id, channel, frequency, pin_val)
2239-
2240-
PWM control
2241-
2242-
* **Parameters**
2243-
2244-
* **id** – 1/2 (L/R)
2245-
2246-
* **channel** (_int_) – IO number (1 - 5).
2247-
2248-
* **frequency** (_int_) – clock frequency (0/1: 0 - 1Mhz 1 - 10Mhz)
2246+
### set_pwm_output()
22492247

2250-
* **pin_val** (_int_) – Duty cycle 0 ~ 100: 0 ~ 100%
2248+
Set PWM output
22512249

22522250
### set_reference_frame(id, rftype)
22532251

pymycobot/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class ProtocolCode(object):
144144
GET_PLAN_ACCELERATION = 0xD1
145145
SET_PLAN_SPEED = 0xD2
146146
SET_PLAN_ACCELERATION = 0xD3
147+
SET_GSERVO_ROUND = 0xD4
147148

148149
# Motor status read
149150
GET_SERVO_SPEED = 0xE1

pymycobot/generate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def set_gripper_state(self, flag, speed):
679679
"""Set gripper switch state
680680
681681
Args:
682-
flag (int): 0 - open, 1 - close
682+
flag (int): 0 - open, 1 - close, 10 - release
683683
speed (int): 0 ~ 100
684684
"""
685685
return self._mesg(ProtocolCode.SET_GRIPPER_STATE, flag, speed)
@@ -1024,4 +1024,7 @@ def get_error_information(self):
10241024
def clear_error_information(self):
10251025
"""Clear robot error message"""
10261026
return self._mesg(ProtocolCode.CLEAR_ERROR_INFO, has_reply = True)
1027-
1027+
1028+
def set_gservo_round(self):
1029+
"""Drive the 9g steering gear clockwise for one revolution"""
1030+
return self._mesg(ProtocolCode.SET_GSERVO_ROUND)

pymycobot/myarm.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ def _mesg(self, genre, *args, **kwargs):
108108
ProtocolCode.GET_END_TYPE,
109109
ProtocolCode.GET_MOVEMENT_TYPE,
110110
ProtocolCode.GET_REFERENCE_FRAME,
111-
ProtocolCode.GET_JOINT_MIN_ANGLE,
112-
ProtocolCode.GET_JOINT_MAX_ANGLE,
113111
ProtocolCode.GET_FRESH_MODE,
114112
ProtocolCode.GET_GRIPPER_MODE,
115113
ProtocolCode.SET_SSID_PWD
@@ -129,6 +127,8 @@ def _mesg(self, genre, *args, **kwargs):
129127
return res
130128
elif genre in [ProtocolCode.GET_SERVO_VOLTAGES]:
131129
return [self._int2coord(angle) for angle in res]
130+
elif genre in [ProtocolCode.GET_JOINT_MAX_ANGLE, ProtocolCode.GET_JOINT_MIN_ANGLE]:
131+
return self._int2coord(res[0])
132132
else:
133133
return res
134134
return None
@@ -149,7 +149,6 @@ def send_radians(self, radians, speed):
149149
radians: a list of radian values( List[float]), length 6
150150
speed: (int )0 ~ 100
151151
"""
152-
calibration_parameters(len6=radians, speed=speed)
153152
degrees = [self._angle2int(radian * (180 / math.pi))
154153
for radian in radians]
155154
return self._mesg(ProtocolCode.SEND_ANGLES, degrees, speed)
@@ -224,13 +223,16 @@ def get_solution_angles(self):
224223
"""Get zero space deflection angle value"""
225224
return self._mesg(ProtocolCode.GET_SOLUTION_ANGLES, has_reply=True)
226225

227-
def release_all_servos(self, data):
226+
def release_all_servos(self, data=None):
228227
"""Relax all joints
229228
230229
Args:
231230
data: 1 - Undamping (The default is damping)
232231
"""
233-
return self._mesg(ProtocolCode.RELEASE_ALL_SERVOS, data)
232+
if data is None:
233+
return super().release_all_servos()
234+
else:
235+
return self._mesg(ProtocolCode.RELEASE_ALL_SERVOS, data)
234236

235237
def get_transpoendr_mode(self):
236238
"""Obtain the configuration information of serial transmission mode

0 commit comments

Comments
 (0)