NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgDataLogger.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 
26 #include "tgDataLogger.h"
27 
28 #include "util/tgBaseCPGNode.h"
30 #include "core/tgRod.h"
31 
32 #include <iostream>
33 #include <fstream>
34 
35 tgDataLogger::tgDataLogger(std::string fileName) :
36 m_fileName(fileName)
37 {}
38 
41 
42 { }
43 
44 void tgDataLogger::render(const tgRod& rod) const
45 {
46  std::ofstream tgOutput;
47  tgOutput.open(m_fileName.c_str(), std::ios::app);
48 
49  btVector3 com = rod.centerOfMass();
50 
51  tgOutput << com[0] << ","
52  << com[1] << ","
53  << com[2] << ","
54  << rod.mass() << ",";
55 
56  tgOutput.close();
57 }
58 
60 {
61  std::ofstream tgOutput;
62  tgOutput.open(m_fileName.c_str(), std::ios::app);
63 
64  tgOutput << mSCA.getRestLength() << ","
65  << mSCA.getCurrentLength() << ","
66  << mSCA.getTension() << ",";
67 
68  tgOutput.close();
69 }
70 
71 void tgDataLogger::render(const tgModel& model) const
72 {
73 
74 }
virtual void render(const tgRod &rod) const
virtual const double getTension() const
Contains the definition of interface class tgDataLogger.
virtual btVector3 centerOfMass() const
Definition: tgBaseRigid.cpp:74
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
virtual ~tgDataLogger()
virtual const double getRestLength() const
virtual double mass() const
Definition: tgBaseRigid.h:65
Contains the definition of class tgRod.
virtual const double getCurrentLength() const
Definition of class tgBaseCPGNode.
Definition: tgRod.h:43