# Clear bulkwrite parameter storage dynamixel.groupBulkWriteClearParam(groupwrite_num) while 1: # Bulkread present position and moving status dynamixel.groupBulkReadTxRxPacket(groupread_num) if dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION) != COMM_SUCCESS: dynamixel.printTxRxResult( PROTOCOL_VERSION, dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION)) # Check if groupbulkread data of Dynamixel#1 is available dxl_getdata_result = ctypes.c_ubyte( dynamixel.groupBulkReadIsAvailable(groupread_num, DXL1_ID, ADDR_PRO_PRESENT_POSITION, LEN_PRO_PRESENT_POSITION)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL1_ID)) quit() # Check if groupbulkread data of Dynamixel#2 is available dxl_getdata_result = ctypes.c_ubyte( dynamixel.groupBulkReadIsAvailable(groupread_num, DXL2_ID, ADDR_PRO_LED_RED, LEN_PRO_LED_RED)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL2_ID)) quit() # Get Dynamixel#1 present position value
dxl_comm_result = dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION) if dxl_comm_result != COMM_SUCCESS: print(dynamixel.getTxRxResult(PROTOCOL_VERSION, dxl_comm_result)) # Clear bulkwrite parameter storage dynamixel.groupBulkWriteClearParam(groupwrite_num) while 1: # Bulkread present position and moving status dynamixel.groupBulkReadTxRxPacket(groupread_num) dxl_comm_result = dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION) if dxl_comm_result != COMM_SUCCESS: print(dynamixel.getTxRxResult(PROTOCOL_VERSION, dxl_comm_result)) # Check if groupbulkread data of Dynamixel#1 is available dxl_getdata_result = ctypes.c_ubyte(dynamixel.groupBulkReadIsAvailable(groupread_num, DXL1_ID, ADDR_PRO_PRESENT_POSITION, LEN_PRO_PRESENT_POSITION)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL1_ID)) quit() # Check if groupbulkread data of Dynamixel#2 is available dxl_getdata_result = ctypes.c_ubyte(dynamixel.groupBulkReadIsAvailable(groupread_num, DXL2_ID, ADDR_PRO_LED_RED, LEN_PRO_LED_RED)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL2_ID)) quit() # Get Dynamixel#1 present position value dxl1_present_position = dynamixel.groupBulkReadGetData(groupread_num, DXL1_ID, ADDR_PRO_PRESENT_POSITION, LEN_PRO_PRESENT_POSITION) # Get Dynamixel#2 moving status value dxl2_led_value_read = dynamixel.groupBulkReadGetData(groupread_num, DXL2_ID, ADDR_PRO_LED_RED, LEN_PRO_LED_RED)
dxl_comm_result = dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION) dxl_error = dynamixel.getLastRxPacketError(port_num, PROTOCOL_VERSION) if dxl_comm_result != COMM_SUCCESS: print(dynamixel.getTxRxResult(PROTOCOL_VERSION, dxl_comm_result)) elif dxl_error != 0: print(dynamixel.getRxPacketError(PROTOCOL_VERSION, dxl_error)) while 1: # Bulkread present position and moving status dynamixel.groupBulkReadTxRxPacket(group_num) dxl_comm_result = dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION) if dxl_comm_result != COMM_SUCCESS: print(dynamixel.getTxRxResult(PROTOCOL_VERSION, dxl_comm_result)) # Check if groupbulkread data of Dynamixel#1 is available dxl_getdata_result = ctypes.c_ubyte(dynamixel.groupBulkReadIsAvailable(group_num, DXL1_ID, ADDR_MX_PRESENT_POSITION, LEN_MX_PRESENT_POSITION)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL1_ID)) quit() # Check if groupbulkread data of Dynamixel#2 is available dxl_getdata_result = ctypes.c_ubyte(dynamixel.groupBulkReadIsAvailable(group_num, DXL2_ID, ADDR_MX_MOVING, LEN_MX_MOVING)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL2_ID)) quit() # Get Dynamixel#1 present position value dxl1_present_position = dynamixel.groupBulkReadGetData(group_num, DXL1_ID, ADDR_MX_PRESENT_POSITION, LEN_MX_PRESENT_POSITION) # Get Dynamixel#2 moving status value dxl2_moving = dynamixel.groupBulkReadGetData(group_num, DXL2_ID, ADDR_MX_MOVING, LEN_MX_MOVING)
PROTOCOL_VERSION, dynamixel.getLastRxPacketError(port_num, PROTOCOL_VERSION)) while 1: # Bulkread present position and moving status dynamixel.groupBulkReadTxRxPacket(group_num) if dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION) != COMM_SUCCESS: dynamixel.printTxRxResult( PROTOCOL_VERSION, dynamixel.getLastTxRxResult(port_num, PROTOCOL_VERSION)) # Check if groupbulkread data of Dynamixel#1 is available dxl_getdata_result = ctypes.c_ubyte( dynamixel.groupBulkReadIsAvailable(group_num, DXL1_ID, ADDR_MX_PRESENT_POSITION, LEN_MX_PRESENT_POSITION)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL1_ID)) quit() # Check if groupbulkread data of Dynamixel#2 is available dxl_getdata_result = ctypes.c_ubyte( dynamixel.groupBulkReadIsAvailable(group_num, DXL2_ID, ADDR_MX_MOVING, LEN_MX_MOVING)).value if dxl_getdata_result != 1: print("[ID:%03d] groupBulkRead getdata failed" % (DXL2_ID)) quit() # Get Dynamixel#1 present position value