summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordufourj2005-05-05 13:47:18 +0000
committerdufourj2005-05-05 13:47:18 +0000
commiteebc8595234bd4999b66fbd7b88e040ace900d6a (patch)
tree45f291b245174947347800999a72e0861be3786b
parentdc1defb9c6dbc965782f1da84979010f2520809c (diff)
Config :
* ralentissement de la vitesse et accélération Ai : * réinitialisation de la PWM à zéro * gestion de rotations inutiles Motor : * fonction pour reset de la PWM sur asserv
-rw-r--r--2005/i/robert/runtime/rc/config6
-rw-r--r--2005/i/robert/src/ai/ai.cc35
-rw-r--r--2005/i/robert/src/motor/motor.cc7
-rw-r--r--2005/i/robert/src/motor/motor.hh2
4 files changed, 39 insertions, 11 deletions
diff --git a/2005/i/robert/runtime/rc/config b/2005/i/robert/runtime/rc/config
index 11f6099..9c7f686 100644
--- a/2005/i/robert/runtime/rc/config
+++ b/2005/i/robert/runtime/rc/config
@@ -2,14 +2,16 @@
asserv.tty = "/dev/ttyS1"
asserv.footing = 0xE3F
asserv.epsilon = 200.00
-asserv.accel = 64 #faut que ca fasse 8 dans l'AVR
+# Aprs homolgation, passage de 64 96
+asserv.accel = 96 #faut que ca fasse 8 dans l'AVR
asserv.kp = 0x0FFF
asserv.ki = 0x0040
asserv.kd = 0x0FFF
asserv.eSat = 1023 # p E w
asserv.speedIntMax = 8191 #Isat
asserv.dSample = 1 # p s b
-asserv.maxSLin = 16
+# Aprs homolgation, passage de 16 8
+asserv.maxSLin = 8
asserv.maxSRot = 4
asserv.useTazFSM = false
asserv.pwmMax = 256
diff --git a/2005/i/robert/src/ai/ai.cc b/2005/i/robert/src/ai/ai.cc
index c184f95..34eb75d 100644
--- a/2005/i/robert/src/ai/ai.cc
+++ b/2005/i/robert/src/ai/ai.cc
@@ -43,14 +43,16 @@ Ai::Ai(const Config & config)
roundDuration_(config.get<int>("ai.roundDuration")),
vitesseAsc_(config.get<int>("ai.vitesseAsc"))
{
- //instance = this
scheduler_.insert (schedulableMotor_);
scheduler_.insert (schedulableEs_);
}
+/// Destructeur
Ai::~Ai (void)
{
+ // On rinitialise
init ();
+ // On sync
do {
update ();
}
@@ -75,6 +77,11 @@ void Ai::stop(void)
{
// Stop les moteurs
motor_.stop();
+ // On sync
+ do
+ {
+ update ();
+ } while (!motor_.idle ());
}
/// Lance le robot
@@ -86,7 +93,8 @@ void Ai::run(void)
// Attend l'entre du jack "pret initialiser"
std::cout << "On attend le jack" << std::endl;
waitJack(false);
- std::cout << "Le jack est mis" << std::endl;
+ std::cout << "Le jack est mis, on rinit la PWM" << std::endl;
+ motor_.setPwm (0, 0);
// Attend la premire sortie du jack(init)
waitJack(true);
std::cout << "Le jack est sorti" << std::endl;
@@ -193,7 +201,6 @@ void Ai::goTo (double x, double y ,double a)
}
/// Recale contre une bordure.
-// XXX Voir ca plus prcisemment
void Ai::recale (void)
{
motor_.recalage();
@@ -219,12 +226,22 @@ void Ai::basic (double d)
void Ai::rotation (double a)
{
// On vrifie que ca ne fasse pas moins de trois degr
- // XXX
- motor_.rotation(a);
- do
- {
- update();
- }while (!motor_.idle()); // XXX Grer le cas d'une rotation trop petite
+ // On rcupre l'angle
+ double destNorm;
+ // On normalise si besoin
+ if (a < 0)
+ destNorm += 2 * M_PI;
+ // On rcupre la diffrence d'angle
+ double diff = motor_.getA () - destNorm;
+ double limit = 3 / 360 * 2 * M_PI; // 3 degr en radian XXX
+ if (diff > limit || diff < - limit)
+ {
+ motor_.rotation(a);
+ do
+ {
+ update();
+ } while (!motor_.idle());
+ }
}
/// Monte(vrai) ou descend(faux) l'ascenceur
diff --git a/2005/i/robert/src/motor/motor.cc b/2005/i/robert/src/motor/motor.cc
index 9cf55f8..c292e9c 100644
--- a/2005/i/robert/src/motor/motor.cc
+++ b/2005/i/robert/src/motor/motor.cc
@@ -58,6 +58,7 @@ void Motor::init (void)
void Motor::stop(void)
{
asserv_.setSpeed();
+ idle_ = true;
}
double Motor::getX(void)
@@ -85,6 +86,12 @@ void Motor::setPosition(double x, double y, double a) //XXX Faire trois setteur
posA_ = a;
}
+void
+Motor::setPwm(int leftPwm, int rightPwm)
+{
+ asserv_.setPwm (leftPwm, rightPwm);
+}
+
void Motor::goTo(double x, double y, double a)
{
diff --git a/2005/i/robert/src/motor/motor.hh b/2005/i/robert/src/motor/motor.hh
index 062957c..b527525 100644
--- a/2005/i/robert/src/motor/motor.hh
+++ b/2005/i/robert/src/motor/motor.hh
@@ -115,6 +115,8 @@ class Motor : public Asserv::Receiver
void receiveSpeedStat (int leftError, int leftInt, int rightError,
int rightInt);
void receivePwm (double leftPwm, double rightPwm);
+ // Dfini les valeurs de la PWM
+ void setPwm(int leftPwm = 0, int rightPwm = 0);
void receiveTiming (int motorTimer4,
int motorTimer3, int motorTimer2,
int motorTimer1, int motorTimer0);