position
parent
f200685ffb
commit
c0495a64af
|
@ -16,11 +16,11 @@
|
||||||
#define LINE_THRESH 90
|
#define LINE_THRESH 90
|
||||||
#define EXTIME 100
|
#define EXTIME 100
|
||||||
|
|
||||||
class DataSourceCtrlLines : public DataSourceCtrl {
|
class DSCtrlLines : public DataSourceCtrl {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataSourceCtrlLines();
|
DSCtrlLines();
|
||||||
DataSourceCtrlLines(vector<DataSource*> in_, vector<DataSource*> out);
|
DSCtrlLines(vector<DataSource*> in_, vector<DataSource*> out);
|
||||||
|
|
||||||
void read() override;
|
void read() override;
|
||||||
void postProcess() override;
|
void postProcess() override;
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "vars.h"
|
||||||
|
#include "ds_ctrl.h"
|
||||||
|
#include "ds_ctrl_lines.h"
|
||||||
|
|
||||||
|
class DSCtrlPosition : public DataSourceController {
|
||||||
|
|
||||||
|
public:
|
||||||
|
DSCtrlPosition();
|
||||||
|
|
||||||
|
};
|
|
@ -25,8 +25,8 @@ s_extr vector<DataSource*> lIn;
|
||||||
s_extr vector<DataSource*> lOut;
|
s_extr vector<DataSource*> lOut;
|
||||||
s_extr vector<DataSource*> dUs;
|
s_extr vector<DataSource*> dUs;
|
||||||
|
|
||||||
s_extr DataSourceCtrl* usCtrl;
|
s_extr DSCtrlLines* usCtrl;
|
||||||
s_extr DataSourceCtrlLines* linesCtrl;
|
s_extr DSCtrlLines* linesCtrl;
|
||||||
|
|
||||||
s_extr DataSourceBNO055* compass;
|
s_extr DataSourceBNO055* compass;
|
||||||
s_extr DataSourceBall* ball;
|
s_extr DataSourceBall* ball;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "sensors.h"
|
#include "sensors.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
DataSourceCtrlLines::DataSourceCtrlLines() {}
|
DSCtrlLines::DSCtrlLines() {}
|
||||||
DataSourceCtrlLines::DataSourceCtrlLines(vector<DataSource*> in_, vector<DataSource*> out_){
|
DSCtrlLines::DSCtrlLines(vector<DataSource*> in_, vector<DataSource*> out_){
|
||||||
this->in = in_;
|
this->in = in_;
|
||||||
this->out = out_;
|
this->out = out_;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ DataSourceCtrlLines::DataSourceCtrlLines(vector<DataSource*> in_, vector<DataSou
|
||||||
exitTimer = 0;
|
exitTimer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceCtrlLines::read(){
|
void DSCtrlLines::read(){
|
||||||
inV = 0;
|
inV = 0;
|
||||||
outV = 0;
|
outV = 0;
|
||||||
for(DataSource* d : in) d->readSensor();
|
for(DataSource* d : in) d->readSensor();
|
||||||
|
@ -49,7 +49,7 @@ void DataSourceCtrlLines::read(){
|
||||||
inV = inV | outV;
|
inV = inV | outV;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceCtrlLines::postProcess(){
|
void DSCtrlLines::postProcess(){
|
||||||
if ((inV > 0) || (outV > 0)) {
|
if ((inV > 0) || (outV > 0)) {
|
||||||
fboundsOX = true;
|
fboundsOX = true;
|
||||||
fboundsOY = true;
|
fboundsOY = true;
|
||||||
|
@ -63,12 +63,12 @@ void DataSourceCtrlLines::postProcess(){
|
||||||
outOfBounds();
|
outOfBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceCtrlLines::outOfBounds(){
|
void DSCtrlLines::outOfBounds(){
|
||||||
handleExtern();
|
handleExtern();
|
||||||
handleIntern();
|
handleIntern();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceCtrlLines::handleIntern(){
|
void DSCtrlLines::handleIntern(){
|
||||||
|
|
||||||
if(fboundsX == true) {
|
if(fboundsX == true) {
|
||||||
if(inV & 0x02) inVOldX = 2;
|
if(inV & 0x02) inVOldX = 2;
|
||||||
|
@ -162,14 +162,14 @@ void DataSourceCtrlLines::handleIntern(){
|
||||||
else slow = false;
|
else slow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceCtrlLines::handleExtern(){
|
void DSCtrlLines::handleExtern(){
|
||||||
if((outV & 0b00000001) == 1) drive->vyp = 1; // esclusione
|
if((outV & 0b00000001) == 1) drive->vyp = 1; // esclusione
|
||||||
if((outV & 0b00000100) == 4) drive->vyn = 1;
|
if((outV & 0b00000100) == 4) drive->vyn = 1;
|
||||||
if((outV & 0b00000010) == 2) drive->vxp = 1;
|
if((outV & 0b00000010) == 2) drive->vxp = 1;
|
||||||
if((outV & 0b00001000) == 8) drive->vxn = 1;
|
if((outV & 0b00001000) == 8) drive->vxn = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceCtrlLines::test(){
|
void DSCtrlLines::test(){
|
||||||
update();
|
update();
|
||||||
DEBUG.print("In: ");
|
DEBUG.print("In: ");
|
||||||
for(DataSource* d : in){
|
for(DataSource* d : in){
|
||||||
|
|
|
@ -16,7 +16,7 @@ void initSensors(){
|
||||||
ball = new DataSourceBall(&Serial4, 57600);
|
ball = new DataSourceBall(&Serial4, 57600);
|
||||||
camera = new DataSourceCamera(&Serial2, 19200);
|
camera = new DataSourceCamera(&Serial2, 19200);
|
||||||
usCtrl = new DataSourceCtrl(dUs);
|
usCtrl = new DataSourceCtrl(dUs);
|
||||||
linesCtrl = new DataSourceCtrlLines(lIn, lOut);
|
linesCtrl = new DSCtrlLines(lIn, lOut);
|
||||||
bt = new DataSourceBT(&Serial3, 115200);
|
bt = new DataSourceBT(&Serial3, 115200);
|
||||||
|
|
||||||
/*game = new Game();
|
/*game = new Game();
|
||||||
|
|
Loading…
Reference in New Issue