Angular velocity support
This commit is contained in:
parent
e0230a7684
commit
a6d1b0c945
@ -17,7 +17,6 @@ DifferentialDrive::DifferentialDrive(Placement leftMotorPlacement,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DifferentialDrive::SetTargetSpeeds(float leftSpeed, float rightSpeed) {
|
void DifferentialDrive::SetTargetSpeeds(float leftSpeed, float rightSpeed) {
|
||||||
Serial.printf("motor count %d\n", this->motorCount);
|
|
||||||
for (unsigned int motorIx = 0; motorIx < this->motorCount; motorIx++) {
|
for (unsigned int motorIx = 0; motorIx < this->motorCount; motorIx++) {
|
||||||
Thing *thing = placement[motorIx].thing;
|
Thing *thing = placement[motorIx].thing;
|
||||||
if (thing->type == Thing::UncontrolledMotorType) {
|
if (thing->type == Thing::UncontrolledMotorType) {
|
||||||
@ -60,3 +59,12 @@ Polar DifferentialDrive::GetVelocity() {
|
|||||||
Polar velocity = Polar(direction, distance);
|
Polar velocity = Polar(direction, distance);
|
||||||
return velocity;
|
return velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float DifferentialDrive::GetAngularVelocity() {
|
||||||
|
Motor *leftMotor = (Motor *)placement[0].thing;
|
||||||
|
Motor *rightMotor = (Motor *)placement[1].thing;
|
||||||
|
float leftSpeed = leftMotor->GetSpeed();
|
||||||
|
float rightSpeed = rightMotor->GetSpeed();
|
||||||
|
float angularVelocity = leftSpeed - rightSpeed;
|
||||||
|
return angularVelocity;
|
||||||
|
}
|
@ -52,11 +52,10 @@ class DifferentialDrive : public Propulsion {
|
|||||||
/// @note As a DifferentialDrive cannot move sideward or vertical, this
|
/// @note As a DifferentialDrive cannot move sideward or vertical, this
|
||||||
/// function has the same effect as using the void SetTwistSpeed(float
|
/// function has the same effect as using the void SetTwistSpeed(float
|
||||||
/// forward, float yaw) function.
|
/// forward, float yaw) function.
|
||||||
virtual void SetTwistSpeed(Vector3 linear,
|
virtual void SetTwistSpeed(Vector3 linear, float yaw = 0.0F,
|
||||||
float yaw = 0.0F,
|
float pitch = 0.0F, float roll = 0.0F);
|
||||||
float pitch = 0.0F,
|
|
||||||
float roll = 0.0F);
|
|
||||||
virtual Polar GetVelocity() override;
|
virtual Polar GetVelocity() override;
|
||||||
|
virtual float GetAngularVelocity() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user