From d01cf2ea580d9411140bd7dec539c6ae7a8a39cd Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 10 Dec 2012 07:06:08 +0100 Subject: Read muscle activation from .sto --- LocomotorPrimitivesController.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'LocomotorPrimitivesController.cpp') diff --git a/LocomotorPrimitivesController.cpp b/LocomotorPrimitivesController.cpp index 84b6187..e4308bc 100644 --- a/LocomotorPrimitivesController.cpp +++ b/LocomotorPrimitivesController.cpp @@ -46,7 +46,7 @@ int LocomotorPrimitivesController::loadCsvData(const std::string &muscleName, co data.close(); - _act.push_back(p); + //_act.push_back(p); std::cout << ">>> loaded EMG profile for " << p.getName() << ", " << p.getIdx() << "/" << p.getCapacity() << std::endl; return 0; @@ -58,12 +58,22 @@ void LocomotorPrimitivesController::computeControls(const SimTK::State &s, SimTK static double last_twitch = t; /* Extract muscle activation for each of the muscles */ - for (std::vector::const_iterator it = _act.begin(); it != _act.end(); ++it) { - MuscleEMGProfile p = *it; + int act_set_siz = getActuatorSet().getSize(); + for (int i = 0; i < act_set_siz; i++) { + const OpenSim::Muscle *m = dynamic_cast(&getActuatorSet().get(i)); + const OpenSim::Array indices = _act.getColumnIndicesForIdentifier(m->getName()); + + if (indices.getSize() != 0) { + double muscle_act = 0.0; + + _act.getDataAtTime(t, indices.get(0), &muscle_act); + std::cout << indices.get(0) << " actuation data for '" << m->getName() << "' found: " << muscle_act << std::endl; + } //std::cout << " " << p.getName() << "(" << p.getIdx() << "/" << p.getCapacity() << ")" << std::endl; } +#if 0 //const OpenSim::Muscle *rectfem = dynamic_cast(&getActuatorSet().get("bifemlh_r")); const OpenSim::Muscle *rectfem = dynamic_cast(&getActuatorSet().get("rect_fem_r")); const OpenSim::Muscle *ercspn_r = dynamic_cast(&getActuatorSet().get("ercspn_r")); @@ -98,4 +108,5 @@ void LocomotorPrimitivesController::computeControls(const SimTK::State &s, SimTK ercspn_l->addInControls(ctrl_ercsp, controls); extobl_r->addInControls(ctrl_extobl, controls); extobl_l->addInControls(ctrl_extobl, controls); +#endif } \ No newline at end of file -- cgit v1.2.3-54-g00ecf