Page 1 of 1

Understanding the API: How to know the possible column names

Posted: Tue Aug 28, 2018 9:43 am
by masterv
Hi again,

I was trying to follow the program for making a simple arm model as provided in the OpenSim github https://github.com/opensim-org/opensim-core.
I was wondering on how do we know or look into the API for understanding what are the probable names that are supported to view the output in the reporter.

For example, a snippet of the code from repo is shown below:

Code: Select all

// Add a console reporter to print the muscle fiber force and elbow angle.
    ConsoleReporter* reporter = new ConsoleReporter();
    reporter->set_report_time_interval(1.0);
    reporter->addToReport(biceps->getOutput("fiber_force"));
    reporter->addToReport(
        elbow->getCoordinate(PinJoint::Coord::RotationZ).getOutput("value"),
        "elbow_angle");
    model.addComponent(reporter);
As you can see that, you have used getOutput() and as arguments, "fiber_force" and "value" has been provided. First question is : May I know how did you know them or where can I find them as well ?
Because I tried the following, say in order to view the muscle power, and it was of course wrong

Code: Select all

reporter->addToReport(biceps->getOutput("muscle_power"),"biceps_power");
reporter->addToReport(biceps->getOutput("excitations"), "excitations");
As you can see from the above code snippet that when I comment the excitations, I guessed the "muscle_power" argument right and I could see the result in console. But it did not work for excitations/activations. Could you please point me to where I can understand or look up those? I am still learning to use API.

Thanks,
Vishal

Re: Understanding the API: How to know the possible column names

Posted: Tue Aug 28, 2018 9:57 am
by jimmy
The outputs for each class are located in the Class documentation. Here is an example of the Class Muscle.

Re: Understanding the API: How to know the possible column names

Posted: Tue Aug 28, 2018 10:05 am
by masterv
jimmy wrote:
Tue Aug 28, 2018 9:57 am
The outputs for each class are located in the Class documentation. Here is an example of the Class Muscle.
Thanks a lot, James. Just what I was looking for. :)

Re: Understanding the API: How to know the possible column names

Posted: Wed Aug 29, 2018 7:25 am
by jimmy
Also, there is a method to write components inputs and outputs to the terminal ;

Code: Select all

Component::printOutputInfo()

Component::printInputInfo()

Re: Understanding the API: How to know the possible column names

Posted: Wed Aug 29, 2018 7:55 am
by masterv
jimmy wrote:
Wed Aug 29, 2018 7:25 am
Also, there is a method to write components inputs and outputs to the terminal ;

Code: Select all

Component::printOutputInfo()

Component::printInputInfo()
That's even more beautiful. Thank you :)