SD/FAST in MATLAB
Benjamin Stephens
Robotics Institute 2007

This document describes how to compile and run SDFAST simulations from within Matlab. The compilation process involves logging into a remote CMU server that holds the SDFAST program that creates C code from a script file describing the model. Next, the C files have to be compiled using Visual C++ from Windows. Finally, the MATLAB mex command is used to create a single .mexw32 file that runs the model from MATLAB

The rest of this page serves as a quick-start guide. More advanced topics are found here:

Quick-Start Guide

  1. Find/Create an SDFAST model file

    Here is an example file for the sarcos robot: sarcos.sd

  2. Generate the SDFAST code

    1. SSH onto run-prime.graphics.cs.cmu.edu
    2. change to your afs directory containing the sdfast model
    3. Run the following commands:

      > setenv SDKEYDIR /usr0/local/lib

      > /usr0/local/bin/sdfast -lc -ge -n sarcos.sd

    This step will create several C files:

  3. Compile the Code
    1. Open up an VC++ command line and change to the directory containing the C files
    2. Run the following commands:

      > cl /c sarcos_sar.c sarcos_dyn.c sdlib.c

  4. Compile the code into Matlab using MEX

    Before you do this the first time, you will need to setup the matlab mex routine. Run "mex -setup" and select the LCC compiler.

    1. Copy the file, "C:\Program Files\Microsoft Visual Studio 8\VC\lib\chkstk.obj" into your directory
    2. Run the following command from matlab:

      >mex mexSim.c sarcos_dyn.obj sdlib.obj chkstk.obj sarcos_sar.obj