32 #include "LinearMath/btQuickprof.h"
42 void tgBasicActuator::constructorAux()
45 assert(m_pHistory != NULL);
47 if (m_springCable == NULL)
49 throw std::invalid_argument(
"Pointer to tgBulletSpringCable is NULL.");
51 else if (m_config.targetVelocity < 0.0)
53 throw std::invalid_argument(
"Target velocity is negative.");
55 else if (m_config.minActualLength < 0.0)
57 throw std::invalid_argument(
"Minimum length is negative.");
68 m_preferredLength(m_restLength)
99 BT_PROFILE(
"tgBasicActuator::step");
100 #endif //BT_NO_PROFILE
103 throw std::invalid_argument(
"dt is not positive.");
117 #ifndef BT_NO_PROFILE
118 BT_PROFILE(
"tgBasicActuator::onVisit");
119 #endif //BT_NO_PROFILE
123 void tgBasicActuator::logHistory()
141 throw std::invalid_argument(
"Rest length is negative.");
145 m_preferredLength = input;
153 throw std::invalid_argument(
"Rest length is negative.");
157 m_preferredLength = input;
160 assert(m_preferredLength == input);
177 assert(stiffness > 0.0);
185 if ((actualLength - m_preferredLength) * stiffness
192 const double fabsDiff = abs(diff);
201 if (abs(diff) > stepSize)
203 m_restLength += (diff/fabsDiff)*stepSize;
207 m_restLength += diff;
217 std::cout <<
"RL: " << m_restLength
219 <<
" prev Vel: " << prevVel
220 <<
" force " << (actualLength - m_restLength)*stiffness << std::endl;
227 bool tgBasicActuator::invariant()
const
234 (m_preferredLength >= 0.0);
virtual void setRestLength(const double newRestLength)
virtual void setup(tgWorld &world)
tgBasicActuator(tgBulletSpringCable *muscle, const tgTags &tags, tgSpringCableActuator::Config &config)
virtual void moveMotors(double dt)
virtual const double getVelocity() const
std::deque< double > tensionHistory
std::deque< double > dampingHistory
std::deque< double > restLengths
virtual void step(double dt)
virtual void setControlInput(double input)
virtual void step(double dt)
virtual void setup(tgWorld &world)
std::deque< double > lastVelocities
virtual const double getRestLength() const
tgSpringCable * m_springCable
virtual void render(const tgRod &rod) const
std::deque< double > lastLengths
virtual ~tgBasicActuator()
Contains the definition of interface class tgModelVisitor.
Contains the definition of class tgBasicActuator.
virtual const double getCoefK() const
Contains the definition of class tgWorld $Id$.
virtual const double getTension() const =0
virtual const double getDamping() const
Definitions of classes tgBulletSpringCable $Id$.
virtual const double getActualLength() const =0
virtual void onVisit(const tgModelVisitor &r) const
SpringCableActuatorHistory *const m_pHistory
virtual void step(double dt)=0
void notifyStep(double dt)