Enlighten Engineering [image]
Home Contact Us OMD For Simulink SCOOTA Driving Game PyOMD2 PyOMD Bug Walk

OMD For Simulink Examples

Introduction

First of all, you will (of course) need matlab and Simulink, but basic simulink should suffice. Also, you will need Python, which can be found here: Python Download:
Once you have Python installed, download the example models for OMD for Simulink: OMD For Simulink Examples Download . This page describes those examples.
In the .zip file that contains the examples you will find a directory entitled OMD4Simulink. In that directory you will find all the matlab files, simulink models, libraries and Python scripts you will need to run the examples. The simulink models contain S-Function that interface with the OMD library. What follows on this page are a step by step set of instructions which will allow you to run the examples to illustrate how the software works.

Instructions

  1. If you don't have a compiler download the latest free Visual C++
  2. Download Python 2.5 if you do not already have it Python Download:
  3. Download the zipped file that contains the example from here:
    OMD For Simulink Examples Download:
  4. Unzip the examples somewhere on your hard drive. Perhaps in you Matlab working directory, or in My Documents or wherever.
  5. Open Matlab and change the directory to the "OMD4Simulink" directory that was extracted from the zip file.
    Matlab command: >>cd "path"/OMD4Simulink
  6. If you have not used the "mex" command in the past, type:
    >mex -setup
    specify Visual C++, there might be something else that works, but the compiler that ships with Matlab does not (at least not for me)
  7. Enter the followin command at the Matlab Prompt:
    >> makemex
    This will run a matlab script containing a set of "mex" commands to compile the C++ code that comprises the S-Functions in the examples. If it does not work it could be because Python 2.5 can not be found. If you open the makemex.m file you will see the absolute paths to the include and lib files from python. You should be able to find them on your hard drive is you have the software installed.
    If this step is succesful the following files should have been created:
  8. Open either "doublependtest.mdl" or "robottest.mdl".
  9. Start the simulation.

Further Description

Both example models (doublependtest and robottest) are intentionally slowed down by setting a Fixed-Step size of 0.001. This has nothing to do with OMD requirments this is simply done so the animation can be seen is something close to realtime. If you computer is faster than mine you will need to slow down the simulation even further to see what is happening. If you don't care to view the animation, you can set the solver type to "Variable-Step" and let Simulink determine who fast the simulation should run.

Double Pendulum Example

This example is minimulistic. You have the OMD block, blocks to get body positions, the animation block and an integrator. The forces on the mechanism do not change during run time. They are always subjected to acceleration due to gravity and nothing else. You can see the mechasism swing freely in the animation.

Robot Example

This example utilizes a double pendulum mechanism but contains a model of a motor with a PID control scheme placed on the joint that attaches the first body to the ground that the first pendulum bob with the next. The forces on the OMD model are changed during run time based on the PID Simulink controller. In the animation the pendulum will stand up straight due to the control scheme.

OMD For Simulink Examples