/** * Provide the value(s) to be reported that correspond to the labels */ OpenSim::Array<double> ElasticFoundationForce::getRecordValues(const SimTK::State& state) const { OpenSim::Array<double> values(1); const ContactParametersSet& contactParametersSet = get_contact_parameters(); const SimTK::ElasticFoundationForce& simtkForce = (SimTK::ElasticFoundationForce &)(_model->getForceSubsystem().getForce(_index)); SimTK::Vector_<SimTK::SpatialVec> bodyForces(0); SimTK::Vector_<SimTK::Vec3> particleForces(0); SimTK::Vector mobilityForces(0); //get the net force added to the system contributed by the Spring simtkForce.calcForceContribution(state, bodyForces, particleForces, mobilityForces); for (int i = 0; i < contactParametersSet.getSize(); ++i) { ContactParameters& params = contactParametersSet.get(i); for (int j = 0; j < params.getGeometry().size(); ++j) { ContactGeometry& geom = _model->updContactGeometrySet().get(params.getGeometry()[j]); std::string bodyName = geom.getBodyName(); SimTK::Vec3 forces = bodyForces(_model->getBodySet().get(bodyName).getIndex())[1]; SimTK::Vec3 torques = bodyForces(_model->getBodySet().get(bodyName).getIndex())[0]; values.append(3, &forces[0]); values.append(3, &torques[0]); } } return values; }
/** * Provide the value(s) to be reported that correspond to the labels */ OpenSim::Array<double> HuntCrossleyForce:: getRecordValues(const SimTK::State& state) const { OpenSim::Array<double> values(1); const ContactParametersSet& contactParametersSet = get_contact_parameters(); const auto& forceSubsys = _model->getForceSubsystem(); const SimTK::Force& abstractForce = forceSubsys.getForce(_index); const auto& simtkForce = (SimTK::HuntCrossleyForce &)(abstractForce); SimTK::Vector_<SimTK::SpatialVec> bodyForces(0); SimTK::Vector_<SimTK::Vec3> particleForces(0); SimTK::Vector mobilityForces(0); //get the net force added to the system contributed by the Spring simtkForce.calcForceContribution(state, bodyForces, particleForces, mobilityForces); for (int i = 0; i < contactParametersSet.getSize(); ++i) { ContactParameters& params = contactParametersSet.get(i); for (int j = 0; j < params.getGeometry().size(); ++j) { const ContactGeometry& geom = getModel().getComponent<ContactGeometry>(params.getGeometry()[j]); const auto& mbi = geom.getFrame().getMobilizedBodyIndex(); const auto& thisBodyForce = bodyForces(mbi); SimTK::Vec3 forces = thisBodyForce[1]; SimTK::Vec3 torques = thisBodyForce[0]; values.append(3, &forces[0]); values.append(3, &torques[0]); } } return values; }