motorcontrollers.cpp
142 void wheeledRobotsComputeKinematicMovement(wMatrix &mtr, real leftWheelVelocity, real rightWheelVelocity, real wheelr, real axletrack, real timestep)
214 // the wheel: which weels depends on its distance from C. We take the wheel which is furthest from
215 // C to avoid having r = 0 (which would lead to an invalid value of the angular velocity). Distances
219 const real angularVelocity = (fabs(distLeftWheel) > fabs(distRightWheel)) ? (-leftSpeed / distLeftWheel) : (-rightSpeed / distRightWheel);
222 // also compute the center of rotation in world coordinates (we also need to compute it in the frame
223 // of reference centered between the wheels, not in O) and the axis of rotation (that is simply the
226 const wVector centerOfRotation = origMtr.transformVector(C - wVector(axletrack / 2.0, 0.0, 0.0));
234 bool FARSA_WSIM_API wheeledRobotsComputeWheelsSpeed(const wMatrix& start, const wMatrix& end, real wheelr, real axletrack, real timestep, real& leftWheelVelocity, real& rightWheelVelocity)
254 const wVector& Xs = start.x_ax; FARSA_DEBUG_TEST_INVALID(Xs.x) FARSA_DEBUG_TEST_INVALID(Xs.y) FARSA_DEBUG_TEST_INVALID(Xs.z)
255 const wVector& Xe = end.x_ax; FARSA_DEBUG_TEST_INVALID(Xe.x) FARSA_DEBUG_TEST_INVALID(Xe.y) FARSA_DEBUG_TEST_INVALID(Xe.z)
257 const wVector displacementVector = end.w_pos - start.w_pos; FARSA_DEBUG_TEST_INVALID(displacementVector.x) FARSA_DEBUG_TEST_INVALID(displacementVector.y) FARSA_DEBUG_TEST_INVALID(displacementVector.z)
259 // If displacement is 0, direction will be invalid (the check for displacement != 0 is done below)
310 const real distCenterOfRotationToCenterOfRobot = displacement / 2.0f; FARSA_DEBUG_TEST_INVALID(distCenterOfRotationToCenterOfRobot)
311 const real slowWheel = (distCenterOfRotationToCenterOfRobot - halfAxletrack) * PI_GRECO; FARSA_DEBUG_TEST_INVALID(slowWheel)
312 const real fastWheel = (distCenterOfRotationToCenterOfRobot + halfAxletrack) * PI_GRECO; FARSA_DEBUG_TEST_INVALID(fastWheel)
357 const real rotationSign = (((Xs * Xe) % start.z_ax) < 0.0f) ? -1.0f : 1.0f; FARSA_DEBUG_TEST_INVALID(rotationSign)
373 leftWheelVelocity = (leftWheelDistance / wheelr) / timestep; FARSA_DEBUG_TEST_INVALID(leftWheelVelocity)
374 rightWheelVelocity = (rightWheelDistance / wheelr) / timestep; FARSA_DEBUG_TEST_INVALID(rightWheelVelocity)
448 void WheelMotorController::setSpeedLimits( QVector<double> minSpeeds, QVector<double> maxSpeeds ) {
453 void WheelMotorController::setSpeedLimits( double minSpeed1, double minSpeed2, double maxSpeed1, double maxSpeed2 ) {
460 void WheelMotorController::getSpeedLimits( QVector<double>& minSpeeds, QVector<double>& maxSpeeds ) const {
465 void WheelMotorController::getSpeedLimits( double& minSpeed1, double& minSpeed2, double& maxSpeed1, double& maxSpeed2 ) const {
482 MarXbotAttachmentDeviceMotorController::MarXbotAttachmentDeviceMotorController(PhyMarXbot* robot) :
544 m_joint = new PhyHinge(wVector(1.0, 0.0, 0.0), wVector(0.0, 0.0, 0.0), 0.0, m_attachedRobot->turret(), m_robot->attachmentDevice());
674 if ((otherRobot != NULL) && (otherRobot->attachmentDeviceEnabled()) && (!discardedRobots.contains(otherRobot))) {
687 // Now we have a set of candidates. In practice we should always have at most one candidate due to
688 // physical constraints. In case we have more than one, we simply return the first. If we have none,
PhyHinge * attachmentDeviceJoint()
Returns the joint of the attachment device.
Definition: phymarxbot.h:232
double getMaxVelocity() const
Returns the maximum speed at which the attachment device can move.
Definition: motorcontrollers.cpp:594
MarXbotAttachmentDeviceMotorController * attachmentDeviceController()
returns the motor controller for the attachment device
Definition: phymarxbot.h:109
MarXbotAttachmentDeviceMotorController(PhyMarXbot *robot)
Constructor.
Definition: motorcontrollers.cpp:482
void setDesiredPosition(double pos)
Sets the desired position of the attachment device.
Definition: motorcontrollers.cpp:603
void setDesiredVelocity(double vel)
Sets the desired velocity of the attachment device.
Definition: motorcontrollers.cpp:628
void setSpeeds(QVector< double > speeds)
sets the desired speed for the wheels
Definition: motorcontrollers.cpp:397
Status
The possible status of the attachment device. See class description for more information.
Definition: motorcontrollers.h:291
double pidloop(double currentvalue)
it compute a loop of PID algorithm
Definition: motorcontrollers.cpp:52
FARSA_UTIL_TEMPLATE const T max(const T &t1, const U &t2)
void setMaxTorque(double maxTorque)
sets the maximum allowed torque of wheels
Definition: motorcontrollers.cpp:472
double getDesiredVelocity() const
Returns the desired velocity of the attachment device.
Definition: motorcontrollers.cpp:635
void setSpeedLimits(QVector< double > minSpeeds, QVector< double > maxSpeeds)
sets the minimum and maximum velocities for each wheel
Definition: motorcontrollers.cpp:448
double getMaxTorque() const
gets the maximum allowed torque of wheels
Definition: motorcontrollers.cpp:478
bool attachmentDeviceEnabled() const
Returns true if the attachment device is enabled.
Definition: phymarxbot.h:178
void getSpeeds(QVector< double > &speeds) const
gets the current speed of the wheels
Definition: motorcontrollers.cpp:427
PhyObject * turret()
Returns the solid modelling the turret of the robot.
Definition: phymarxbot.h:209
void getSpeedLimits(QVector< double > &minSpeeds, QVector< double > &maxSpeeds) const
gets the minimum and maximum velocities for each wheel
Definition: motorcontrollers.cpp:460
double getDesiredPosition() const
Returns the desired position of the attachment device.
Definition: motorcontrollers.cpp:610
void getDesiredSpeeds(QVector< double > &speeds) const
gets the desired speed of the wheels
Definition: motorcontrollers.cpp:439
bool attachmentDeviceEnabled() const
Returns true if the attachment device is enabled.
Definition: motorcontrollers.cpp:582
double getPosition() const
Returns the current position of the attachment device.
Definition: motorcontrollers.cpp:619
wMatrix rotateAround(const wVector &axis, const wVector ¢re, real angle) const
Rotate this matrix around the axis, and position passed of radians specified.
Definition: wmatrix.h:301
wVectorT< false > scale(real s) const
return a new wVectorT with element scaled by s
Definition: wvector.h:305
void setDesiredStatus(Status status)
Changes the status of the attachment device.
Definition: motorcontrollers.cpp:653
float real
FARSA_UTIL_TEMPLATE const T min(const T &t1, const U &t2)
bool attachedToRobot() const
Returns true if we are attached to another robot.
Definition: motorcontrollers.h:434
PhyObject * attachmentDevice()
Returns the solid modelling the attachment device.
Definition: phymarxbot.h:221
wVector transformVector(const wVector &v) const
apply both rotation and translation to the vector v
Definition: wmatrix.h:364
virtual void update()
The method updating the attachment device at each timestep.
Definition: motorcontrollers.cpp:499
Dedicated controller for wheeled robots.
Definition: motorcontrollers.h:167
void setMaxVelocity(double speed)
Sets the maximum speed at which the attachment device can move.
Definition: motorcontrollers.cpp:587
friend class PhyMarXbot
The PhyMarXbot class is friend to call the attachmentDeviceAboutToBeDestroyed() function.
Definition: motorcontrollers.h:544
double getVelocity() const
Returns the current velocity of the attachment device.
Definition: motorcontrollers.cpp:644