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
controller_test.cpp
- Committer:
- ronvbree
- Date:
- 2016-11-02
- Revision:
- 7:a80cb6b06320
- Child:
- 12:8295c02d740f
File content as of revision 7:a80cb6b06320:
#include "controller.h"
Serial pc(USBTX, USBRX);
RobotController controller;
AnalogIn upperPotMeter(A0);
AnalogIn lowerPotMeter(A1);
InterruptIn button(D2);
InterruptIn killButton(D3);
void readArmLengths(float &upper, float &lower) {
upper = L_min + (L_max - L_min) * upperPotMeter;
lower = L_min + (L_max - L_min) * lowerPotMeter;
}
void onButtonPress() {
float upper;
float lower;
readArmLengths(upper, lower);
pc.printf("Reference: Lower: %f, Upper: %f\n\r", lower, upper);
pc.printf("Encoder: Lower: %f, Upper: %f\n\r", controller.getLowerArmLength(), controller.getUpperArmLength());
pc.printf("Robot killed: %s\n\r", controller.isKilled()? "Yes":"No");
controller.setArmLengths(upper, lower);
}
int main() {
pc.baud(115200);
button.fall(&onButtonPress);
killButton.fall(controller.getRobot(), &Robot::kill);
pc.printf("Initialized\n\r");
while (true);
}