--- title: "Point IA" date: "17-10-2020" link: "https://hackmd.io/6Z3mqogPQDO7mPU29dCX5Q" tags: EVOLUTEK --- # Point IA ## JSON Les objectifs (Goal): ```json= { "name" = "goal", "position" = { "x": 1500, "y": 1000 }, "actions" = [ // See Actions ], // Optionals "theta" = 0.0, "score" = 42, "obstacles" = [ "buoy1", "buoy2" ], "secondary_goal" = "secondary", "timeout" aw = 0.0 } ``` Les actions (Action): ```json= { "fct": "test" "handler": "actuators" // Actuators or Robot or AI "args": { "sens": False }, // Optionals "avoid": True, "avoid_startegy": "AvoidStrategy.Timeout", // See Avoid strategy "timeout": 0.0, "score": 0.0 } ``` Les stratégies (Strategy): ```json= { "name": "a", "goals": [ "1", "2" ], "available": [ "pal", "pmi" ] } ``` Objectif critique (Critical Goal): ```json= { "goal": "name", "timeout": 0.0 } ``` Les positions de départ (Starting Pos): ```json= "starting_pos": { "pal": { "x": 0, "y": 0, "theta": 0 }, "pmi": { "x": 0, "y": 0, "theta": 0 } } ``` ## Init - Init des variables : - cs - actuators - robot - score - goals - fsm - events (reset, recalibration, match_start, match_end, critical_timeout) - timer critical - Setup : - Init le gpio tirette - Lancer le thread de la FSM - Lancer le thread de l'interface => TODO ## Setup - Enable trajman - Mettre le MDB en color mode - Reset actuators - Reset avec la stratégie choisie - Reset des variables - Disable l'évitement - Reset le timer critical - Si recalibration : - Recalibration - Go Home - Si pas recalibration : - free robot - set pos - unfree ## Waiting - Wait for reset or match start - Reset event - Return l'état (setup ou selecting) - Si début du match, lancement du timer du critical ## Selecting - On prend l'objectif suivant - Si le timer de critical est fini, go faire le critical - Si plus d'objectif, fin du match ## Making - goto with path to position / with avoid selon le bouton - Selon le retour : - reached : pass - unreachable : - si pas d'objectif secondaire : on attend - si un timeout : on attend le temps du timeout puis on go sur - si pas de timeout : on go secondaire direct - goto theta if theta is in goal - reached : pass - has_avoid : bug ? error ? - unreached : retry puis error si refailed voir une tentative de récup - for action in actions: - enable/disable l'évitement avant et après les actions - action.make() - code de retour : - reached : pass - unreached : error - has_avoid : - on move back ? - wait : on attend - timeout : on skip - skip - if score in action : update score - update score - entre chaque étape : - check ending - check critical ## Ending - Reset event - Free et disable robot - Free et disable Actuators - Set MDB mode 2 - Stop critical timer ## Error - Free et disable robot - Free et disable actuators - Set MDB error ## TODO - Clear les valeurs des capteurs sur le MDB - Tester à partir de quel angle la gravité ne fait pas tomber l'ax5 free (ressors en secours) - Tester if it can avoid during rotation - Coder une tentaive de récupération - Ajouter un bouton sur l'interface pour désactiver le pathfinding (goto_avoid au lieu de goto_with_path) - Ajouter l'état de l'ia sur l'interface - Problème telemtrie ? - Lancer l'IA après que l'interface graphique est lancée