Command Line Set-Up Instructions 

Your OpenSim download includes command line executables that can run all of the OpenSim tools, including OpenSense for IMU-based kinematics (as of version 4.1). 

After you have installed OpenSim, you need to tell your system where to find the command line tools by adding their folder to your system's path.

Mac, using the bash shell

On Mac, you should add a shortcut to opensim-cmd and/or to opensense. You can do this by running the script provided:

cd /Applications/OpenSim\ 4.1/bin
./opensim-install-command-line.sh

From then on, you can refer to opensense and opensim-cmd from anywhere on your Mac.

To test if the OpenSim command line tools are now on your path, type in "opensim-cmd" at the command prompt from any directory. A set of instructions for using opensim-cmd should be printed to the Terminal window. You can test the opensense command line tools similarly.


Alternately, you can do the set-up manually by following the steps below:

ln -s <OpenSim Installation Folder>/bin/opensense opensense
ln -s <OpenSim Installation Folder>/bin/opensim-cmd opensim-cmd

The "/usr/local/bin" folder may be write-protected, in which case you need to prefix these lines with "sudo ". For example, if you have installed OpenSim 4.1 in the folder "/Applications/OpenSim", you would type:

sudo ln -s /Applications/OpenSim\ 4.1/bin/opensim-cmd opensim-cmd
sudo ln -s /Applications/OpenSim\ 4.1/bin/opensense opensense

Note that the backslash before the 4.1 allows the terminal shell to correctly interpret the space in the name of the "OpenSim 4.1" folder.

From then on, you can refer to opensense and opensim-cmd from anywhere on your Mac.

To test if the OpenSim command line tools are now on your path, type in "opensim-cmd" at the command prompt from any directory. A set of instructions for using opensim-cmd should be printed to the Terminal window. You can test the opensense command line tools similarly.

If you remove an installation or install a new version of OpenSim, remember to update or remove these links: 

You can learn more about your bash profile and how to edit it here

Starting with macOS 10.15 Catalina, the default command-line shell is zsh instead of bash. See https://support.apple.com/en-gb/HT208050 for details. 

Windows

On Windows, you also need to add the path to OpenSim executables and dynamic libraries to your system path by performing the following steps: 

Executing command line utilities

OpenSim contains a command line executable that can run all of the OpenSim Tools. This executable takes as input the same setup (or settings) file loaded into or saved from the OpenSim GUI application. For example, to perform Inverse Kinematics from the command line (the Command Prompt in Windows, or the Terminal on macOS), one can execute the following command:

opensim-cmd run-tool arm26_Setup_InverseKinematics.xml

The same command can be used to run CMC or any other tool (the specific OpenSim Tool to run is determined based on the provided setup file). The command line executable is located in <OpenSim_Install_Dir>/bin (on Windows, this directory also contains deprecated executables named "ik", "id", "cmc", etc.).

The command line executable can do more than run OpenSim Tools. You can generate template XML files for tools or modeling components (opensim-cmd print-xml) and update an XML file to the latest version (opensim-cmd update-file). Lastly, the command opensim-cmd info can be a very handy resource to obtain information about Tools and Components, including the XML tags needed in the model and/or setup file. This is the same information listed in the "XML Browser" panel under the Help menu in the OpenSim GUI. Executing opensim-cmd info without any other arguments lists all the registered classes (components, analyses, utilities and tools) available in OpenSim. For more information about a particular object, such as adding a point constraint to the model, executing

opensim-cmd info PointConstraint

yields:

PROPERTIES FOR PointConstraint (5)
1. components
2. isEnforced
3. socket_body_1_connectee_name
4. socket_body_2_connectee_name
5. location_body_1
6. location_body_2

This list describes the properties used to define a point constraint in OpenSim.

Just like the GUI, the command line executable also allows loading OpenSim plugins (via the --library argument). 

Use opensim-cmd --help for more information and examples on how to use the command line executable.

Previous: Probes