Running OpenSim in the command line

Provide a space for people developing and using musculoskeletal models to collaborate and learn from each other.
POST REPLY
User avatar
Edith Arnold
Posts: 44
Joined: Fri Apr 06, 2007 2:07 pm

Running OpenSim in the command line

Post by Edith Arnold » Thu Oct 21, 2010 11:06 am

When I started using OpenSim I did most of my work in the GUI, but as I got into more complex simulations, with rapid iteration of my setup files in notepad++, I found that using the command line was really useful. Here's how to do it.

In Windows, go the the Start menu, select Run, type "cmd", and click "OK" to open a command window.

Navigate the the folder where your setup file is. (e.g. "cd My Documents\mysimulation\setupfiles")

Type the path to the tool you want to use, followed by -S and the name of the setup file.
c:\Program Files\yourverisonofopensim\bin\thetoolyouwant -S nameofyoursetupfile

e.g. to use verison 2.0 and the cmc tool it looks like this:
c:\Program Files\OpenSim 2.0\bin\cmc.exe -S mySetupFile_RRA.xml
Hit Enter.

If your simulations are crashing the GUI and you don't know why, using the command line instead means you'll at least get an out.log file and some output to the command window that you can use to debug.

-Edith

User avatar
Nur Adila Faruk Senan
Posts: 75
Joined: Tue Apr 06, 2010 8:20 pm

RE: Running OpenSim in the command line

Post by Nur Adila Faruk Senan » Thu Nov 11, 2010 11:54 am

Hey Edith,

First of all, thanks for this post (and this project in general) - very neat :)

I tried out what you mentioned above using the OpenSim examples and I got through the first step:
navigate to the folder where my setup file is. In my case, this is
cd c:\OpenSim 2.2\examples\Gait2354_Simbody

after I hit enter, the command line then read
C:\OpenSim 2.2\examples\Gait2354_Simbody>

but when I typed in the path to the tool I wanted to use (I just copied your exampleand tried it out with cmc), I got this message:

c:\OpenSim is not recognized as an internal or external command, operable program or batch file.

Since my OpenSim 2.2 folder is in the C directory, all I typed in was
c:\OpenSim 2.2\bin\cmc.exe -S subject01_Setup_CMC.xml

So, the full line on my command line looked like this:

C:\OpenSim 2.2\examples\Gait2354_Simbody>c:\OpenSim 2.2\bin\cmc.exe -S subject01_Setup_CMC.xml
(where the part after the ">" is what I typed in.

but I keep getting the message shown above (c:\OpenSim is not recognized as an internal or external command, operable program or batch file.)

I also tried copying and pasting the cmc.exe file from the "bin" folder into the Gait2354_Simbody folder and modifying the file path as appropriate, but I still get the "c:\OpenSim in not recognized..." error message.

Do you know why this is?

Thanks a bunch,
adila

User avatar
Ayman Habib
Posts: 2238
Joined: Fri Apr 01, 2005 12:24 pm

RE: Running OpenSim in the command line

Post by Ayman Habib » Thu Nov 11, 2010 11:58 am

Hi Adila,

I think you need to include the command between quotes since it appears the shell you're using doesn't recognize the spaces properly. Thank you Microsoft for the misery!

Please let us know if that doesn't resolve your problem.

-Ayman

User avatar
Nur Adila Faruk Senan
Posts: 75
Joined: Tue Apr 06, 2010 8:20 pm

RE: Running OpenSim in the command line

Post by Nur Adila Faruk Senan » Thu Nov 11, 2010 12:26 pm

Hey Ayman,
Thanks for responding so quickly. I tried what you said, and I'm still getting the same message.

i.e.
"c:\OpenSim 2.2\bin\cmc.exe -S subject01_Setup_CMC.xml "

as well as

"c:\OpenSim 2.2\examples\Gait2354_Simbody\cmc.exe -S subject01_Setup_CMC.xml"
(since I copied and pasted the cmc.exe file into the same folder)

but neither of these work. It lets me load my directory without the quotation marks though...

thanks
adila

User avatar
Ayman Habib
Posts: 2238
Joined: Fri Apr 01, 2005 12:24 pm

RE: Running OpenSim in the command line

Post by Ayman Habib » Thu Nov 11, 2010 12:36 pm

Adila,

I don't know where you installed OpenSim. The latest installer doesn't include space in the path name, so that might be an option/workaround.

Also the reason you use the full path is if you have not added the directory of the installation/bin to your path when installing (default is to add to the path). If you did then you should only use the executable name without the full path. If your shell (command prompt) allows for auto completion I'd use that to make sure there're no typos in the Paths.

Hope this helps,
-Ayman

User avatar
Nur Adila Faruk Senan
Posts: 75
Joined: Tue Apr 06, 2010 8:20 pm

RE: Running OpenSim in the command line

Post by Nur Adila Faruk Senan » Thu Nov 11, 2010 12:59 pm

Hey Ayman,

My OpenSim is installed directly in C (i.e. C:\OpenSim 2.2)

I went ahead and took out the space so that my folder is named OpenSim2.2, and ran through the same steps above with the same error message.

I also tried just
"cmc.exe -S subject01_Setup_CMC.xml" (since I have a copy of cmc.exe in the same folder) with no success.

thanks,
adila

User avatar
Ayman Habib
Posts: 2238
Joined: Fri Apr 01, 2005 12:24 pm

RE: Running OpenSim in the command line

Post by Ayman Habib » Thu Nov 11, 2010 1:08 pm

Hi Adila,

It's unlikely that the error message is the same "OpenSim not a recognized ..." if the command line is different and doesn't contain OpenSim followed by a space!. Can you please send the exact error message and when you're getting it?

Best,
-Ayman

User avatar
Nur Adila Faruk Senan
Posts: 75
Joined: Tue Apr 06, 2010 8:20 pm

RE: Running OpenSim in the command line

Post by Nur Adila Faruk Senan » Thu Nov 11, 2010 3:42 pm

Hey Ayman,

Sorry - my mistake. The exact error message was:
"c:\OpenSim 2.2\bin\cmc.exe -S subject01_Setup_CMC.xml" is not recognized as an internal or external command, operable program or batch file.

But then, I tried doing the exact same thing, but leaving out the quotation marks (so my input was
c:\OpenSim2.2\bin\cmc.exe -S subject01_Setup_CMC.xml) and it works!


Thanks a million for the help,
adila

User avatar
Ayman Habib
Posts: 2238
Joined: Fri Apr 01, 2005 12:24 pm

RE: Running OpenSim in the command line

Post by Ayman Habib » Thu Nov 11, 2010 4:32 pm


No problem, Adila. Glad we got that resolved..

Cheers,
-Ayman

User avatar
Nur Adila Faruk Senan
Posts: 75
Joined: Tue Apr 06, 2010 8:20 pm

RE: Running OpenSim in the command line

Post by Nur Adila Faruk Senan » Fri Nov 12, 2010 2:14 pm

Just another follow up to this: If I'm running OpenSim on Windows using the Parallel Desktop application (so my path through the Windows console is \\.psf\Home\Desktop\Adila_OpenSim)

is there any way to run my models (which are saved on my Mac Desktop) using the command line in Windows? I tried doing

cd \\.psf\Home\Desktop\Adila_OpenSim
but it doesn't allow it (the error message says "CMD does not allow UNC paths as current directories").

I know I could just copy and paste everything into a folder on Windows, but the problem with that is that every time I want to access them, I have to run the Parallel Desktop app which I'd much rather not.

Thanks,
adila

POST REPLY