Hello,
I am trying to control Dynamixel using Python code with the SDK.
The system consists of a Dynamixel, OpenCR, and Raspberry Pi.
Issue:
After writing the goal position of the Dynamixel:
packetHandler.write4ByteTxRx(portHandler, DXL_ID, ADDR_GOAL_POSITION, goal_position)
An error occurs when I try to read the present position:
packetHandler.read4ByteTxRx(portHandler, DXL_ID, ADDR_PRESENT_POSITION)
There are no errors when I only write or only read, but an error occurs when I read after writing.
To solve this, I have tried the following:
-
Verified DXL_ID, baud rate, and protocol version
-
Performed factory reset and firmware update using DynamixelWizard 2.0
-
Experimented with time.sleep(0.1) and different sleep times
-
Checked the torque enable status and re-enabled it if disabled
-
Cleared the port with portHandler.clearPort()
-
Used a while loop to wait until the goal position is reached before reading, without using time.sleep
However, an error still occurs when I try to read.
I suspect this might be due to sending the instruction packet twice in a row.
I believe I need to add a delay time because of consecutive transmissions, but I wonder if there is another delay mechanism besides time.sleep.
The error I get with time.sleep is:
DXL_MAKEWORD(data[2], data[3]) if result == COMM_SUCCESS
IndexError: list index out of range
The error I get without time.sleep is:
Incorrect status packet TxRxResult Communication error
Thank you for your help.
DYNAMIXEL Servo:
- XL540-W270
- XM430-W210
DYNAMIXEL Controller:
OpenCR, Raspberry Pi
Software Interface:
Python, Ubuntu 20.04, ROS Noetic