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 // This module
29 #include "RPLengthController.h"
30 // This application
31 #include "../../../yamlbuilder/TensegrityModel.h"
32 // This library
33 #include "core/tgBasicActuator.h"
34 #include "core/tgCast.h"
35 // The C++ Standard Library
36 #include <cassert>
37 #include <stdexcept>
38 #include <time.h>
39 
40 using namespace std;
41 
42 RPLengthController::RPLengthController(const double length) :
43  m_length(length)
44 {
45  if (length < 0.0)
46  {
47  throw std::invalid_argument("Negative length");
48  }
49 }
50 
52 {
53 }
54 
56 {
57 
58  actuators = subject.getAllActuators();
59 
60 }
61 
62 void RPLengthController::onStep(TensegrityModel& subject, double dt)
63 {
64  if (dt <= 0.0)
65  {
66  throw std::invalid_argument("dt is not positive");
67  }
68  else{
69  for(int k=0;k<actuators.size();k++){
70  //std::cout << k << ": " << actuators[k]->getTension() << ", ";
71  std::cout << actuators[k]->getTension() << ", ";
72  }
73  std::cout << std::endl;
74  }
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)