Locations

Wearable Intertace for Teleoperation of Robot Arms - WITRA

 
[Update 5] Toradex + MATLAB: IMU data acquisition
Update #10123  |  05 Nov 2014
 

In the video you can see the data from the IMU's spacial orientation being plotted in MATLAB. Previously the intention was to send data from the IMU to Colibri over bluetooth. However due to problems using the Windows CE bluetooth stack, the communication was switched to serial interface. 

The IMU Razor 9DoF is connected to COM3 on X16 pin group. To read the data on this COM port, I followed the tutorial present at the developer section of Toradex website at http://developer.toradex.com/knowledge-base/how-to-use-uart

Basically one needs to configure the COM port and the use

ReadFile(portHandle, receiveBuffer, 23, &noOfBytesRead, NULL);

to read from it and store the read data in receiveBuffer. 

After manipulation of the data contained in this buffer, a string is sent over TCP/IP and the module as client

sprintf(sendBuffer, "%.2f,%.2f,%.2f\n",angles[0],angles[1],angles[2]);

retVal_S = send(commSocket, sendBuffer, strlen(sendBuffer), 0);

On MATLAB side, a TCP/IP server is created and the received data is read and separated into the indivudal angle values. A code example is shown below:

t = tcpip('192.168.27.101', 23, 'NetworkRole', 'server');
fopen(t);

while ~KEY_IS_PRESSED

     data = fscanf(t');
     data = char(data);
     [yaw,pitch,roll] = strread(data,'%f%f%f','delimiter',',');

    flushinput(t);
    pause(0.2);

end

fclose(t);

Along with the above code, the plot() function is used to plot the values of yaw, pitch and roll continuously on the screen.

Here we have a picture of the code working:

thumbnail

_____________________________________________________________________________________________________

Make sure you also follow our news and updates on our social channels below. 

youtube       facebook       email
 

Comments