From f544ab78229d3a4d54b910135ba61bb816009589 Mon Sep 17 00:00:00 2001 From: sicarius Date: Thu, 22 Feb 2007 20:59:02 +0000 Subject: The Last Day ? --- .../Framework/modules/interpreter/ball_tracker.c | 15 +++++++++++++++ .../Framework/modules/interpreter/ball_tracker.h | 10 ++++++++-- .../modules/interpreter/position_tracker.c | 21 ++++++++++++--------- .../modules/interpreter/position_tracker.h | 4 ++-- 4 files changed, 37 insertions(+), 13 deletions(-) (limited to 'source/Concept/Framework/modules/interpreter') diff --git a/source/Concept/Framework/modules/interpreter/ball_tracker.c b/source/Concept/Framework/modules/interpreter/ball_tracker.c index 2d85b96..16fdfb4 100755 --- a/source/Concept/Framework/modules/interpreter/ball_tracker.c +++ b/source/Concept/Framework/modules/interpreter/ball_tracker.c @@ -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]) diff --git a/source/Concept/Framework/modules/interpreter/ball_tracker.h b/source/Concept/Framework/modules/interpreter/ball_tracker.h index c62f05e..cb90ff2 100755 --- a/source/Concept/Framework/modules/interpreter/ball_tracker.h +++ b/source/Concept/Framework/modules/interpreter/ball_tracker.h @@ -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; } }; diff --git a/source/Concept/Framework/modules/interpreter/position_tracker.c b/source/Concept/Framework/modules/interpreter/position_tracker.c index a64ab60..f6d67ac 100755 --- a/source/Concept/Framework/modules/interpreter/position_tracker.c +++ b/source/Concept/Framework/modules/interpreter/position_tracker.c @@ -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(IO_DISPLAY_MAIN))->Print(" ", 5, 1); + /*(parent->GetModule(IO_DISPLAY_MAIN))->Clear(); + (parent->GetModule(IO_DISPLAY_MAIN))->Print(this->orientation * 180.0f / PI, 5, 1); + (parent->GetModule(IO_DISPLAY_MAIN))->Print(this->positionX, 1, 2); + (parent->GetModule(IO_DISPLAY_MAIN))->Print(this->positionY, 1, 3);*/ } diff --git a/source/Concept/Framework/modules/interpreter/position_tracker.h b/source/Concept/Framework/modules/interpreter/position_tracker.h index 47d0740..56b16c4 100755 --- a/source/Concept/Framework/modules/interpreter/position_tracker.h +++ b/source/Concept/Framework/modules/interpreter/position_tracker.h @@ -51,8 +51,8 @@ public: // returns orientation float GetOrientation() { - return 0.0f; //tmp!!!!!!!!!! - //return orientation; + //return 0.0f; //tmp!!!!!!!!!! + return orientation; } }; -- cgit v1.2.3