This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
rc2007-soccer/source/Concept/Framework/modules/executor/navigator.h

75 lines
1.5 KiB
C
Raw Normal View History

2007-02-18 00:14:00 +00:00
#ifndef _NAVIGATOR_H
#define _NAVIGATOR_H
#include "../../stdafx.h"
class Navigator : public IO_Module
{
public:
Navigator()
{
this->parent = NULL;
this->moduleId = 0;
2007-02-19 17:15:02 +00:00
this->correctionCountdown = CYCLES_PER_CORRECTION;
this->direction = EMPTY_FLOAT;
this->targetAngle = EMPTY_FLOAT;
this->targetX = EMPTY_FLOAT;
this->targetY = EMPTY_FLOAT;
2007-02-18 17:57:03 +00:00
this->robotSpeed = 0;
2007-02-18 00:14:00 +00:00
this->rotationSpeed = 0;
}
Navigator(uint32 navigatorId)
{
this->parent = NULL;
this->moduleId = navigatorId;
2007-02-19 17:15:02 +00:00
this->correctionCountdown = CYCLES_PER_CORRECTION;
this->direction = EMPTY_FLOAT;
this->targetAngle = EMPTY_FLOAT;
this->targetX = EMPTY_FLOAT;
this->targetY = EMPTY_FLOAT;
2007-02-18 17:57:03 +00:00
this->robotSpeed = 0;
2007-02-18 00:14:00 +00:00
this->rotationSpeed = 0;
}
protected:
2007-02-19 17:15:02 +00:00
uint16 correctionCountdown;
2007-02-18 00:14:00 +00:00
float direction;
float targetAngle;
float targetX;
float targetY;
2007-02-18 17:57:03 +00:00
float robotSpeed;
2007-02-18 00:14:00 +00:00
float rotationSpeed;
public:
void Update();
void Stop();
void Drive(float newDirection, float newAngle, float newSpeed, float rotationSpeed);
2007-02-18 17:57:03 +00:00
void DriveTo(float newX, float newY, float newAngle, float newSpeed, float rotationSpeed);
2007-02-22 20:59:02 +00:00
void RotateTo(float newAngle,float roationSpeed);
2007-02-18 00:14:00 +00:00
void Rotate(float rotationSpeed);
2007-02-18 17:57:03 +00:00
void SetSpeed(float newSpeed)
{
this->robotSpeed = newSpeed;
}
2007-02-19 17:15:02 +00:00
void CalculateDirection();
void CalculateEngines();
bool HasTarget()
{
return (targetX != EMPTY_FLOAT && targetY != EMPTY_FLOAT);
}
2007-02-22 20:59:02 +00:00
bool TargetReached();
bool AngleReached();
2007-02-18 00:14:00 +00:00
};
2007-02-19 22:02:01 +00:00
2007-02-18 00:14:00 +00:00
#endif