Hi,
I'm new using the robotics toolbox. I am using the Arbotix.m function to interface with a physical prototype from Matlab. The robot has an Arbotix-M controller and Dynamixel AX-18 servos.
I use a code example in Matlab like this to read/write data from/to the servos:
arb=Arbotix('port','COM5', 'nservos',1); % Establishes a connection with the arbotix-m board
arb.readdata(1,Arbotix.ADDR_POS,2); % Reads 2-byte current position from servo 1
arb.writedata2(1,Arbotix.ADDR_SPEED,i); % Sets speed register of servo 1
arb.flush(); % Flash receive buffer
I can implement this instructions one by one using the Matlab command window and I can execute the sequence read/write/flush several times and it works fine. The problem comes when I try to implement this code in an m-file to run it into a loop like this:
for i=100:120
arb.readdata(1,Arbotix.ADDR_POS,2); % Reads 2-byte current position from servo 1
arb.writedata2(1,Arbotix.ADDR_SPEED,i); % Sets speed register of servo 1
arb.flush(); % Flash receive buffer
end
In this case Matlab crashes every time I try to run the code and it shows the error message: "Unsuccessful read: the specified amount of data was not returned within the timeout period". The error is found in the code lines:
Arbotix/readdata
retval=arb.receive();
Arbotix/receive
c=fread(arb.serPort,1,'uint8');
serial/fread
Unsuccessful read:
I tried to introduce pauses between instructions and it works better but still crashes from time to time and makes the code slower.
Did anyone have the same problem or know where can it be the error?
Thanks very much!