From b22bb601a027ad33097f8bd0f3d34bc579718a75 Mon Sep 17 00:00:00 2001 From: dufourj Date: Fri, 18 May 2007 22:17:45 +0000 Subject: * General: - commit post hoomologation. * Ai: - add functions to manage sharps, "rouleau", ascensor and fuck the wall. * Motor & Asserv: - update fuck the wall. * Es: - ascensor management; - "rouleau" management. * ToDo: - too much functions to manage the ascensor, simplify! --- i/chuck/runtime/rc/config | 12 +- i/chuck/src/ai/ai.cc | 283 +++++++++++++++++++++++++++++----------- i/chuck/src/ai/ai.hh | 14 +- i/chuck/src/ai/test_ai.cc | 24 +++- i/chuck/src/asserv/asserv.cc | 6 + i/chuck/src/asserv/asserv.hh | 1 + i/chuck/src/es/es.cc | 44 ++++--- i/chuck/src/es/es.hh | 10 +- i/chuck/src/es/test_es.cc | 2 + i/chuck/src/motor/motor.cc | 9 ++ i/chuck/src/motor/motor.hh | 1 + i/chuck/src/motor/test_motor.cc | 2 + 12 files changed, 303 insertions(+), 105 deletions(-) (limited to 'i') 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"< (static_cast (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 @@ -65,6 +65,8 @@ class TestEs : public Tester "Blocking wait (time)\n" " - 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)"); 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", -- cgit v1.2.3