Skip to content

Commit 508708a

Browse files
authored
fix(MyAGVPro): The issue that Bluetooth address matching fails is fixed (#178)
* add MyCobot 280 X5PI API * add MyCobot 280 X5 PI doc * Fix MyCobot 280 X5 Pi doc errors * add MyCobot 280 X5 PI sokcet sever&client * MyCobot 280 X5 PI server compatible with python2 * rename MyCobot280x5pi to MyCobot280RDKX5 * fix MyArmMControl bugs * fix MyArmC bugs * fix myArmM&C demo bug * update M&C demo * fix MyCobot280 rdkx5 bug * fix MyArmM&C bugs * fix bugs * fix bug * fix ThreeHand api bug * Fixed the issue that Pro630 could not read data * fix MyArmM bug * MyArmM&C adds get_joints_coord interface * fix Pro630 bug * fix Pro630 bugs * Fixed the pro630 socket communication bug * Optimize MyCobot280 RDK X5 interface parameter error prompt * Optimized the way MyAGV reads MCU data * feat(myagvpro): add myagvpro api * fix(ConveyorApi):Fix the problem that no data is returned * feat(MyAGVPro): Adapt to Bluetooth and socket TCP communication modes * docs(MyAGVPro): Format the document * docs(MyAGVPro): Documentation to increase use cases * docs(MyAGVPro): rename MyAGVPro_zh.md * docs(MyAGVPro): Update the serial port * fix(MyArmM): Correction of joint limit and motor code value range * feat(MyAGVPro): Add get_emergency_stop_state api * feat(MyAGVPro): Add get_emergency_stop_state api * refactor(MyAGVPro): rename get_emergency_stop_state to get_estop_state * feat(MyAgv): Added setting/reading automatic report status interface * fix(M750):Updated M750 Swing Limit * fix(MyAGVPro): The issue that Bluetooth address matching fails is fixed --------- Co-authored-by: Mrkun5018 <[email protected]>
1 parent 3c517fe commit 508708a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

pymycobot/myagvpro.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ class ProtocolCode(enum.Enum):
4949
GET_BLUETOOTH_ADDRESS = 0x53
5050

5151
def equal(self, other):
52-
return self.value == other.value
52+
if isinstance(other, ProtocolCode):
53+
return self.value == other.value
54+
else:
55+
return self.value == other
5356

5457

5558
PLAINTEXT_REPLY_PROTOCOL_CODE = (
@@ -117,6 +120,8 @@ def _match_protocol_data(self, genre, timeout=0.1):
117120
reply_data = self._read_plaintext_data(timeout=timeout)
118121
else:
119122
reply_data = self._read_protocol_data(timeout=timeout)
123+
if not genre.equal(reply_data[3]): # check genre
124+
continue
120125

121126
if len(reply_data) == 0:
122127
continue
@@ -220,7 +225,7 @@ def _parsing_data(cls, genre, reply_data):
220225
return data[0] if len(data) == 1 else None
221226

222227
if ProtocolCode.GET_BLUETOOTH_ADDRESS.equal(genre):
223-
data = re.findall(r'AGVPro:BLE:MAC:(.*)', reply_data)
228+
data = re.findall(r'AGVPro:BLE:MAC:(.*);\r\n', reply_data)
224229
return data[0] if len(data) == 1 else None
225230

226231
if ProtocolCode.GET_MOTOR_STATUS.equal(genre):
@@ -360,6 +365,26 @@ def is_power_on(self):
360365
"""
361366
return self._merge(ProtocolCode.GET_POWER_STATE)
362367

368+
def _basic_move(self, vertical_speed=0.0, horizontal_speed=0.0, rotate_speed=0.0):
369+
""" Basic moving control
370+
371+
Args:
372+
vertical_speed: +-0.01 ~ +-1.50m/s
373+
horizontal_speed: +-0.01 ~ +-1.00m/s
374+
rotate_speed:
375+
376+
Returns:
377+
378+
"""
379+
return self._merge(
380+
ProtocolCode.AGV_MOTION_CONTROL,
381+
[
382+
int(vertical_speed * 100),
383+
int(horizontal_speed * 100),
384+
int(rotate_speed * 100)
385+
]
386+
)
387+
363388
def move_forward(self, speed):
364389
"""Pan the robot forward
365390
@@ -390,6 +415,7 @@ def move_backward(self, speed):
390415

391416
if self.get_significant_bit(speed) > 2:
392417
raise ValueError(f"speed must be a number with 2 significant bits, but got {speed}")
418+
393419
return self._merge(ProtocolCode.AGV_MOTION_CONTROL, [int(speed * 100 * -1)])
394420

395421
def move_left_lateral(self, speed):

0 commit comments

Comments
 (0)