12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
-
-
- #include <unistd.h>
- #include <iostream>
- #include <signal.h>
- #include "enc03r.h"
-
- using namespace std;
-
- bool shouldRun = true;
-
-
- #define CALIBRATION_SAMPLES 1000
-
- void sig_handler(int signo)
- {
- if (signo == SIGINT)
- shouldRun = false;
- }
-
- int main()
- {
- signal(SIGINT, sig_handler);
-
-
-
-
- upm::ENC03R *gyro = new upm::ENC03R(0);
-
-
- cout << "Please place the sensor in a stable location, and do not" << endl;
- cout << "move it while calibration takes place." << endl;
- cout << "This may take a couple of minutes." << endl;
-
- gyro->calibrate(CALIBRATION_SAMPLES);
- cout << "Calibration complete. Reference value: "
- << gyro->calibrationValue() << endl;
-
-
-
- while (shouldRun)
- {
- unsigned int val = gyro->value();
- double av = gyro->angularVelocity(val);
-
- cout << "Raw value: " << val << ", "
- << "angular velocity: " << av << " deg/s" << endl;
-
- usleep(100000);
- }
-
-
- cout << "Exiting" << endl;
-
- delete gyro;
- return 0;
- }
|