Skip to content

Commit 7635fce

Browse files
authored
feat(MyAgv): Added setting/reading automatic report status interface (#173)
* 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): 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 --------- Co-authored-by: Mrkun5018 <76215701+Mrkun5018@users.noreply.github.com>
1 parent 1fc2dc2 commit 7635fce

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

pymycobot/myagv.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ class ProtocolCode:
1111
RESTORE = (0x01, 0x00)
1212
SET_LED = (0x01, 0x02)
1313
SET_LED_MODE = (0x01, 0x0A)
14+
SET_MOTION_CONTROL = (0x01, 0x0B)
1415
GET_FIRMWARE_VERSION = (0x01, 0x03)
1516
GET_MODIFIED_VERSION = (0x01, 0x09)
1617
SET_GYRO_STATE = (0x01, 0x07)
18+
SET_AUTO_REPORT_STATE = (0x01, 0x0c)
19+
GET_AUTO_REPORT_STATE = (0x01, 0x0d)
1720
GET_GYRO_STATE = (0x01, 0x08)
18-
GET_MCU_INFO = (0x01, 0x0B)
19-
UNDEFINED = ()
21+
GET_MCU_INFO = ()
2022

2123

2224
class MyAGVCommandProtocolApi(CommunicationProtocol):
@@ -190,7 +192,7 @@ def __basic_move_control(self, *genre, timeout: int = 5):
190192
while time.time() - t < timeout:
191193
if self.__movement is False:
192194
break
193-
self._merge(ProtocolCode.UNDEFINED, *genre)
195+
self._merge(ProtocolCode.SET_MOTION_CONTROL, *genre)
194196
time.sleep(0.1)
195197
self.stop()
196198

@@ -274,7 +276,7 @@ def counterclockwise_rotation(self, speed: int, timeout=5):
274276

275277
def stop(self):
276278
"""stop-motion"""
277-
self._merge(ProtocolCode.UNDEFINED, 128, 128, 128)
279+
self._merge(ProtocolCode.SET_MOTION_CONTROL, 128, 128, 128)
278280
self.__movement = False
279281

280282
def get_mcu_info(self):
@@ -334,6 +336,27 @@ def get_modified_version(self):
334336
"""Get modified version number"""
335337
return self._merge(ProtocolCode.GET_MODIFIED_VERSION, has_reply=True)
336338

339+
def set_auto_report_state(self, state):
340+
"""Set the state of automatic reporting
341+
342+
Args:
343+
state (int): 1 - open. 0 - close. Defaults to 0.
344+
"""
345+
if state not in (0, 1):
346+
raise ValueError("state must be 0 or 1")
347+
348+
self._merge(ProtocolCode.SET_AUTO_REPORT_STATE, state)
349+
350+
def get_auto_report_state(self):
351+
"""Get the state of automatic reporting
352+
353+
Return:
354+
1 - open
355+
0 - close
356+
"""
357+
358+
return self._merge(ProtocolCode.GET_AUTO_REPORT_STATE, has_reply=True)
359+
337360

338361
class MyAgv(MyAGVCommandApi):
339362

0 commit comments

Comments
 (0)