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: 2017NHKpin_config FEP ikarashiMDC
Fork of NHK2017_octopus2 by
Diff: bot/controller/controller.cpp
- Revision:
- 54:857390145ac4
- Parent:
- 52:320f910ca6ca
diff -r cdf67348b946 -r 857390145ac4 bot/controller/controller.cpp
--- a/bot/controller/controller.cpp Thu Nov 23 04:15:02 2017 +0000
+++ b/bot/controller/controller.cpp Thu Nov 23 14:59:59 2017 +0900
@@ -1,14 +1,14 @@
#include "controller.h"
Controller::Controller() :
- FEP(XBee2TX, XBee2RX, ADDR1),
+ FEP(FEPTX, FEPRX, ADDR1),
data(),
fepTemp(0),
button1(),
button2(),
- stick(),
- radian(),
- norm()
+ stick()
+ // radian(),
+ // norm()
{
}
@@ -18,13 +18,13 @@
fepTemp(0),
button1(),
button2(),
- stick(),
- radian(),
- norm()
+ stick()
+ // radian(),
+ // norm()
{
}
-int Controller::receiveState()
+bool Controller::receiveState()
{
fepTemp = FEP::read(data, DATA_SIZE);
if(fepTemp == FEP_SUCCESS) {
@@ -42,14 +42,8 @@
if(stick[i] < -1.0) stick[i] = -1.0;
}
setStick();
- } else if(fepTemp == FEP_DT_BIN) {
- return 2;
- } else if(fepTemp == FEP_DT_BIN) {
- return 3;
- } else if(fepTemp == FEP_NO_RESPONSE) {
+ } else {
return 0;
- } else {
- return 4;
}
return 1;
}
@@ -60,16 +54,16 @@
if(stick[i] < STICK_NEWTRAL && stick[i] > -STICK_NEWTRAL) stick[i] = 0;
}
- radian[0] = atan2(stick[1], stick[0]);
- radian[1] = atan2(stick[3], -stick[2]);
-
- norm[0] = hypot(stick[0], stick[1]);
- norm[1] = hypot(stick[2], stick[3]);
-
- if(norm[0] < STICK_NEWTRAL) norm[0] = 0;
- if(norm[1] < STICK_NEWTRAL) norm[1] = 0;
- if(norm[0] > STICK_NORM_MAX) norm[0] = STICK_NORM_MAX;
- if(norm[1] > STICK_NORM_MAX) norm[1] = STICK_NORM_MAX;
+ // radian[0] = atan2(stick[1], stick[0]);
+ // radian[1] = atan2(stick[3], -stick[2]);
+ //
+ // norm[0] = hypot(stick[0], stick[1]);
+ // norm[1] = hypot(stick[2], stick[3]);
+ //
+ // if(norm[0] < STICK_NEWTRAL) norm[0] = 0;
+ // if(norm[1] < STICK_NEWTRAL) norm[1] = 0;
+ // if(norm[0] > STICK_NORM_MAX) norm[0] = STICK_NORM_MAX;
+ // if(norm[1] > STICK_NORM_MAX) norm[1] = STICK_NORM_MAX;
}
bool Controller::getButton1(int number) const
@@ -87,12 +81,12 @@
return stick[number];
}
-float Controller::getRadian(int number) const
-{
- return radian[number];
-}
-
-float Controller::getNorm(int number) const
-{
- return norm[number];
-}
+// float Controller::getRadian(int number) const
+// {
+// return radian[number];
+// }
+//
+// float Controller::getNorm(int number) const
+// {
+// return norm[number];
+// }
