NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
RPLengthController_rand.cpp
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 #include <iostream>
28 #include <fstream>
29 #include <string>
30 // This module
31 #include "RPLengthController.h"
32 // This application
33 #include "../../../yamlbuilder/TensegrityModel.h"
34 // This library
35 #include "core/tgBasicActuator.h"
36 #include "core/tgCast.h"
37 // The C++ Standard Library
38 #include <cassert>
39 #include <stdexcept>
40 #include <time.h>
41 
42 using namespace std;
43 
45  m_length(length)
46 {
47  if (length < 0.0)
48  {
49  throw std::invalid_argument("Negative length");
50  }
51 }
52 
54 {
55 }
56 
58 {
59 
60  actuators = subject.getAllActuators();
61 
62 }
63 
65 {
66  if (dt <= 0.0) {
67  throw std::invalid_argument("dt is not positive");
68  }
69  else {
70  for (int k = 0; k < (actuators.size()-1); k++) {
71  //std::cout << k << ": " << actuators[k]->getTension() << ", ";
72  std::cout << actuators[k] -> getTension() << ", ";
73  }
74  std::cout << actuators[actuators.size()-1] -> getTension() << std::endl;
75  }
76 }
77 
virtual void onStep(TensegrityModel &subject, double dt)
Utility class for class casting and filtering collections by type.
const std::vector< tgSpringCableActuator * > & getAllActuators() const
Contains the definition of class tgBasicActuator.
virtual void onSetup(TensegrityModel &subject)
RPLengthController(const double length=400)