15 Hardware connectionsTop13 Joint Coupling and Underactuated Hands14 Matlab interface


14 Matlab interface

Warning: The Matlab interface has not been been maintained or tested recently. We hope to bring it up to date at some point, but for now you might have to fix it yourself to get it working again.

On some machines, the GraspIt TCP server segfaults on exit (due to what seems to be a Qt Socket problem that we have not been able to track down). Therefore, we have commented it out; if you want to use this feature you must bring the declaration back. In the file $GRASPIT/src/main.cpp, find the relevant line and uncomment it.

When GraspIt! begins, this will start up a TCP server that accepts connections. A text protocol, which will be described in future documentation, allows external programs to issue commands and collect data from the simulation. These programs could run on the same machine that GraspIt! is running on or on a separate machine. The functions described in this document allow MATLAB to communicate with GraspIt. The functions are implemented as C language MEX files. Each one opens a connection to the GraspIt! server (which for now must be running on the same machine), issues a command to either change or query the world state, and closes the connection.

To use these functions, be sure to set your MATLAB working directory to the "matlab" folder within the GraspIt root installation folder. Type "help matlab" to get a summary of the available functions, and type "help" and the name of a function to find more detailed information.

14.1 Commands

14.2 One time step

A script that performs a dynamic simulation will contain a loop, where each iteration of the loop advances the simulation by one time step. The following is a possible example script:

%the maximum time step is commonly 2.5 milliseconds
maxdt = 0.0025;  
while 1
  % advance the simulation	
  h = moveDynamicBodies(maxdt);
  % compute the control forces
  %where 6 9 12 are the indices of the fingertip bodies
  [CF,CP] = getAverageContacts([6; 9; 12]);  

  DP = getDOFVals;
  DF = computeControlForces(DP,CF,CP);
  %This would be a user supplied function that computes the new
  %DOF forces based on the current DOF positions, the contact forces,
  %and positions.

  %the computed forces are applied to the bodies and will affect 
  %the next velocity computation.

Copyright (C) 2002-2009 Columbia University

15 Hardware connectionsTop13 Joint Coupling and Underactuated Hands14 Matlab interfaceContents