Skip to content

Commit

Permalink
Reverting API changes pt. 3 + more diff clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbianco committed Aug 29, 2023
1 parent 016d8bd commit bb4b8be
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 89 deletions.
10 changes: 4 additions & 6 deletions Applications/Scale/test/testScale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <OpenSim/Simulation/Model/ForceSet.h>
#include <OpenSim/Simulation/Model/Ligament.h>
#include <OpenSim/Simulation/Model/PhysicalOffsetFrame.h>
#include <OpenSim/Simulation/Model/GeometryPath.h>
#include <OpenSim/Simulation/SimbodyEngine/PinJoint.h>
#include <OpenSim/Simulation/SimbodyEngine/FreeJoint.h>
#include <OpenSim/Simulation/SimbodyEngine/EllipsoidJoint.h>
Expand Down Expand Up @@ -562,9 +561,8 @@ void scalePhysicalOffsetFrames()
const Vec3 offset1 = Vec3(0.2, 0.4, 0.6);
PathActuator* act1 = new PathActuator();
act1->setName("pathActuator1");
auto& path = act1->updPath<GeometryPath>();
path.appendNewPathPoint("point1a", model->updGround(), Vec3(0));
path.appendNewPathPoint("point1b", *body, offset1);
act1->addNewPathPoint("point1a", model->updGround(), Vec3(0));
act1->addNewPathPoint("point1b", *body, offset1);
body->addComponent(act1);

// Second PathActuator is attached to the Body via a POF. Both new
Expand All @@ -578,8 +576,8 @@ void scalePhysicalOffsetFrames()
PathActuator* act2 = new PathActuator();
act2->setName("pathActuator2");
auto& path2 = act2->updPath<GeometryPath>();
path2.appendNewPathPoint("point2a", model->updGround(), Vec3(0));
path2.appendNewPathPoint("point2b", *pof2, offset2);
act2->addNewPathPoint("point2a", model->updGround(), Vec3(0));
act2->addNewPathPoint("point2b", *pof2, offset2);
act1->addComponent(act2);

State& s = model->initSystem();
Expand Down
1 change: 0 additions & 1 deletion Bindings/Java/OpenSimJNI/Test/testContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <OpenSim/Simulation/Model/PathPoint.h>
#include <OpenSim/Simulation/Wrap/PathWrap.h>
#include <OpenSim/Simulation/Model/ConditionalPathPoint.h>
#include <OpenSim/Simulation/Model/GeometryPath.h>
#include <OpenSim/Simulation/SimbodyEngine/SimbodyEngine.h>
#include <OpenSim/Simulation/Wrap/WrapObject.h>
#include <OpenSim/Simulation/Model/Analysis.h>
Expand Down
10 changes: 4 additions & 6 deletions Bindings/Java/tests/TestBasics.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ public static void testMuscleList() {
Ground ground = model.getGround();
Thelen2003Muscle thelenMuscle =
new Thelen2003Muscle("Darryl", 1, 0.5, 0.5, 0);
GeometryPath pathThelen = thelenMuscle.initGeometryPath();
pathThelen.appendNewPathPoint("muscle1-point1", ground, new Vec3(0.0,0.0,0.0));
pathThelen.appendNewPathPoint("muscle1-point2", ground, new Vec3(1.0,0.0,0.0));
thelenMuscle.addNewPathPoint("muscle1-point1", ground, new Vec3(0.0,0.0,0.0));
thelenMuscle.addNewPathPoint("muscle1-point2", ground, new Vec3(1.0,0.0,0.0));
Millard2012EquilibriumMuscle millardMuscle =
new Millard2012EquilibriumMuscle("Matt", 1, 0.5, 0.5, 0);
GeometryPath pathMillard = millardMuscle.initGeometryPath();
pathMillard.appendNewPathPoint("muscle1-point1", ground, new Vec3(0.0,0.0,0.0));
pathMillard.appendNewPathPoint("muscle1-point2", ground, new Vec3(1.0,0.0,0.0));
millardMuscle.addNewPathPoint("muscle1-point1", ground, new Vec3(0.0,0.0,0.0));
millardMuscle.addNewPathPoint("muscle1-point2", ground, new Vec3(1.0,0.0,0.0));
model.addComponent(thelenMuscle);
model.addComponent(millardMuscle);

Expand Down
5 changes: 2 additions & 3 deletions Bindings/Java/tests/TestModelBuilding.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public static void main(String[] args) {
0.6, // Optimal fibre length
0.55, // Tendon slack length
0.0); // Pennation angle
GeometryPath pathBiceps = biceps.initGeometryPath();
pathBiceps.appendNewPathPoint("origin", hum, ArrayDouble.createVec3(new double[]{0, 0.8, 0}));
pathBiceps.appendNewPathPoint("insert", rad, ArrayDouble.createVec3(new double[]{0, 0.7, 0}));
biceps.addNewPathPoint("origin", hum, ArrayDouble.createVec3(new double[]{0, 0.8, 0}));
biceps.addNewPathPoint("insert", rad, ArrayDouble.createVec3(new double[]{0, 0.7, 0}));

PrescribedController cns = new PrescribedController();
cns.addActuator(biceps);
Expand Down
5 changes: 2 additions & 3 deletions OpenSim/Actuators/Test/testActuators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,8 @@ void testMcKibbenActuator()
OpenSim::Body* ball = new OpenSim::Body("ball", mass, Vec3(0), mass*SimTK::Inertia::sphere(0.1));
ball->scale(Vec3(ball_radius), false);

auto& path = actuator->updPath<GeometryPath>();
path.appendNewPathPoint("mck_ground", ground, Vec3(0));
path.appendNewPathPoint("mck_ball", *ball, Vec3(ball_radius));
actuator->addNewPathPoint("mck_ground", ground, Vec3(0));
actuator->addNewPathPoint("mck_ball", *ball, Vec3(ball_radius));

Vec3 locationInParent(0, ball_radius, 0), orientationInParent(0), locationInBody(0), orientationInBody(0);
SliderJoint *ballToGround = new SliderJoint("ballToGround", ground, locationInParent, orientationInParent, *ball, locationInBody, orientationInBody);
Expand Down
6 changes: 2 additions & 4 deletions OpenSim/Actuators/Test/testModelProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ Model createElbowModel() {
// Add a muscle that flexes the elbow.
auto* biceps = new
Millard2012EquilibriumMuscle("biceps", 200, 0.6, 0.55, 0);

auto& path = biceps->updPath<GeometryPath>();
path.appendNewPathPoint("origin", model.getGround(), Vec3(0, 0.8, 0));
path.appendNewPathPoint("insertion", *body, Vec3(0, 0.7, 0));
biceps->addNewPathPoint("origin", model.getGround(), Vec3(0, 0.8, 0));
biceps->addNewPathPoint("insertion", *body, Vec3(0, 0.7, 0));

model.addBody(body);
model.addJoint(joint);
Expand Down
35 changes: 14 additions & 21 deletions OpenSim/Actuators/Test/testMuscles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,8 @@ void simulateMuscle(
//Attach the muscle
const string &actuatorType = aMuscle->getConcreteClassName();
aMuscle->setName("muscle");
auto& path = aMuscle->updPath<GeometryPath>();
path.appendNewPathPoint("muscle-box", ground, Vec3(anchorWidth/2,0,0));
path.appendNewPathPoint("muscle-ball", *ball, Vec3(-ballRadius,0,0));
aMuscle->addNewPathPoint("muscle-box", ground, Vec3(anchorWidth/2,0,0));
aMuscle->addNewPathPoint("muscle-ball", *ball, Vec3(-ballRadius,0,0));

ActivationFiberLengthMuscle_Deprecated *aflMuscle
= dynamic_cast<ActivationFiberLengthMuscle_Deprecated *>(aMuscle);
Expand Down Expand Up @@ -608,9 +607,8 @@ void testThelen2003Muscle()
false);

Model m;
auto& path = muscle.updPath<GeometryPath>();
path.appendNewPathPoint("p1", m.getGround(), SimTK::Vec3(0.0));
path.appendNewPathPoint("p2", m.getGround(), SimTK::Vec3(1.0));
muscle.addNewPathPoint("p1", m.getGround(), SimTK::Vec3(0.0));
muscle.addNewPathPoint("p2", m.getGround(), SimTK::Vec3(1.0));
// Test property bounds.
{
Thelen2003Muscle musc = muscle;
Expand Down Expand Up @@ -700,9 +698,8 @@ void testThelen2003Muscle()
MaxIsometricForce0, OptimalFiberLength0, TendonSlackLength0,
PennationAngle0);

auto& path = myMcl->updPath<GeometryPath>();
path.appendNewPathPoint("p1", myModel.getGround(), SimTK::Vec3(0.0));
path.appendNewPathPoint("p2", myModel.getGround(), SimTK::Vec3(1.0));
myMcl->addNewPathPoint("p1", myModel.getGround(), SimTK::Vec3(0.0));
myMcl->addNewPathPoint("p2", myModel.getGround(), SimTK::Vec3(1.0));
myModel.addForce(myMcl);

// Set properties of Thelen2003Muscle.
Expand Down Expand Up @@ -786,9 +783,8 @@ void testThelen2003Muscle()
const double tendonSlackLength = 0.001;
auto muscle = new Thelen2003Muscle("muscle", 1., optimalFiberLength,
tendonSlackLength, 0.);
auto& path = muscle->updPath<GeometryPath>();
path.appendNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
path.appendNewPathPoint("p2", model.updGround(), SimTK::Vec3(0,0,1));
muscle->addNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
muscle->addNewPathPoint("p2", model.updGround(), SimTK::Vec3(0,0,1));
model.addForce(muscle);

SimTK::State& state = model.initSystem();
Expand All @@ -802,9 +798,8 @@ void testThelen2003Muscle()
{
Model model;
auto muscle = new Thelen2003Muscle("muscle", 1., 0.5, 0.5, 0.);
auto& path = muscle->updPath<GeometryPath>();
path.appendNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
path.appendNewPathPoint("p2", model.updGround(), SimTK::Vec3(0,0,1));
muscle->addNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
muscle->addNewPathPoint("p2", model.updGround(), SimTK::Vec3(0,0,1));
model.addForce(muscle);
model.finalizeFromProperties();

Expand Down Expand Up @@ -897,9 +892,8 @@ void testMillard2012EquilibriumMuscle()
const double tendonSlackLength = 0.1; //short tendon
auto muscle = new Millard2012EquilibriumMuscle("muscle", 1.,
optimalFiberLength, tendonSlackLength, 0.);
auto& path = muscle->updPath<GeometryPath>();
path.appendNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
path.appendNewPathPoint("p2", model.updGround(), SimTK::Vec3(0, 0, 1));
muscle->addNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
muscle->addNewPathPoint("p2", model.updGround(), SimTK::Vec3(0, 0, 1));
model.addForce(muscle);

SimTK::State& state = model.initSystem();
Expand All @@ -914,9 +908,8 @@ void testMillard2012EquilibriumMuscle()
{
Model model;
auto muscle = new Millard2012EquilibriumMuscle("mcl", 1., 0.5, 0.5, 0.);
auto& path = muscle->updPath<GeometryPath>();
path.appendNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
path.appendNewPathPoint("p2", model.updGround(), SimTK::Vec3(0,0,1));
muscle->addNewPathPoint("p1", model.updGround(), SimTK::Vec3(0));
muscle->addNewPathPoint("p2", model.updGround(), SimTK::Vec3(0,0,1));
model.addForce(muscle);
model.finalizeFromProperties();

Expand Down
5 changes: 2 additions & 3 deletions OpenSim/Analyses/Test/testOutputReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ void simulateMuscle(
//Attach the muscle
/*const string &actuatorType = */muscle->getConcreteClassName();
muscle->setName("muscle");
auto& path = muscle->updPath<GeometryPath>();
path.appendNewPathPoint("muscle-box", ground, Vec3(anchorWidth / 2, 0, 0));
path.appendNewPathPoint("muscle-ball", *ball, Vec3(-ballRadius, 0, 0));
muscle->addNewPathPoint("muscle-box", ground, Vec3(anchorWidth / 2, 0, 0));
muscle->addNewPathPoint("muscle-ball", *ball, Vec3(-ballRadius, 0, 0));

model.addForce(muscle);

Expand Down
3 changes: 1 addition & 2 deletions OpenSim/Examples/ExampleHopperDevice/buildDeviceModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ Device* buildDevice() {
auto pathActuator = new PathActuator();
pathActuator->setName("cableAtoB");
pathActuator->set_optimal_force(OPTIMAL_FORCE);
auto& path = pathActuator->updPath<GeometryPath>();
path.appendNewPathPoint("pointA", *cuffA, Vec3(0));
pathActuator->addNewPathPoint("pointA", *cuffA, Vec3(0));
//pathActuator->addNewPathPoint("pointB", *cuffB, Vec3(0));
device->addComponent(pathActuator);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ Device* buildDevice() {
auto pathActuator = new PathActuator();
pathActuator->setName("cableAtoB");
pathActuator->set_optimal_force(OPTIMAL_FORCE);
auto& path = pathActuator->updPath<GeometryPath>();
path.appendNewPathPoint("pointA", *cuffA, Vec3(0));
path.appendNewPathPoint("pointB", *cuffB, Vec3(0));
pathActuator->addNewPathPoint("pointA", *cuffA, Vec3(0));
pathActuator->addNewPathPoint("pointB", *cuffB, Vec3(0));
device->addComponent(pathActuator);

// Create a PropMyoController.
Expand Down
7 changes: 3 additions & 4 deletions OpenSim/Examples/ExampleHopperDevice/buildHopperModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ Model buildHopper(bool showVisualizer) {
mclPennAng = 0.;
auto vastus = new Thelen2003Muscle("vastus", mclFmax, mclOptFibLen,
mclTendonSlackLen, mclPennAng);
auto& path = vastus->updPath<GeometryPath>();
path.appendNewPathPoint("origin", *thigh, Vec3(linkRadius, 0.1, 0));
path.appendNewPathPoint("insertion", *shank, Vec3(linkRadius, 0.15, 0));
vastus->addNewPathPoint("origin", *thigh, Vec3(linkRadius, 0.1, 0));
vastus->addNewPathPoint("insertion", *shank, Vec3(linkRadius, 0.15, 0));
hopper.addForce(vastus);

// Attach a cylinder (patella) to the distal end of the thigh over which the
Expand All @@ -163,7 +162,7 @@ Model buildHopper(bool showVisualizer) {
thigh->addComponent(patellaFrame);

// Configure the vastus muscle to wrap over the patella.
path.addPathWrap(*patella);
vastus->updGeometryPath().addPathWrap(*patella);

// Create a controller to excite the vastus muscle.
auto brain = new PrescribedController();
Expand Down
3 changes: 1 addition & 2 deletions OpenSim/Examples/ExampleHopperDevice/exampleHopperDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ void connectDeviceToModel(OpenSim::Device& device, OpenSim::Model& model,
if (model.hasComponent<WrapCylinder>(patellaPath)) {
auto& cable = model.updComponent<PathActuator>("device/cableAtoB");
auto& wrapObject = model.updComponent<WrapCylinder>(patellaPath);
auto& path = cable.updPath<GeometryPath>();
path.addPathWrap(wrapObject);
cable.updGeometryPath().addPathWrap(wrapObject);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ void connectDeviceToModel(OpenSim::Device& device, OpenSim::Model& model,
if (model.hasComponent<WrapCylinder>(patellaPath)) {
auto& cable = model.updComponent<PathActuator>("device/cableAtoB");
auto& wrapObject = model.updComponent<WrapCylinder>(patellaPath);
auto& path = cable.updPath<GeometryPath>();
path.addPathWrap(wrapObject);
cable.updGeometryPath().addPathWrap(wrapObject);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,9 @@ void createLuxoJr(OpenSim::Model& model){
"knee_extensor_right",
knee_extensor_F0, knee_extensor_lm0,
knee_extensor_lts, pennationAngle);
auto& pathKneeRight = kneeExtensorRight->updPath<GeometryPath>();
pathKneeRight.appendNewPathPoint("knee_extensor_right_origin", *leg_Hlink,
kneeExtensorRight->addNewPathPoint("knee_extensor_right_origin", *leg_Hlink,
knee_extensor_origin);
pathKneeRight.appendNewPathPoint("knee_extensor_right_insertion",
kneeExtensorRight->addNewPathPoint("knee_extensor_right_insertion",
*bottom_bracket,
knee_extensor_insertion);
kneeExtensorRight->set_ignore_tendon_compliance(true);
Expand All @@ -728,15 +727,14 @@ void createLuxoJr(OpenSim::Model& model){
knee_extensor_F0, knee_extensor_lm0,
knee_extensor_lts, pennationAngle);

auto& pathKneeLeft = kneeExtensorLeft->updPath<GeometryPath>();
pathKneeLeft.appendNewPathPoint("knee_extensor_left_origin", *leg_Hlink,
kneeExtensorLeft->addNewPathPoint("knee_extensor_left_origin", *leg_Hlink,
knee_extensor_origin);
pathKneeLeft.appendNewPathPoint("knee_extensor_left_insertion",
kneeExtensorLeft->addNewPathPoint("knee_extensor_left_insertion",
*bottom_bracket,
knee_extensor_insertion);

// flip the z coordinates of all path points
PathPointSet& points = pathKneeLeft.updPathPointSet();
PathPointSet& points = kneeExtensorLeft->updGeometryPath().updPathPointSet();
for (int i=0; i<points.getSize(); ++i) {
dynamic_cast<PathPoint&>(points[i]).upd_location()[2] *= -1;
}
Expand All @@ -750,10 +748,9 @@ void createLuxoJr(OpenSim::Model& model){
back_extensor_F0, back_extensor_lm0,
back_extensor_lts, pennationAngle);

auto& pathBackRight = backExtensorRight->updPath<GeometryPath>();
pathBackRight.appendNewPathPoint("back_extensor_right_origin", *chest,
backExtensorRight->addNewPathPoint("back_extensor_right_origin", *chest,
back_extensor_origin);
pathBackRight.appendNewPathPoint("back_extensor_right_insertion", *back,
backExtensorRight->addNewPathPoint("back_extensor_right_insertion", *back,
back_extensor_insertion);
backExtensorRight->set_ignore_tendon_compliance(true);
model.addForce(backExtensorRight);
Expand All @@ -764,13 +761,13 @@ void createLuxoJr(OpenSim::Model& model){
back_extensor_F0, back_extensor_lm0,
back_extensor_lts, pennationAngle);

auto& pathBackLeft = backExtensorLeft->updPath<GeometryPath>();
pathBackLeft.appendNewPathPoint("back_extensor_left_origin", *chest,
backExtensorLeft->addNewPathPoint("back_extensor_left_origin", *chest,
back_extensor_origin);
pathBackLeft.appendNewPathPoint("back_extensor_left_insertion", *back,
backExtensorLeft->addNewPathPoint("back_extensor_left_insertion", *back,
back_extensor_insertion);

PathPointSet& pointsLeft = pathBackLeft.updPathPointSet();
PathPointSet& pointsLeft = backExtensorLeft->updGeometryPath()
.updPathPointSet();
for (int i=0; i<points.getSize(); ++i) {
dynamic_cast<PathPoint&>(pointsLeft[i]).upd_location()[2] *= -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,11 @@ int main()

// Specify the paths for the two muscles
// Path for muscle 1
auto& path1 = muscle1->updPath<GeometryPath>();
path1.appendNewPathPoint("muscle1-point1", ground, Vec3(0.0,0.05,-0.35));
path1.appendNewPathPoint("muscle1-point2", *block, Vec3(0.0,0.0,-0.05));
muscle1->addNewPathPoint("muscle1-point1", ground, Vec3(0.0,0.05,-0.35));
muscle1->addNewPathPoint("muscle1-point2", *block, Vec3(0.0,0.0,-0.05));
// Path for muscle 2
auto& path2 = muscle2->updPath<GeometryPath>();
path2.appendNewPathPoint("muscle2-point1", ground, Vec3(0.0,0.05,0.35));
path2.appendNewPathPoint("muscle2-point2", *block, Vec3(0.0,0.0,0.05));
muscle2->addNewPathPoint("muscle2-point1", ground, Vec3(0.0,0.05,0.35));
muscle2->addNewPathPoint("muscle2-point2", *block, Vec3(0.0,0.0,0.05));

// Add the two muscles (as forces) to the model
osimModel.addForce(muscle1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ Model createHangingMuscleModel(bool ignoreActivationDynamics,
actu->set_tendon_compliance_dynamics_mode("implicit");
actu->set_max_contraction_velocity(10);
actu->set_pennation_angle_at_optimal(0.10);
auto& path = actu->updPath<GeometryPath>();
path.appendNewPathPoint("origin", model.updGround(), SimTK::Vec3(0));
path.appendNewPathPoint("insertion", *body, SimTK::Vec3(0));
actu->addNewPathPoint("origin", model.updGround(), SimTK::Vec3(0));
actu->addNewPathPoint("insertion", *body, SimTK::Vec3(0));
model.addForce(actu);

// Add metabolics probes: one for the total metabolic rate,
Expand Down
10 changes: 4 additions & 6 deletions OpenSim/Examples/MuscleExample/mainFatigue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,14 @@ int main()
pennationAngle);

// Define the path of the muscles
auto& fatigablePath = fatigable->updPath<GeometryPath>();
fatigablePath.appendNewPathPoint("fatigable-point1", ground,
fatigable->addNewPathPoint("fatigable-point1", ground,
Vec3(0.0, halfLength, -0.35));
fatigablePath.appendNewPathPoint("fatigable-point2", *block,
fatigable->addNewPathPoint("fatigable-point2", *block,
Vec3(0.0, halfLength, -halfLength));

auto& originalPath = original->updPath<GeometryPath>();
originalPath.appendNewPathPoint("original-point1", ground,
original->addNewPathPoint("original-point1", ground,
Vec3(0.0, halfLength, 0.35));
originalPath.appendNewPathPoint("original-point2", *block,
original->addNewPathPoint("original-point2", *block,
Vec3(0.0, halfLength, halfLength));

// Define the default states for the two muscles
Expand Down

0 comments on commit bb4b8be

Please sign in to comment.