===============================================================
HOW TO RUN THE CONTROLLER EXAMPLE, IMPROVE IT, AND RUN IT AGAIN
===============================================================
Chand T. John and Ajay Seth
March 14, 2011
--------------

0) <OPENSIM_INSTALL_DIR> is the directory where you installed OpenSim, 
   such as "C:\OpenSim" or "C:\Program Files\OpenSim".
   It is a good idea to copy the example out of:
     <OPENSIM_INSTALL_DIR>\sdk\APIExamples\ControllerExample
   and into your own workspace, which we will refer to <WORKSPACE_DIR>, e.g.
   C:\Users\myAccount\OpenSimAPIExamples\ControllerExample
   

1) Make sure your PATH contains <OPENSIM_INSTALL_DIR>\bin; if not, add
   this to your PATH.   Whenever you see <OPENSIM_INSTALL_DIR> substitute it with 
   the full path as above.
   Also, make sure that no other OpenSim "\bin" directory
   is in your PATH.  If you've ever built OpenSim from source code, make sure
   no directory containing .lib or .dll files for OpenSim are present in your
   PATH either.  If you don't do this, OpenSim will get confused and possibly
   use .dll and .lib files from other/older versions of OpenSim instead of
   the files from the current version of OpenSim and you will likely experience
   run-time errors.

2) Start Menu -> CMake 2.8 -> CMake (cmake-gui)

3) Where is the source code: <WORKSPACE_DIR>
    (e.g. C:\Users\myAccount\OpenSimAPIExamples\ControllerExample)

4) Where to build the binaries: <WORKSPACE_DIR>\build
   (e.g. C:\Users\myAccount\OpenSimAPIExamples\ControllerExample\build)

5) Click Configure.

6) If the "build" directory doesn't exist yet, a message box will pop up asking
   if you want to create this directory.  Click Yes.

7) Another dialog box will open up entitled "cmake-gui" - in the drop-down
   menu, select the version of Visual Studio you will use to compile the
   Controller Example program.  For example a release of OpenSim is compatible
   with Visual Studio 10 Express.  

   Leave "Use default native compilers" selected in the option menu below the
   drop-down box.

7) Click Finish.

8) One pink field will show up called OPENSIM_INSTALL_DIR. Select your
   <OPENSIM_INSTALL_DIR>

9) Click Configure.  The message window at the bottom of the CMake window
    should say "Configuring done"

11) Click Generate.  The message window should now display:
    Configuring done
    Generating done

10) Close CMake.

11) In Windows Explorer, navigate to your build directory:
    <WORKSPACE_DIR>\build

12) Double-click on ControllerExample.sln (Visual Studio Solution).

13) Right-click on ALL_BUILD and choose Build from the drop-down menu.

14) Open a Command Prompt window. (e.g., Start -> Run -> cmd and click Run)

15) Navigate to: <WORKSPACE_DIR>\build

16) Type:
    Release\main.exe
    and press Enter.

17) Launch OpenSim

18) File -> Open Model...

19) Navigate to: Navigate to: <WORKSPACE_DIR>\build

20) Select tugOfWar_model_ThelenOnly.osim and click Open

21) File -> Load Motion...

22) Select tugOfWar_states_degrees.mot and click Open

23) Play the motion.

24) File -> Load Motion...

25) Select tugOfWar_desired_motion.sto and click Open

26) Play the motion.  Notice how the motion we played previously does not
    quite match this motion: the previous motion, which was computed by the
    controller in the controller example program, doesn't quite move the block
    to the left or right ends of this desired motion, and the block also does
    not move all the way to the center by the end of the motion like it does in
    the desired motion.

27) Do the controller example exercises indicated in the ControllerExample.cpp
    file.  If you get stuck, the solution is in the OutputReference directory
    inside the ControllerExample directory, as are the output motions computed
    by the controller in the ControllerExample_Solution.cpp file.

28) Once you have completed all the steps outlined in ControllerExample.cpp,
    repeat steps 14 through 25 above.  Note how much more closely the motion
    computed by the controller now matches the desired motion!

