Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI biquadFilter
Diff: robot.cpp
- Revision:
- 12:8295c02d740f
- Parent:
- 7:a80cb6b06320
- Child:
- 18:1c9dc6caab9d
--- a/robot.cpp Wed Nov 02 16:29:13 2016 +0000 +++ b/robot.cpp Thu Nov 03 13:08:44 2016 +0000 @@ -18,13 +18,16 @@ const float initialArmLength = L_min; +const float maxUpperArmVelocity = 1; // Rad/s +const float maxLowerArmVelocity = 3; // Rad/s + /* Constructor */ Robot::Robot(): - upperArm(initialArmLength, upperMotorPWM, upperMotorDir, upperEncoderPin1, upperEncoderPin2), - lowerArm(initialArmLength, lowerMotorPWM, lowerMotorDir, lowerEncoderPin1, lowerEncoderPin2) { + upperArm(initialArmLength, maxUpperArmVelocity, upperMotorPWM, upperMotorDir, upperEncoderPin1, upperEncoderPin2), + lowerArm(initialArmLength, maxLowerArmVelocity, lowerMotorPWM, lowerMotorDir, lowerEncoderPin1, lowerEncoderPin2) { killed = false; } @@ -38,6 +41,16 @@ lowerArm.update(); } +// Get upper arm encoder velocity +float Robot::getUpperArmEncoderVelocity() { + return upperArm.getEncoderVelocity(); +} + +// Get lower arm encoder velocity +float Robot::getLowerArmEncoderVelocity() { + return lowerArm.getEncoderVelocity(); +} + // Set upper arm velocity (rad/s) void Robot::setUpperArmVelocity(float referenceVelocity) { if (!killed) {