NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgLinearStringInfo.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 "tgLinearStringInfo.h"
27 
28 #include "core/Muscle2P.h"
29 
31 m_config(config),
33 {}
34 
36 m_config(config),
37 tgConnectorInfo(tags)
38 {}
39 
41 m_config(config),
42 tgConnectorInfo(pair)
43 {}
44 
45 
47 {
48  return new tgLinearStringInfo(m_config, pair);
49 }
50 
51 void tgLinearStringInfo::initConnector(tgWorld& world)
52 {
53  // Note: Muscle2P holds pointers to things in the world, but it doesn't actually have any in-world representation.
54  m_muscle2P = createMuscle2P();
55 }
56 
57 tgModel* tgLinearStringInfo::createModel(tgWorld& world)
58 {
59  // Don't have to do anything in the world for a Muscle2P...
60  // @todo: set the name based on joined tags, or remove name from the model...
61  //std::cout << "tgLinearStringInfo::createModel" << std::endl;
62 
63  // ensure connector has been initialized
64  assert(m_muscle2P);
65  return new tgLinearString(m_muscle2P, getTags(), m_config);
66 }
67 
68 double tgLinearStringInfo::getMass()
69 {
70  // @todo: calculate a mass? Muscle2P doesn't have physics...
71  return 0;
72 }
73 
74 
75 Muscle2P* tgLinearStringInfo::createMuscle2P()
76 {
77  //std::cout << "tgLinearStringInfo::createMuscle2P()" << std::endl;
78 
79  //std::cout << " getFromRigidInfo(): " << getFromRigidInfo() << std::endl;
80  //std::cout << " getFromRigidInfo(): " << getFromRigidInfo()->getRigidInfoGroup() << std::endl;
81 
82  // @todo: need to check somewhere that the rigid bodies have been set...
83  btRigidBody* fromBody = getFromRigidBody();
84  btRigidBody* toBody = getToRigidBody();
85 
86  btVector3 from = getFromRigidInfo()->getConnectionPoint(getFrom(), getTo(), m_config.rotation);
87  btVector3 to = getToRigidInfo()->getConnectionPoint(getTo(), getFrom(), m_config.rotation);
88 
89  return new Muscle2P(fromBody, from, toBody, to, m_config.stiffness, m_config.damping);
90 }
91 
Definitions of classes Muscle2P and MuscleAnchor.
tgLinearStringInfo(const tgLinearString::Config &config)
virtual tgConnectorInfo * createConnectorInfo(const tgPair &pair)
Definition: tgPair.h:47
Definition of class tgLinearStringInfo.
virtual btVector3 getConnectionPoint(const btVector3 &referencePoint, const btVector3 &destinationPoint) const =0
Definition: tgTags.h:43