opensim-core icon indicating copy to clipboard operation
opensim-core copied to clipboard

Add plot to doxygen for CoordinateLimitForce

Open chrisdembia opened this issue 7 years ago • 3 comments

Here's what I made for the TGCS example, based on feedback from Colin Smith.

coordinatelimitforce


hopper = BuildHopper();

state = hopper.initSystem();

import org.opensim.modeling.*;

N = 400;
hipAngle = linspace(-110, 130, N); % degrees.
force = zeros(1, N);
clf = CoordinateLimitForce.safeDownCast(hopper.getComponent('hip/hipLigaments'));
for i = 1:N
    hopper.setStateVariableValue(state, 'hip/hipFlexion/value', pi/180.*hipAngle(i));
    hopper.setStateVariableValue(state, 'hip/hipFlexion/speed', 0);
    hopper.realizeDynamics(state);
    force(i) = clf.calcLimitForce(state);
end
close all;
h = figure(1);
set(gcf, 'PaperPositionMode', 'auto');
set(h, 'Position', [0, 0, 400, 200]);
plot(hipAngle, force, 'k', 'LineWidth', 2);
ylim([-400, 400]);
xlim([-110, 130]);
hold on;

plot([-110, 130], [0, 0], 'k', 'LineWidth', 0.5);
plot(-90*[1, 1], [-400, 400], 'k--', 'LineWidth', 1.5);
plot(-100*[1, 1], [-400, 200], 'k--', 'LineWidth', 1.5);
plot(110*[1, 1], [-400, 400], 'k--', 'LineWidth', 1.5);
plot(120*[1, 1], [-200, 400], 'k--', 'LineWidth', 1.5);

t = text(-90, -200, 'lower limit');
t.Rotation = 90;
t.HorizontalAlignment = 'center';
t.VerticalAlignment = 'top';

t = text(110, -200, 'upper limit');
t.Rotation = 90;
t.HorizontalAlignment = 'center';
t.VerticalAlignment = 'bottom';

t = text(-95, -200, 'transition');
t.HorizontalAlignment = 'center';
quiver(-90, -150, -10, 0, 'k--', 'LineWidth', 1.5);

t = text(-105, 350, 'lower stiffness');

t = text(125, -350, 'upper stiffness');
t.HorizontalAlignment = 'right';

xticks([-100, -90, 110, 120]);
ylabel('Force (N)');
xlabel('Joint Angle (degrees)');
breakxaxis([-85, 105])

print -dpng -r300 CoordinateLimitForce.png

chrisdembia avatar Jul 13 '17 09:07 chrisdembia

@jenhicks Do you know why this was made a 4.4? @tkuchida your student recently updated doxygen for StepFunction can that be reused here? Thanks

aymanhab avatar Apr 28 '22 15:04 aymanhab

(The StepFunction plot was added in PR #3169.) It's a different function so the image can't be reused here. The figure shown up top could be added to the documentation verbatim as an example (when the parameters are the following…), or could be generalized as was done for the Millard muscle curves (e.g., https://github.com/opensim-org/opensim-core/blob/master/doc/images/fig_ForceVelocityCurve.png).

tkuchida avatar May 10 '22 01:05 tkuchida

Fixed in PR #3201 Please verify in latest build artifact

aymanhab avatar May 11 '22 17:05 aymanhab