2007-02-18 00:14:00 +00:00
|
|
|
#ifndef _NAVIGATOR_H
|
|
|
|
#define _NAVIGATOR_H
|
|
|
|
|
2007-02-18 17:57:03 +00:00
|
|
|
//#include <math.h>
|
2007-02-18 00:14:00 +00:00
|
|
|
#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-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-18 00:14:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|