From 1ed2797955836050c1a84121c1fbd053f96b646f Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 16 Jan 2013 17:00:30 +0100 Subject: LocomotorPrimitivesController: Fix to read correct data from storage --- LocomotorPrimitivesController.cpp | 59 +++++++++++---------------------------- 1 file changed, 16 insertions(+), 43 deletions(-) (limited to 'LocomotorPrimitivesController.cpp') diff --git a/LocomotorPrimitivesController.cpp b/LocomotorPrimitivesController.cpp index d22ee71..69f7c72 100644 --- a/LocomotorPrimitivesController.cpp +++ b/LocomotorPrimitivesController.cpp @@ -13,54 +13,27 @@ void LocomotorPrimitivesController::computeControls(const SimTK::State &s, SimTK /* Extract muscle activation for each of the muscles */ int act_set_siz = getActuatorSet().getSize(); + int nc = _act.getSmallestNumberOfStates(); + + // Get the first nc states at a specified time (_NOT_ the state at nc as + // with getData()). + _act.getDataAtTime(t, nc, _muscle_act); + 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()); + const OpenSim::Muscle *muscle = dynamic_cast(&getActuatorSet().get(i)); + const OpenSim::Array indices = _act.getColumnIndicesForIdentifier(muscle->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; + int idx = indices.get(0) - 1; + std::cout << t << " (" << idx << ") actuation data for '" << muscle->getName() << "' found: " << _muscle_act[idx] << std::endl; + + SimTK::Vector ctrl(1, _muscle_act[idx]); + muscle->addInControls(ctrl, controls); + } else { + std::cerr << "Error: no actuation data for muscle '" << muscle->getName() << "' at time " << t << " found" << std::endl; + continue; } //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")); - const OpenSim::Muscle *ercspn_l = dynamic_cast(&getActuatorSet().get("ercspn_l")); - const OpenSim::Muscle *extobl_r = dynamic_cast(&getActuatorSet().get("extobl_r")); - const OpenSim::Muscle *extobl_l = dynamic_cast(&getActuatorSet().get("extobl_l")); - - double v = rectfem->getLengtheningSpeed(s); - double act = v * _alpha; - - if (act < 0.0) - act = 0.0; - if (act > 1.0) - act = 1.0; - - if (t - last_twitch < TIME_DAMP) - act = 0.0; - - if (act > 0.0) - last_twitch = t; - - //if (VERBOSE && act > 0.0) - // std::cout << "(" << std::fixed << t << ") " << "v=" << std::fixed << v << ", act=" << std::fixed << act << std::endl; - - SimTK::Vector ctrl_rectfem(1, act); - SimTK::Vector ctrl_extobl(1, 0.79); - SimTK::Vector ctrl_ercsp(1, 0.375); - - rectfem->addInControls(ctrl_rectfem, controls); - - ercspn_r->addInControls(ctrl_ercsp, controls); - ercspn_l->addInControls(ctrl_ercsp, controls); - extobl_r->addInControls(ctrl_extobl, controls); - extobl_l->addInControls(ctrl_extobl, controls); -#endif } -- cgit v1.2.3-54-g00ecf space:mode:
authorIngo Molnar <mingo@kernel.org>2016-07-10 20:58:36 +0200
committerIngo Molnar <mingo@kernel.org>2016-07-10 20:58:36 +0200
commit44530d588e142a96cf0cd345a7cb8911c4f88720 (patch)
treef1b2a9d46904fd3479c320267691ee89d172b3dc /tools/arch
parent46866b59dfbe9bf99bb1323ce1f3fd2073a81aa3 (diff)
Revert "perf/x86/intel, watchdog: Switch NMI watchdog to ref cycles on x86"
This reverts commit 2c95afc1e83d93fac3be6923465e1753c2c53b0a. Stephane reported the following regression: > Since Andi added: > > commit 2c95afc1e83d93fac3be6923465e1753c2c53b0a > Author: Andi Kleen <ak@linux.intel.com> > Date: Thu Jun 9 06:14:38 2016 -0700 > > perf/x86/intel, watchdog: Switch NMI watchdog to ref cycles on x86 > > $ perf stat -e ref-cycles ls > <not counted> .... > > fails systematically because the ref-cycles is now used by the > watchdog and given this is a system-wide pinned event, it monopolizes > the fixed counter 2 which is the only counter able to measure this event. Since the next merge window is near, fix the regression for now by reverting the commit. Reported-by: Stephane Eranian <eranian@google.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/arch')