ball sensor: ball angle in absolute space
parent
f26cbf4984
commit
325656d810
|
@ -35,7 +35,7 @@ typedef struct input{
|
||||||
}input;
|
}input;
|
||||||
|
|
||||||
typedef struct data{
|
typedef struct data{
|
||||||
int IMUAngle, ballAngle, ballDistance,
|
int IMUAngle, ballAngle, ballAngleFix, ballDistance,
|
||||||
yAngle, bAngle, yAngleFix, bAngleFix,
|
yAngle, bAngle, yAngleFix, bAngleFix,
|
||||||
yDist, bDist,
|
yDist, bDist,
|
||||||
angleAtk, angleAtkFix, angleDef, angleDefFix,
|
angleAtk, angleAtkFix, angleDef, angleDefFix,
|
||||||
|
|
|
@ -8,6 +8,6 @@ class DataSourceBall : public DataSource{
|
||||||
void postProcess() override;
|
void postProcess() override;
|
||||||
void test() override;
|
void test() override;
|
||||||
|
|
||||||
int angle, distance;
|
int angle, distance, angleFix;
|
||||||
bool ballSeen;
|
bool ballSeen;
|
||||||
};
|
};
|
|
@ -14,9 +14,13 @@ void DataSourceBall :: postProcess(){
|
||||||
ballSeen = distance == 255 ? 0 : 1;
|
ballSeen = distance == 255 ? 0 : 1;
|
||||||
}else{
|
}else{
|
||||||
angle = value * 2;
|
angle = value * 2;
|
||||||
|
int imuAngle = CURRENT_DATA_READ.IMUAngle > 180 ? 360 -CURRENT_DATA_READ.IMUAngle : CURRENT_DATA_READ.IMUAngle;
|
||||||
|
int ballAngle = angle > 180 ? 360 -angle : angle;
|
||||||
|
angleFix = (ballAngle-imuAngle+360)%360;
|
||||||
}
|
}
|
||||||
CURRENT_INPUT_WRITE.ballByte = value;
|
CURRENT_INPUT_WRITE.ballByte = value;
|
||||||
CURRENT_DATA_WRITE.ballAngle = angle;
|
CURRENT_DATA_WRITE.ballAngle = angle;
|
||||||
|
CURRENT_DATA_WRITE.ballAngleFix = angleFix;
|
||||||
CURRENT_DATA_WRITE.ballDistance = distance;
|
CURRENT_DATA_WRITE.ballDistance = distance;
|
||||||
CURRENT_DATA_WRITE.ballSeen = ballSeen;
|
CURRENT_DATA_WRITE.ballSeen = ballSeen;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +30,8 @@ void DataSourceBall :: test(){
|
||||||
// if(ballSeen){
|
// if(ballSeen){
|
||||||
DEBUG.print(angle);
|
DEBUG.print(angle);
|
||||||
DEBUG.print(" | ");
|
DEBUG.print(" | ");
|
||||||
|
DEBUG.print(angleFix);
|
||||||
|
DEBUG.print(" | ");
|
||||||
DEBUG.print(distance);
|
DEBUG.print(distance);
|
||||||
DEBUG.print(" | ");
|
DEBUG.print(" | ");
|
||||||
DEBUG.println(ballSeen);
|
DEBUG.println(ballSeen);
|
||||||
|
|
Loading…
Reference in New Issue