44 tgCPGMGActuatorControl::tgCPGMGActuatorControl(
const double controlStep) :
47 m_controlStep(controlStep),
48 m_commandedTension(0.0),
52 if (m_controlStep < 0.0)
54 throw std::invalid_argument(
"Negative control step");
58 tgCPGMGActuatorControl::~tgCPGMGActuatorControl()
70 std::vector<const tgBulletSpringCableAnchor*> anchors =
73 std::size_t n = anchors.size();
76 m_pFromBody = anchors[0]->attachedBody;
77 m_pToBody = anchors[n - 1]->attachedBody;
88 tgBasicActuator& m_sca = *(tgCast::cast<tgSpringCableActuator, tgBasicActuator>(subject));
93 m_commandedTension = motorControl().
control(m_sca,
m_controlTime, controlLength(), getCPGValue());
106 assert(m_nodeNumber == -1);
108 m_pCPGSystem = &CPGSys;
110 std::vector<double> params (7);
111 params[0] = nodeParams[0][0];
112 params[1] = nodeParams[0][0];
113 params[2] = nodeParams[0][1];
114 params[3] = nodeParams[0][1];
119 m_nodeNumber = m_pCPGSystem->addNode(params);
126 assert(m_nodeNumber >= 0);
130 std::vector<int> connectivityList;
131 std::vector<double> weights;
132 std::vector<double> phases;
137 for (
int i = 0; i < allStrings.size(); i++)
139 if (
this != allStrings[i])
142 assert(m_pCPGSystem == allStrings[i]->
getCPGSys());
144 const btRigidBody* theirFromGroup = allStrings[i]->getFromBody();
145 const btRigidBody* theirToGroup = allStrings[i]->getToBody();
148 if(m_pFromBody == theirFromGroup ||
149 m_pToBody == theirToGroup ||
150 m_pFromBody == theirToGroup ||
151 m_pToBody == theirFromGroup)
153 int theirMuscle = allStrings[i]->getNodeNumber();
156 int j = m_nodeNumber;
158 connectivityList.push_back(theirMuscle);
161 weights.push_back(edgeParams[k][j][0]);
162 phases.push_back(edgeParams[k][j][1]);
166 weights.push_back(edgeParams[j][k][0]);
167 phases.push_back(edgeParams[j][k][1]);
173 m_pCPGSystem->defineConnections(m_nodeNumber, connectivityList, weights, phases);
178 tgBaseCPGNode::setupControl(ipc);
182 double controlLength)
184 if (controlLength < 0.0)
186 throw std::invalid_argument(
"Negative control length");
189 m_controlLength = controlLength;
190 tgBaseCPGNode::setupControl(ipc);
Contains the definition of class ImpedanceControl. $Id$.
Definition of the tgCPGStringControl observer class.
Definitions of class tgSpringCable.
virtual void moveMotors(double dt)
void assignNodeNumber(CPGEquations &CPGSys, array_2D nodeParams)
virtual const double getStartLength() const
void setConnectivity(const std::vector< tgCPGMGActuatorControl * > &allStrings, array_3D edgeParams)
Utility class for class casting and filtering collections by type.
const double m_controlStep
virtual void onStep(tgSpringCableActuator &subject, double dt)
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
const CPGEquations * getCPGSys() const
Contains the definition of class tgBasicActuator.
virtual void onAttach(tgSpringCableActuator &subject)
virtual const std::vector< const tgSpringCableAnchor * > getAnchors() const =0
Definitions of class tgBulletSpringCableAnchor, formerly muscleAnchor.
Definition of class CPGEquations.
Definitions of class tgSpringCableAnchor.
double control(tgBasicController &mLocalController, double deltaTimeSeconds, double newPosition, double offsetVel=0)
Control Functions.
const tgSpringCable * getSpringCable() const