Using a board with FTDI chip, and the library from Robotis, the DLL is linked to Matlab and so functions can be called from within m-functions to send-receive packets from the servo bus.
function [PresentPos]=bioloid(id,GoalPos) % Send and receive values from dynamixels % [PRESENTPOS]=BIOLOID(ID,GOALPOS) % ID - Vector with all dynamixels ID % GOALPOS - Vector with all goal dynamixels positions % PRESENTPOS - Vector with all dynamixels positions % Fernando Carreira % IST-Humanoids lab, Lisbon % 09-02-2010 n=length(id); for pos=1:n calllib('dynamixel','dxl_write_word',id(pos),30,GoalPos(pos)); %write pos PresentPos(pos) = calllib('dynamixel','dxl_read_word',id(pos),36); %read pos end
We do some speed tests to see the overall latency of talking to individual servos on the bus. Our robot has 10 servos. Their IDs are stored in vector id and PresentPos has the target positions at first and after calling the bioloid() routine, it will contain the actual positions (in the text below these are the same values because the robot is laying still).
>> id = [14 18 11 19 41 40 17 15 4 6]; >> PresentPos = [513 511 519 521 512 512 519 489 511 512]; >> tic for i=1:1000 [PresentPos]=bioloid(id,PresentPos); end t=toc t = 35.6943 >> tmean = t/1000 tmean = 0.0357 >> freq = 1/tmean freq = 28.0156 >> PresentPos PresentPos = 513 511 519 521 512 512 519 489 511 512
Leave a Reply