You are viewing the documentation for OpenSim 3.x. Are you looking for the latest OpenSim 4.0 Documentation?

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Using the OpenSim API

The Developer's Guide has examples using the API, including:

/wiki/spaces/OpenSim/pages/53084294 - Write a main C++ program (a "tug of war") to create a model and run a forward simulation

/wiki/spaces/OpenSim/pages/53084274 - Write your own Analysis to output the center of mass of each body in a model, plus velocities and accelerations

Creating a Controller - Extend the tug of war example with a custom controller

Creating an Optimization - Write an optimization to find muscle controls to maximize the forward velocity of the hand

Creating a Customized Actuator - Implement a spring with controllable stiffness

Creating a Customized Muscle Model - Implement a muscle model with fatigue

 

Building the API Examples

A summary of the steps to build the API examples is below. There are more details in the Developer's Guide.  We will use the tug-of-war Example (Located in your OpenSimInstallationDirectory\sdk\APIExamples\ExampleMain folder) as an example.

On Windows

  • Prepare a working directory: Copy the example folder from the installation folder (by default, this is C:\OpenSim 3.0\sdk\APIExamples\ExampleMain) to a working folder. In this example, we will assume the working folder is C:\ExampleMain, but the name and path are arbitrary.
  • Run CMake. Launch CMake. In the dialog box that appears:
    1. For the field "Where is the source code," select the working plug-in directory you just created (e.g., C:\ExampleMain).
    2. Select a directory for "Where to build the binaries." For this example, we will use the folder C:\TugOfWarBuild. (If the directory does not exist CMake will prompt you to ask if it should create the directory after you hit Configure)



    3. Hit Configure and you will see things highlighted in red. Make sure that the correct installation directory is specified for OPENSIM_INSTALL_DIR, and update it if needed. If you use any directory other than the default for installation, you will also need to update CMAKE_INSTALL_PREFIX to have the same value as OPENSIM_INSTALL_DIR.



    4. Click Configure again, and the highlighted red should be cleared, and then Generate.



 

  • You will see a solution file (.sln) generated in the build directory. Double click on it and it will launch Visual Studio

  • Build solution. Use Visual Studio's "Build" menu to compile your project (or right click on ALL_BUILD and build). You need to switch from "Debug" to either "Release" or "RelWithDebInfo" if you do not have debuggable OpenSim libraries against which to link.

If you are building a plugin there will be an INSTALL project in the Solution Explorer on the left panel. you can build it in order to install your dll file to the plugins directory in OpenSim.

  • No labels