summaryrefslogtreecommitdiff
path: root/i
diff options
context:
space:
mode:
Diffstat (limited to 'i')
-rw-r--r--i/chuck/runtime/rc/config12
-rw-r--r--i/chuck/src/ai/ai.cc283
-rw-r--r--i/chuck/src/ai/ai.hh14
-rw-r--r--i/chuck/src/ai/test_ai.cc24
-rw-r--r--i/chuck/src/asserv/asserv.cc6
-rw-r--r--i/chuck/src/asserv/asserv.hh1
-rw-r--r--i/chuck/src/es/es.cc44
-rw-r--r--i/chuck/src/es/es.hh10
-rw-r--r--i/chuck/src/es/test_es.cc2
-rw-r--r--i/chuck/src/motor/motor.cc9
-rw-r--r--i/chuck/src/motor/motor.hh1
-rw-r--r--i/chuck/src/motor/test_motor.cc2
12 files changed, 303 insertions, 105 deletions
diff --git a/i/chuck/runtime/rc/config b/i/chuck/runtime/rc/config
index e0ec1b6..9219d0b 100644
--- a/i/chuck/runtime/rc/config
+++ b/i/chuck/runtime/rc/config
@@ -5,8 +5,8 @@ asserv.t_accel = 512
asserv.a_accel = 1024
asserv.t_max_speed = 64
asserv.a_max_speed = 64
-asserv.t_max_speed_slow = 8
-asserv.a_max_speed_slow = 8
+asserv.t_max_speed_slow = 48
+asserv.a_max_speed_slow = 48
asserv.tkp = 100
asserv.tki = 3
asserv.tkd = 0
@@ -16,7 +16,7 @@ asserv.akd = 0
asserv.esat = 1023
asserv.isat = 3072
asserv.l_invert_pwm = true
-asserv.r_invert_pwm = false
+asserv.r_invert_pwm = true
asserv.step_per_mm = 75.78789091394133410940
# Stats.
asserv.pos_report = 10
@@ -92,8 +92,10 @@ ai.ref_sensor_mask = 127
# log.logger.default = "ram"
# log.logger.asserv = "null"
log.logger.default = "stdout"
-log.level.default = "debug"
-log.logger.proto = "null"
+log.level.Es = "debug"
+log.level.Motor = "null"
+#log.level.proto = "debug"
+log.level.Ai = "debug"
### Exemples
foo = "toto"
diff --git a/i/chuck/src/ai/ai.cc b/i/chuck/src/ai/ai.cc
index da62abd..c84dcd5 100644
--- a/i/chuck/src/ai/ai.cc
+++ b/i/chuck/src/ai/ai.cc
@@ -1,4 +1,4 @@
-// ai.cc
+//ai.cc
// chuck - programme du robot 2007 {{{
//
// Copyright (C) 2007 Romain Becquet
@@ -48,7 +48,7 @@ Ai::Ai (const Config & config)
Ai::~Ai(void)
{
- // On réinitialise
+ // On réinitialise
// Initialise les moteurs
// XXX
motor_.reset();
@@ -81,6 +81,7 @@ Ai::stop (void)
motor_.stop ();
// XXX In fact, we should wait a little here...
while (!update ());
+ temporisation (500);
}
/// Synchronize data of under class
@@ -99,7 +100,7 @@ Ai::update (void)
/// Wait schedule_time
scheduler_.schedule (schedule_time_, true);
bool retour = sync ();
- // On vérifie que le match n'est pas fini
+ // On vérifie que le match n'est pas fini
if (Timer::getRoundTime () > round_duration_)
throw std::runtime_error ("End of match ! You win !");
return retour;
@@ -137,6 +138,7 @@ Ai::prepare (void)
{
es_.lcdPrint("");
es_.lcdPrint("Prepa match...");
+ es_.initservo();
es_.lcdPrint("G ma couleur");
es_.lcdPrint("Inserer Jack");
std::cout<<"insere jak"<<std::endl;
@@ -155,23 +157,21 @@ Ai::prepare (void)
motor_.getAsserv().setPos(0,0,0);
// Ok the match begin ! Go go go !
Timer::startRound ();
- //on fait tomber le roulo apré le top départ
- es_.roulo_tombe();
- temporisation(1500);
- es_.roulo_roule(0xDD);
- es_.setOthersStat (0);
- std::cout<<"le roulo auré du tombé"<<std::endl;
+ //on fait tomber le roulo apré le top départ
+ rouloAction();
+ std::cout<<"le roulo auré du tombé"<<std::endl;
// Shut up fucking beach !
es_.setOthersStat (0);
es_.setOthersStat (0);
while (!update ());
+ es_.launchSharpDetection();
}
/// Some after after a match
void
Ai::afterMatch(void)
{
- // On attend de mettre le jack après le match
+ // On attend de mettre le jack après le match
es_.lcdPrint("FIN DU MATCH");
// es_.lcdPrint("Inserer jack...");
while (!update());
@@ -186,96 +186,172 @@ Ai::afterMatch(void)
while (!update());
}
+void Ai::progH2(void)
+{
+ init();
+ prepare();
+ es_.roulo_roule(0x00);
+ motorMove(2660.,0.);
+ es_.roulo_roule(0x50);
+ motorMove(1000.,0.);
+
+}
/// programme d'homologation du robal
void Ai::progHomoloRobal(void)
{
- /// On init le robal
- prepare();
+// double dummy, aStart, aEnd;
+
+ // Init of cards
+ init ();
+ /// On prépare le robot
+
+ prepare();
+ log_("match") << "fin prepare";
+/// Faire des crêpes...
while (!update ());
- temporisation (1000);
+ /// En avant guingamp
+ log_ ("match") << "Eloignement du bord";
+ motorMove(1500,0.);//On fonce tout droit
while (!update ());
- /// on avance un poil parce que le mur c'est mal
- std::cout << "Move !" << std::endl;
- motorMove(500, 0);
- std::cout << "Rotate !" << std::endl;
- motorRotate(-0.54);
- std::cout << "Move !" << std::endl;
- motorMove(1200, 0);
- std::cout << "Rotate !" << std::endl;
- motorRotate(1.40);
- motorMove(500, 0);
-// temporisation (100);
- std::cout << "Find hole !" << std::endl;
-
- /// On tourne XXX
-/// motorRotate(-M_PI/4);
- /// On cherche au moins une balle (sinon c'est con)
-/// motorMove(1000, 0); /// XXX Voir la distance
- /// XXX Avancer d'une certaine facon pour choper des balles
- /// XXX Ouais ba y'a encore ddes truc à faire là
- /// On cherche un tru (repositionnement??)
-/// motor_.lockGoodHole();
-/// while (!update ());
-/// motor_.findHole();
-/// while (!update ());
- /// On trouve un trou, chouette
- /// Aspirer le trou
- //es_.extraitBalle();
- /// mettre une baballe
+ /// On tourner de 45°
+ log_ ("match") << "Petite rotation de 35°";
+ motorRotate((0.8)*(coefcolor));
+ while(!update());
+ std::cout<<"première rot"<<std::endl;
+ ///On avance a travers les ordures euh on est sensé en ramacer
+ std::cout<<"je traverse en diag"<<std::endl;
+ motorMove(1420.,0.);
+
+
+ log_("match") << "Start rotation";
+ ///On se positionne pour la marche arrière
+ motorRotate(R45*(5)*(coefcolor));
+
+ ///tuuutuuuutuuuuu je fait mon crénau
+ log_ ("match") << "Creneau";
+ //bool ok = motor_.docreno();
+ std::cout<<"je recule"<<std::endl;
+ temporisation (1000);
+// motorMove(-500.,0.);
+ fuckTheWall ();
+
+ log_ ("match") << "fin fuck";
+motorMove(200.0,0.);
+ motorRotate(R90*coefcolor*(-2));
+
+do
+{
+fuckTheWall();
+
+// Move asc up;
+ moveAsc (true);
+temporisation(500);
+
+ es_.roulo_roule (0);
+bougeAsc(0xff,0x05,false);
+ temporisation(200);
+ bougeAsc(0xff,0x05,true);
+ temporisation(200);
+bougeAsc(0xff,0x05,false);
+ temporisation(200);
+ bougeAsc(0xff,0x05,true);
+ temporisation(200);
+
+ /*es_.roulo_roule (0);*/
+ while(!update());
+ temporisation(2000);
+
+
+ // Move asc down
+ moveAsc (false /* down */);
+
+ temporisation(2000);
+ motorMove(100.,0.);
+}while(1);
+ es_.roulo_roule (0);
+
+
+// // Move asc up
+// moveAsc (true /* up */);
+// temporisation(2000);
+//
+// // Move asc down
+// moveAsc (false /* down */);
+// temporisation(2000);
+
+while(!update());
+ temporisation(2000);
+ /*rouloAction();*/
+
+ /*
while (!update ());
- temporisation (3000);
+ //on avance un peu
+ motorMove(400.,0.);
+ //direction le tas d'ordure
while (!update ());
- temporisation (3000);
- motorMove(300, 0);
+ motorRotate(R45*(-1)*coefcolor);
+ motorMove(450.,0.);
+
while (!update ());
- temporisation (3000);
+ //demitour
+ motorRotate(R90);
while (!update ());
- temporisation (3000);
- motorMove(300, 0);
- /// Tourner 3 fois en chantant du Mickael Jackson
- /// Again....
- /// Fin du match
- afterMatch();
+
+ motorMove(450.,0.);
+*/
+
+ /* Save angle */
+ /*motor_.getPosition (dummy, dummy, aStart);*/
+ /* afterMatch();*/
+}
+
+void
+Ai::fuckTheWall (void)
+{
+ motor_.fuckTheWall ();
+ do
+ {
+ update ();
+ } while (!motor_.finish ());
}
void
Ai::progMatch(void)
{
- double dummy, aStart, aEnd;
+ double dummy, aStart; // aEnd;
// Init of cards
init ();
- /// On prépare le robot
+ /// On prépare le robot
prepare();
- /// Faire des crêpes...
+ log_("match") << "fin prepare";
+ /// Faire des crêpes...
while (!update ());
/// En avant guingamp
log_ ("match") << "Eloignement du bord";
- motorMove(1300,0);//On fonce tout droit
+ motorMove(1700.,0.);//On fonce tout droit
while (!update ());
- /// On tourner de 45°
- log_ ("match") << "Petite rotation de 45°";
- motorRotate(R45*(coefcolor));
+ /// On tourner de 45°
+ log_ ("match") << "Petite rotation de 45°";
+ motorRotate(R35*(coefcolor));
- std::cout<<"première rot"<<std::endl;
- ///On avance a travers les ordures euh on est sensé en ramacer
- motorMove(1900.,0.);
+ std::cout<<"première rot"<<std::endl;
+ ///On avance a travers les ordures euh on est sensé en ramacer
+ std::cout<<"je traverse en diag"<<std::endl;
+ motorMove(1000.,0.);
-
-
-
- while(!update())
- {
-
- ///On se positionne pour la marche arrière
+ log_("match") << "fin prepare";
+ ///On se positionne pour la marche arrière
motorRotate(R45*(5)*(coefcolor));
- ///tuuutuuuutuuuuu je fait mon crénau
+ ///tuuutuuuutuuuuu je fait mon crénau
log_ ("match") << "Creneau";
//bool ok = motor_.docreno();
- motorMove(-500.,0.);
- es_.bouge_ascenceur(0x50,0xFF,0x00);
-
+
+ motorMove(-10.,0.);
+ std::cout<<"je recule"<<std::endl;
+ es_.bouge_ascenceur();
+ temporisation(2000);
while (!update ());
//on avance un peu
motorMove(400.,0.);
@@ -291,26 +367,23 @@ Ai::progMatch(void)
motorMove(450.,0.);
- }
/* Save angle */
motor_.getPosition (dummy, dummy, aStart);
afterMatch();
}
-/// Avance le robal et dit si il a finit (true) ou si il a bloqué
+/// Avance le robal et dit si il a finit (true) ou si il a bloqué
bool
Ai::motorMove (double d, double a)
{
double xStart, yStart, xCur, yCur, dummy;
motor_.getPosition (xStart, yStart, dummy);
-
motor_.move(d, a); /// XXX Voir la distance
do
{
update ();
if(es_.getSharpAck())
{
- // Stop !
stop ();
// Go back a little bit
motor_.move (-100, 0);
@@ -318,6 +391,7 @@ Ai::motorMove (double d, double a)
{
update ();
} while (!motor_.finish ());
+ temporisation (1000);
// Get current position
motor_.getPosition (xCur, yCur, dummy);
// Re eanble sharps
@@ -325,7 +399,7 @@ Ai::motorMove (double d, double a)
// Go to the position we want first
double xDiff = xStart - xCur;
double yDiff = yStart - yCur;
- motor_.move (sqrt (xDiff * xDiff + yDiff * yDiff), 0);
+ motor_.move (d - sqrt (xDiff * xDiff + yDiff * yDiff), 0);
}
}
while (!motor_.finish ()/* && !motor_.blocked()*/);
@@ -355,5 +429,60 @@ Ai::avoidrobot(void)
{
es_.launchSharpDetection();
+
+}
+void
+Ai::launchSharp (void)
+{
+ es_.launchSharpDetection ();
+ while (!update ());
+}
+///action du roulo
+void
+Ai::rouloAction(void)
+{
+ es_.roulo_tombe();
+ temporisation(1500);
+ es_.roulo_roule(0x50);
+}
+void
+Ai::test_ascenseur (void)
+{
+ es_.moveAsc (0x70, 0xde, true);
+ while (!update ());
+ temporisation (6000);
+ es_.moveAsc (0x70, 0xFF, false);
+ temporisation (1000);
+ es_.moveAsc (0x70, 0x30, false);
+// es_.bougeascDown ();
+ while (!update ());
+}
+
+void
+Ai::moveAsc (bool up)
+{
+ if (up)
+ {
+ bougeAsc (0x70, 0xE5, up);
+ while (!update ());
+ temporisation (6000);
+ }
+ else
+ {
+ bougeAsc (0x70, 0xFF, up);
+ while (!update ());
+ temporisation (4000);
+ bougeAsc (0x70, 0x30, up);
+ while (!update ());
+ temporisation (1000);
+ }
+ while (!update ());
+}
+
+void
+Ai::bougeAsc (int speed, int time, bool up)
+{
+ es_.moveAsc (speed, time, up);
+ while (!update ());
}
diff --git a/i/chuck/src/ai/ai.hh b/i/chuck/src/ai/ai.hh
index b19dbc8..bb07000 100644
--- a/i/chuck/src/ai/ai.hh
+++ b/i/chuck/src/ai/ai.hh
@@ -34,7 +34,8 @@
#define PI 3.14159
#define R90 1.57079
-#define R45 0.7854
+#define R45 0.65
+#define R35 0.6108
class Ai
{
@@ -59,7 +60,7 @@ class Ai
Ai(const Config & config);
/// Destructeur du robot
~Ai(void);
-
+
/// Initialisation du robal
void init(void);
/// Arrête complêtement le robot
@@ -83,5 +84,14 @@ class Ai
void motorRotate (double d);
void motorDeblock(void);
void avoidrobot(void);
+ void rouloAction(void);
+ void launchSharp (void);
+ ///bourrine prog homo
+ void progH2(void);
+ /// Initialisation du robal
+ void test_ascenseur (void);
+ void bougeAsc (int speed, int time, bool up);
+ void moveAsc (bool up);
+ void fuckTheWall (void);
};
#endif // ai_hh
diff --git a/i/chuck/src/ai/test_ai.cc b/i/chuck/src/ai/test_ai.cc
index 1993036..39ddaf1 100644
--- a/i/chuck/src/ai/test_ai.cc
+++ b/i/chuck/src/ai/test_ai.cc
@@ -59,9 +59,31 @@ class TestAi : public Tester
// Add functions
interpreter.add ("progMatch", Interpreter::memFunc (ai_, &Ai::progMatch),
"progMatch ()");
- interpreter.add
+ interpreter.add ("progH2",Interpreter::memFunc (ai_, &Ai::progH2),"prog bourrin");
+ interpreter.add
+ ("progH", Interpreter::memFunc (ai_, &Ai::progHomoloRobal),
+ "prog d'homologation");
+interpreter.add ("roulo", Interpreter::memFunc (ai_, &Ai::rouloAction),"mise en fonction du roulo + servo");
+interpreter.add ("rotate",Interpreter::memFunc (ai_, &Ai::motorRotate), "angle en radian");
+interpreter.add
("avoid", Interpreter::memFunc (ai_, &Ai::avoidrobot),
"do the avoid prog");
+ interpreter.add("motorMove",Interpreter::memFunc (ai_, &Ai::motorMove),"bouge le robot avec les sharp");
+ interpreter.add
+ ("launchSharp", Interpreter::memFunc (ai_, &Ai::launchSharp),
+ "start sharp");
+ interpreter.add
+ ("test_ascenseur", Interpreter::memFunc (ai_, &Ai::test_ascenseur),
+ "test_ascenseur");
+ interpreter.add
+ ("temporisation", Interpreter::memFunc (ai_, &Ai::temporisation),
+ "temporisation");
+ interpreter.add
+ ("init", Interpreter::memFunc (ai_, &Ai::init),
+ "init");
+ interpreter.add
+ ("bougeAsc", Interpreter::memFunc (ai_, &Ai::bougeAsc),
+ "bougeAsc");
}
void postRun(void)
{
diff --git a/i/chuck/src/asserv/asserv.cc b/i/chuck/src/asserv/asserv.cc
index e196803..eb87b71 100644
--- a/i/chuck/src/asserv/asserv.cc
+++ b/i/chuck/src/asserv/asserv.cc
@@ -385,3 +385,9 @@ Asserv::radToStep (double a) const
return static_cast<int> (static_cast<double> (footing_) * a * 0.5);
}
+void
+Asserv::fuckTheWall (int seq)
+{
+ proto_.send ('f', "b", seq);
+}
+
diff --git a/i/chuck/src/asserv/asserv.hh b/i/chuck/src/asserv/asserv.hh
index c740b1b..42763da 100644
--- a/i/chuck/src/asserv/asserv.hh
+++ b/i/chuck/src/asserv/asserv.hh
@@ -125,6 +125,7 @@ class Asserv : public Proto::Receiver
void clearParams (void);
/// Implémentation du proto::Receiver.
void receive (char command, const Proto::Frame &frame);
+ void fuckTheWall (int seq);
/* ///
*
diff --git a/i/chuck/src/es/es.cc b/i/chuck/src/es/es.cc
index 1f32925..9927727 100644
--- a/i/chuck/src/es/es.cc
+++ b/i/chuck/src/es/es.cc
@@ -32,7 +32,7 @@
/// Constructeur
Es::Es (const Config & config)
: proto_ (*this), log_ ("Es"), lcdKeyPressed_ (-1), front_sensor_ (false),
- jackIn_ (false),colorModeBlue_(false)
+ jackIn_ (false),colorModeBlue_(false),ackSharp_(false)
{
// Récupération des valeurs de configuration dans le fichier
@@ -87,7 +87,6 @@ Es::reset (void)
lcdGetKey (lcdKeyStat_);
// XXX Hardcoded value !
setSharpThreshold (1, thresholdSharp_, thresholdSharp_);
- launchSharpDetection ();
log_ ("Es", Log::debug) << "Reset Es done.";
}
@@ -240,24 +239,26 @@ void Es::receive(char command, const Proto::Frame & frame)
//Activation du truk ki monte et descend.
void
-Es::bouge_ascenceur(uint8_t vit,uint8_t tps,uint8_t sens)
+Es::bouge_ascenceur(void)
{
- proto_.send('a',"bbb",vit,tps,0x00);
- for(int cpt=0;cpt<5;cpt++)
- {
- proto_.send('a',"bbb",0xFF,0x05,0x01);
- proto_.send('a',"bbb",0xFF,0x05,0x00);
- }
- proto_.send('a',"bbb",vit,tps,0x01);
- proto_.send('a',"bbb",vit,tps,0x01);
- //faire un static pour savoir la dernière commande.
- //permettra de faire l'inverse en automatique.
+ proto_.send('a',"bbb",0x70,0xde,0x00);
+
+ /*roulo_roule(0x00);*/
+}
+void
+Es::bougeascDown(void)
+{
+proto_.send('a',"bbb",0x60,0xf0,0x01);
+
+
+ /* roulo_roule(0x00);*/
}
+
//le roulo qui roule
void
-Es::roulo_roule(int vit) //je c pas encore trop le type
+Es::roulo_roule(uint8_t vit)
{
proto_.send('R',"b",vit);
}
@@ -276,12 +277,16 @@ Es::setcolorsens(void)
}
}
-
+void
+Es::initservo(void)
+{
+ proto_.send('m',"bb",0x02,0x00);
+}
//Le roulo tombe grace au servo
void
Es::roulo_tombe(void)
{
- proto_.send('m',"bb",0x00,0x7b);
+ proto_.send('m',"bb",0x02,0x7b);
}
@@ -293,3 +298,10 @@ Es::launchSharpDetection (void)
setSharpUpdate (2, freqSharp_);
}
+/// Move ascenseur
+void
+Es::moveAsc (int speed, int time, bool up)
+{
+ proto_.send ('a', "bbb", speed, time, up ? 0x0 : 0x1);
+}
+
diff --git a/i/chuck/src/es/es.hh b/i/chuck/src/es/es.hh
index f5eeff4..0c26df0 100644
--- a/i/chuck/src/es/es.hh
+++ b/i/chuck/src/es/es.hh
@@ -119,15 +119,17 @@ class Es : public Proto::Receiver
/// Get the current pressed keys of the LCD
void lcdGetKey (int freq);
+ void moveAsc (int speed, int time, bool way);
///Activé l'assenceur
- void bouge_ascenceur(uint8_t vit,uint8_t tps,uint8_t sens);
- ///rotate Left or Right
+ void bouge_ascenceur(void);
+ void bougeascDown(void);
+///rotate Left or Right
int setcolorsens(void);
//a finir pour def le vit
- void roulo_roule(int vit);
+ void roulo_roule(uint8_t vit);
//le roulo tombe
void roulo_tombe(void);
-
+ void initservo(void);
/// Get sharp ack
bool getSharpAck (void) const { return ackSharp_; }
diff --git a/i/chuck/src/es/test_es.cc b/i/chuck/src/es/test_es.cc
index c6cbfb1..be8712e 100644
--- a/i/chuck/src/es/test_es.cc
+++ b/i/chuck/src/es/test_es.cc
@@ -66,6 +66,8 @@ class TestEs : public Tester
" - time : time to wait in ms");
interpreter.add
+ ("down",Interpreter::memFunc (es_, &Es::bougeascDown), "fait descendre l'ascenseur");
+ interpreter.add
("sharpUp", Interpreter::memFunc (es_, &Es::setSharpUpdate),
"Set sharp update frequency (mask, freq)");
interpreter.add
diff --git a/i/chuck/src/motor/motor.cc b/i/chuck/src/motor/motor.cc
index 78fc8b6..8134d14 100644
--- a/i/chuck/src/motor/motor.cc
+++ b/i/chuck/src/motor/motor.cc
@@ -190,3 +190,12 @@ Motor::receiveInPort (unsigned int port)
{
}
+void
+Motor::fuckTheWall (void)
+{
+ nextSeq ();
+ finish_ = false;
+ blocked_ = false;
+ asserv_.fuckTheWall (seq_);
+}
+
diff --git a/i/chuck/src/motor/motor.hh b/i/chuck/src/motor/motor.hh
index 4289201..7727a34 100644
--- a/i/chuck/src/motor/motor.hh
+++ b/i/chuck/src/motor/motor.hh
@@ -71,6 +71,7 @@ class Motor : public Asserv::Receiver
void getPosition(double & x, double & y, double & a) const;
/// DO the super Crénaux
bool docreno(void);
+ void fuckTheWall (void);
private:
diff --git a/i/chuck/src/motor/test_motor.cc b/i/chuck/src/motor/test_motor.cc
index 760dfd6..c2b6f77 100644
--- a/i/chuck/src/motor/test_motor.cc
+++ b/i/chuck/src/motor/test_motor.cc
@@ -72,6 +72,8 @@ class TestMotor : public Tester
"rotate round axis center");
i.add ("findHole", Interpreter::memFunc (motor_, &Motor::findHole),
"findHole\nfind a hole");
+ i.add ("fuckTheWall", Interpreter::memFunc (motor_, &Motor::fuckTheWall),
+ "fuckTheWall\nFuck the wall !");
i.add ("stop", Interpreter::memFunc (motor_, &Motor::stop),
"stop\nguess what");
i.add ("_postcall",