33 #include "LinearMath/btQuickprof.h"
43 tgKinematicActuator::Config::Config(
double s,
57 mf, tVel, mnAL, mnRL, rot),
59 motorFriction(moFric),
60 motorInertia(moInert),
67 throw std::invalid_argument(
"Radius is non-positive");
69 else if (moFric < 0.0)
71 throw std::invalid_argument(
"Motor friction is negative.");
73 else if (moInert <= 0.0)
75 throw std::invalid_argument(
"Motor inertia is non-positive");
79 void tgKinematicActuator::constructorAux()
86 throw std::invalid_argument(
"Pointer to tgBulletSpringCable is NULL.");
90 throw std::invalid_argument(
"Target velocity is negative.");
94 throw std::invalid_argument(
"Minimum length is negative.");
136 #ifndef BT_NO_PROFILE
137 BT_PROFILE(
"tgKinematicActuator::step");
138 #endif //BT_NO_PROFILE
141 throw std::invalid_argument(
"dt is not positive.");
155 m_desiredTorque = 0.0;
160 #ifndef BT_NO_PROFILE
161 BT_PROFILE(
"tgKinematicActuator::onVisit");
162 #endif //BT_NO_PROFILE
166 void tgKinematicActuator::logHistory()
182 return m_motorVel * m_config.
radius;
191 m_motorAcc = (appliedTorque - m_config.
motorFriction * m_motorVel
194 if (!m_config.
backdrivable && m_motorAcc * appliedTorque <= 0.0)
197 m_motorVel = m_motorVel + m_motorAcc * dt > 0.0 ? 0.0 : m_motorVel + m_motorAcc * dt;
201 m_motorVel += m_motorAcc * dt;
220 maxTorque = maxTorque < 0.0 ? 0.0 : maxTorque;
222 return abs(desiredTorque) < maxTorque ? desiredTorque :
223 desiredTorque / abs(desiredTorque) * maxTorque;
228 m_desiredTorque = input;
236 bool tgKinematicActuator::invariant()
const
virtual void setRestLength(const double newRestLength)
virtual void setup(tgWorld &world)
virtual const double getVelocity() const
virtual void setup(tgWorld &world)
std::deque< double > tensionHistory
virtual double getAppliedTorque(double desiredTorque) const
virtual const double getTension() const
std::deque< double > dampingHistory
std::deque< double > restLengths
virtual void step(double dt)
virtual void setControlInput(double input)
std::deque< double > lastVelocities
virtual const double getRestLength() const
tgSpringCable * m_springCable
virtual void render(const tgRod &rod) const
std::deque< double > lastLengths
Contains the definition of interface class tgModelVisitor.
virtual ~tgKinematicActuator()
tgKinematicActuator(tgBulletSpringCable *muscle, const tgTags &tags, tgKinematicActuator::Config &config)
virtual void integrateRestLength(double dt)
Contains the definition of class tgWorld $Id$.
virtual const double getVelocity() const
virtual const double getTension() const =0
virtual const double getDamping() const
Contains the definition of class tgKinematicActuator.
Definitions of classes tgBulletSpringCable $Id$.
virtual void step(double dt)
virtual const double getActualLength() const =0
virtual const tgSpringCableActuator::SpringCableActuatorHistory & getHistory() const
virtual void onVisit(const tgModelVisitor &r) const
SpringCableActuatorHistory *const m_pHistory
virtual void step(double dt)=0
void notifyStep(double dt)