The Last Day ?
This commit is contained in:
parent
dc8b1cde31
commit
f544ab7822
14 changed files with 240 additions and 157 deletions
|
@ -21,6 +21,21 @@ void Ball_Tracker::Update()
|
|||
{
|
||||
greatestIntensity = i;
|
||||
}
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
if(intensity[i] > BALL_HELD_INTENSITY) // Ball derzeit sehr nah dran
|
||||
{
|
||||
ballHeld = true;
|
||||
ballHeldCounter = 100;
|
||||
}
|
||||
else if(ballHeldCounter > 0) // Oder vor kurzem erst sehr nah dran
|
||||
{
|
||||
ballHeld = true;
|
||||
ballHeldCounter--;
|
||||
}
|
||||
else ballHeld = false; // ansonsten hat er den Ball nicht
|
||||
}
|
||||
}
|
||||
|
||||
if(intensity[greatestIntensity])
|
||||
|
|
|
@ -11,6 +11,8 @@ public:
|
|||
this->parent = NULL;
|
||||
this->moduleId = 0;
|
||||
this->direction = EMPTY_FLOAT;
|
||||
this->ballHeldCounter = 0;
|
||||
this->ballHeld = false;
|
||||
}
|
||||
|
||||
Ball_Tracker(uint32 trackerId)
|
||||
|
@ -18,10 +20,14 @@ public:
|
|||
this->parent = NULL;
|
||||
this->moduleId = trackerId;
|
||||
this->direction = EMPTY_FLOAT;
|
||||
this->ballHeldCounter = 0;
|
||||
this->ballHeld = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
float direction;
|
||||
uint8 ballHeldCounter;
|
||||
bool ballHeld;
|
||||
|
||||
public:
|
||||
void Update();
|
||||
|
@ -33,12 +39,12 @@ public:
|
|||
|
||||
bool KnowsBallDirection()
|
||||
{
|
||||
return direction != EMPTY_FLOAT;
|
||||
return (direction != EMPTY_FLOAT);
|
||||
}
|
||||
|
||||
bool RobotHasBall()
|
||||
{
|
||||
//fill me!
|
||||
return ballHeld;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@ void Position_Tracker::Update()
|
|||
// Generate a vector for the left mouse
|
||||
int8 leftX = mouseLeft->GetXMovement();
|
||||
int8 leftY = mouseLeft->GetYMovement();
|
||||
// Generate a vector for the right mouse
|
||||
int8 rightX = mouseRight->GetXMovement();
|
||||
int8 rightY = mouseRight->GetYMovement();
|
||||
|
||||
float distanceLeft = sqrt(leftX * leftX + leftY * leftY);
|
||||
float angleLeft = easyAngle(atan2(leftY, leftX) + (225.0f * PI / 180.0f));
|
||||
|
||||
|
@ -23,9 +27,6 @@ void Position_Tracker::Update()
|
|||
movementLeftY = 0;
|
||||
}
|
||||
|
||||
// Generate a vector for the right mouse
|
||||
int8 rightX = mouseRight->GetXMovement();
|
||||
int8 rightY = mouseRight->GetYMovement();
|
||||
float distanceRight = sqrt(rightX * rightX + rightY * rightY);
|
||||
float angleRight = easyAngle(atan2(rightY, rightX) - (45.0f * PI / 180.0f));
|
||||
|
||||
|
@ -50,13 +51,9 @@ void Position_Tracker::Update()
|
|||
float robotMovementY = movementDifferenceY / 2.0f;
|
||||
robotMovementX += movementLeftX + mouseLeft->GetPositionX() + (-mouseLeft->GetPositionX() * cos(orientationDiff));
|
||||
robotMovementY += movementLeftY + mouseLeft->GetPositionY() + (mouseLeft->GetPositionX() * sin(orientationDiff));
|
||||
//float robotDistance = sqrt(robotMovementX * robotMovementX + robotMovementY * robotMovementY);
|
||||
|
||||
float absoluteDiffX = cos(this->orientation + (orientationDiff / 2.0f)) * robotMovementX - sin(this->orientation + (orientationDiff / 2.0f)) * robotMovementY;
|
||||
float absoluteDiffY = sin(this->orientation + (orientationDiff / 2.0f) + PI / 2.0f) * robotMovementY + cos(this->orientation + (orientationDiff / 2.0f) - PI / 2.0f) * robotMovementX;
|
||||
|
||||
//float absoluteDiffX = cos(this->orientation + (orientationDiff / 2.0f)) * robotDistance * sign(robotMovementX);
|
||||
//float absoluteDiffY = sin(this->orientation + (orientationDiff / 2.0f)) * robotDistance * sign(robotMovementY);
|
||||
float absoluteDiffX = cos(this->orientation + (orientationDiff / 2.0f)) * robotMovementX + sin(this->orientation + (orientationDiff / 2.0f)) * robotMovementY;
|
||||
float absoluteDiffY = sin(this->orientation + (orientationDiff / 2.0f) + PI / 2.0f) * robotMovementY - cos(this->orientation + (orientationDiff / 2.0f) - PI / 2.0f) * robotMovementX;
|
||||
|
||||
if(!robotMovementX && !robotMovementY)
|
||||
{
|
||||
|
@ -74,4 +71,10 @@ void Position_Tracker::Update()
|
|||
this->orientation += orientationDiff;
|
||||
|
||||
this->orientation = easyAngle(this->orientation);
|
||||
|
||||
//(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print(" ", 5, 1);
|
||||
/*(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Clear();
|
||||
(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print(this->orientation * 180.0f / PI, 5, 1);
|
||||
(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print(this->positionX, 1, 2);
|
||||
(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print(this->positionY, 1, 3);*/
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public:
|
|||
|
||||
// returns orientation
|
||||
float GetOrientation() {
|
||||
return 0.0f; //tmp!!!!!!!!!!
|
||||
//return orientation;
|
||||
//return 0.0f; //tmp!!!!!!!!!!
|
||||
return orientation;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue