23 #include "worldsimconfig.h"
25 #include "phyobject.h"
28 #include "wquaternion.h"
35 class PhyJointPrivate;
36 class PhyObjectPrivate;
50 class FARSA_WSIM_API
PhyDOF :
public QObject {
63 this->istranslate = translate;
64 this->centrev = centre;
75 maxvelocityv = 1.5708f;
127 void setCentre(
const wVector& cent ) {
128 this->centrev = cent;
139 void setPosition(
real newpos ) {
141 emit changedPosition( newpos );
149 void setVelocity(
real newvel ) {
151 emit changedVelocity( newvel );
168 stiffnessv =
ramp( 0.0f, 0.99f, newstiff );
169 emit changedStiffness( stiffnessv );
174 maxvelocityv = maxvel;
184 maxforcev = maxforce;
197 void setAxis(
const wVector& ax ) {
206 void setXAxis(
const wVector& x_ax ) {
215 void setYAxis(
const wVector& y_ax ) {
255 emit appliedForce( newforce );
263 real offset = (fabs(hilimit)-fabs(lolimit))*0.005;
264 desiredPos =
ramp( lolimit+offset, hilimit-offset, wishpos );
267 emit changedDesiredPosition( wishpos );
274 desiredVel = wishvel;
276 emit changedDesiredVelocity( wishvel );
287 if ( !istranslate && lowlimit <= -PI_GRECO ) {
288 qDebug() <<
"DOF Lower Limit must be greater than -pi";
290 if ( !istranslate && highlimit >= PI_GRECO ) {
291 qDebug() <<
"DOF Higher Limit must be lesser that pi";
297 real offset = (fabs(hilimit)-fabs(lolimit))*0.005;
298 desiredPos =
ramp( lolimit+offset, hilimit-offset, desiredPos );
299 emit changedLimits( lolimit, hilimit );
304 void appliedForce(
real newforce );
306 void changedDesiredPosition(
real wishpos );
308 void changedDesiredVelocity(
real wishvel );
310 void changedPosition(
real newpos );
312 void changedVelocity(
real newvel );
314 void changedStiffness(
real newstiff );
316 void changedLimits(
real lowlimit,
real highlimit );
331 MotionMode motionMode;
391 virtual QVector<PhyDOF*>
dofs() {
395 void enable(
bool b );
402 virtual wVector centre()
const = 0;
406 virtual wVector getForceOnJoint()
const = 0;
409 virtual void updateJointInfo() = 0;
438 QVector<PhyDOF*> dofsv;
452 PhyObjectPrivate* parentpriv;
453 PhyObjectPrivate* childpriv;
454 WorldPrivate* worldpriv;
455 friend class PhyJointPrivate;
456 virtual void updateJoint(
real timestep ) = 0;
void limits(real &lo, real &hi) const
return the limits
virtual void postUpdate()
postUpdate the PhyJoint this method is called at each step of the world just after the physic update ...
World * world()
Return the World.
void setLimits(real lowlimit, real highlimit)
Set limits of this DOF The meaning of parameters changes depending if it's a rotational or translatio...
wVector centre() const
return the centre of rotation/translation
void setStiffness(real newstiff)
set the stiffness about this DOF
virtual const PhyObject * parent() const
Return the parent object; (NULL means an object attached to static world; see Netwon Documentation) (...
wVector yAxis() const
return the Y axis of local DOF frame
void setMaxForce(real maxforce)
sets the maximum force/torque applied by the joint.
bool isEnabled() const
Return true if the joint is enabled.
FARSA_UTIL_TEMPLATE real ramp(real minv, real maxv, real value)
The base for all class that can have (and can be) an owner.
real velocity() const
return the actual relative velocity of bodies along the axis of rotation/translation ...
void switchOff()
Switches the motor off.
real position() const
return the actual position of bodies For rotational DOF is the angle of rotation For linear DOF is t...
virtual QVector< PhyDOF * > dofs()
Return descriptions of DOF.
MotionMode
Type that encode the current modality of motion (off means motor switched off)
wVector xAxis() const
return the X axis of local DOF frame, this is the zero angle position
void setDesiredVelocity(real wishvel)
Accelerate the DOF to the velocity passed and try to stay at that velocity.
PhyObject * childv
child object
virtual unsigned int numDofs() const
Return the number of DOF constrained by this joint.
bool translate() const
return true if it translate along axis
PhyObject * parentv
parent object
PhyJointPrivate * priv
Engine encapsulation.
real appliedForce() const
Return the Force/Torque applied using applyForce.
real stiffness() const
return the stiffness
virtual PhyObject * parent()
Return the parent object; (NULL means an object attached to static world; see Netwon Documentation) ...
const PhyJoint * joint() const
return the PhyJoint (const version)
void setDesiredPosition(real wishpos)
Move the DOF at the position passed and try to stay there.
real maxForce() const
returns the maximum force/torque.
real desiredVelocity() const
Return the desired position setted.
MotionMode motion() const
return the actual motion mode
const World * world() const
Return the World (const version)
virtual void preUpdate()
preUpdate the PhyJoint this method is called at each step of the world just before the physic update ...
void setMaxVelocity(real maxvel)
set the maximum velocity for the joint (rad/sec)
bool rotate() const
return true if it rotate around axis
void enableLimits()
enable limits
bool enabled
true if is enabled, false otherwise
wVector axis() const
return the axis of rotation/translation
virtual const PhyObject * child() const
Return the child object attached to this joint (see Newton Documentation) (const version) ...
void setMotionMode(enum MotionMode m)
change the modality of motion
real desiredPosition() const
Return the desired position setted.
void disableLimits()
enable limits
PhyDOF(PhyJoint *parent, wVector axis, wVector centre, bool translate=false)
constructor (it's used by PhyJoint subclasses)
virtual PhyObject * child()
Return the child object attached to this joint (see Newton Documentation)
real maxVelocity() const
return the maximum velocity (rad/sec)
PhyJoint * joint()
return the PhyJoint
void applyForce(real newforce)
Apply a Force to the object linked by this DOF.
bool isLimited() const
return true if rotation/translation are limited