SD/FAST C++ Interface and MATLAB Integration
Benjamin Stephens
Robotics Institute 2008

This document describes a hack that I have used to implement SD/FAST in C++ and in MATLAB. The motivation behind this was to find a simple way to use different models, or copies of the same model at the same time. The MATLAB script reads the output of SD/FAST and creates several new files that contain the source for the C++ and MATLAB interfaces.

The Files

Download a copy of all the files needed to run SD/FAST++ on an SD/FAST model here: (updated 7/15/2011)

Below is a description of all of the files associated with this script.


  1. Installation
    1. Unzip the files from to a directory
    2. Add this directory to your MATLAB path
  2. Compiling a model
    1. Write a model description file - "model"
    2. Run SD/FAST - "sdfast -lc -ge model"
    3. Open MATLAB and run the script (make sure the sdfastplus directory is in the path) - "sdfastplus('model')"
    4. Run the model mex make file - "make_model"
  3. An example matlab interface
    1. Create a matlab mex interface file (example: model_impulse.cpp - others are included in the zip file)
    2. Make sure you include "SDModel.h" and "SDModel_common.h"
    3. Compile the mex interface file - mex model_impulse.cpp [SDFAST++Dir]\SDModel.cpp [SDFAST++Dir]\SDModel_common.cpp [SDFAST++Dir]\sdlib.c -I[SDFAST++Dir]
    4. Create a model object and get the pointer - "m = model_mex;"
    5. Pass the pointer into your mex interface function - "x_new = model_impulse(m,x_0,body,force);"