NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
T6TensionController.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
27 // This module
28 #include "T6TensionController.h"
29 // This application
30 #include "T6Model.h"
31 // This library
32 #include "core/tgLinearString.h"
33 // The C++ Standard Library
34 #include <cassert>
35 #include <stdexcept>
36 #include <vector>
37 
39  m_tension(tension)
40 {
41  if (tension < 0.0)
42  {
43  throw std::invalid_argument("Negative tension");
44  }
45 }
46 
47 void T6TensionController::onStep(T6Model& subject, double dt)
48 {
49  if (dt <= 0.0)
50  {
51  throw std::invalid_argument("dt is not positive");
52  }
53  else
54  {
55  const std::vector<tgLinearString*> muscles = subject.getAllMuscles();
56  for (size_t i = 0; i < muscles.size(); ++i)
57  {
58  tgLinearString * const pMuscle = muscles[i];
59  assert(pMuscle != NULL);
60  pMuscle->tensionMinLengthController(m_tension, dt);
61  }
62  }
63 }
Contains the definition of class T6Model. $Id$.
virtual void onStep(T6Model &subject, double dt)
virtual void tensionMinLengthController(const double targetTension, float dt)
Contains the definition of class tgLinearString.
Contains the definition of class T6TensionController.
const std::vector< tgLinearString * > & getAllMuscles() const
Definition: T6Model.cpp:234
T6TensionController(const double tension=.01)