Skip to content
This repository has been archived by the owner on Mar 3, 2019. It is now read-only.

Commit

Permalink
Ajout d'une option de debug pour les capteurs
Browse files Browse the repository at this point in the history
  • Loading branch information
PFGimenez committed Apr 26, 2017
1 parent ee6da38 commit 1dd4070
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
Binary file modified documentation/doc_config_HL.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion pc/src/Homologation.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static void main(String[] args)

KeyPathCache k = new KeyPathCache(state);
k.shoot = false;
k.s = sm.getScripts().get("MINERAI_CRATERE_HAUT_GAUCHE");
k.s = sm.getScripts().get("MINERAI_CRATERE_HAUT_DROITE");
try {
path.prepareNewPathToScript(k);
path.sendPreparedPath();
Expand Down
5 changes: 5 additions & 0 deletions pc/src/capteurs/CapteursProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class CapteursProcess implements Service, LowPFClass, HighPFClass
private Capteur[] capteurs;
private double imprecisionMaxPos;
private double imprecisionMaxAngle;
private boolean debugCapteurs;

private long dateLastMesureCorrection = -1;
private long peremptionCorrection;
Expand All @@ -90,6 +91,7 @@ public CapteursProcess(Container container, Log log, GridSpace gridspace, Table
bufferCorrection = new Cinematique[config.getInt(ConfigInfo.TAILLE_BUFFER_RECALAGE)];
peremptionCorrection = config.getInt(ConfigInfo.PEREMPTION_CORRECTION);
enableCorrection = config.getBoolean(ConfigInfo.ENABLE_CORRECTION);
debugCapteurs = config.getBoolean(ConfigInfo.DEBUG_CAPTEURS);

int demieLargeurNonDeploye = config.getInt(ConfigInfo.LARGEUR_NON_DEPLOYE)/2;
int demieLongueurArriere = config.getInt(ConfigInfo.DEMI_LONGUEUR_NON_DEPLOYE_ARRIERE);
Expand Down Expand Up @@ -183,6 +185,9 @@ public void updateObstaclesMobiles(SensorsData data)
if(positionEnnemi.isHorsTable())
continue; // hors table

if(debugCapteurs)
log.debug("Ajout d'un obstacle d'ennemi en "+positionEnnemi);

ObstacleProximity o = gridspace.addObstacleAndRemoveNearbyObstacles(positionEnnemi);

/**
Expand Down
1 change: 1 addition & 0 deletions pc/src/config/ConfigInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public enum ConfigInfo {
*/
DEBUG_SERIE_TRAME(false), // debug verbeux sur le contenu des trames
DEBUG_SERIE(false), // debug sur la série
DEBUG_CAPTEURS(false), // debug verbeux sur les capteurs
GENERATE_DEPENDENCY_GRAPH(false), // génère le graphe des dépendances

/**
Expand Down
5 changes: 4 additions & 1 deletion pc/src/pathfinding/chemin/CheminPathfinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class CheminPathfinding implements Service, Printable, HighPFClass, Chemi
private int lastValidIndex = -1; // l'indice du dernier index (-1 si aucun ne l'est, Integer.MAX_VALUE si tous le sont)
private boolean uptodate = true; // le chemin est-il complet
private int margeNecessaire, margeInitiale;
private boolean graphic;
private boolean graphic, debugCapteurs;

public CheminPathfinding(Log log, BufferOutgoingOrder out, ObstaclesIteratorPresent iterator, PrintBufferInterface buffer, Config config)
{
Expand All @@ -79,6 +79,7 @@ public CheminPathfinding(Log log, BufferOutgoingOrder out, ObstaclesIteratorPres
margeNecessaire = config.getInt(ConfigInfo.PF_MARGE_NECESSAIRE);
margeInitiale = config.getInt(ConfigInfo.PF_MARGE_INITIALE);
graphic = config.getBoolean(ConfigInfo.GRAPHIC_TRAJECTORY_FINAL);
debugCapteurs = config.getBoolean(ConfigInfo.DEBUG_CAPTEURS);
if(graphic)
buffer.add(this);

Expand Down Expand Up @@ -121,6 +122,8 @@ public synchronized void checkColliding()
{
if(isColliding())
{
if(debugCapteurs)
log.warning("Un ennemi est sur le chemin : replanification nécessaire");
uptodate = false;
notify();
}
Expand Down
10 changes: 8 additions & 2 deletions pc/src/threads/ThreadUpdatePathfinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package threads;

import config.Config;
import config.ConfigInfo;
import container.dependances.HighPFClass;
import exceptions.PathfindingException;
import pathfinding.astar.AStarCourbe;
Expand All @@ -34,12 +36,14 @@ public class ThreadUpdatePathfinding extends ThreadService implements HighPFClas
protected Log log;
private AStarCourbe pathfinding;
private CheminPathfinding chemin;
private boolean debugCapteurs;

public ThreadUpdatePathfinding(Log log, AStarCourbe pathfinding, CheminPathfinding chemin)
public ThreadUpdatePathfinding(Log log, AStarCourbe pathfinding, CheminPathfinding chemin, Config config)
{
this.log = log;
this.pathfinding = pathfinding;
this.chemin = chemin;
debugCapteurs = config.getBoolean(ConfigInfo.DEBUG_CAPTEURS);
}

@Override
Expand All @@ -53,7 +57,9 @@ public void run()
if(chemin.isUptodate())
chemin.wait();
try {
pathfinding.updatePath(false);
if(debugCapteurs)
log.debug("Mise à jour du chemin");
pathfinding.updatePath(true);
} catch (PathfindingException e) {
e.printStackTrace();
}
Expand Down
5 changes: 3 additions & 2 deletions pc/src/threads/serie/ThreadSerialInputCoucheOrdre.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ThreadSerialInputCoucheOrdre extends ThreadService implements Seria
private Container container;

private boolean capteursOn = false;
private boolean debugSerie;
private boolean debugSerie, debugCapteurs;
private int nbCapteurs;

public ThreadSerialInputCoucheOrdre(Log log, Config config, BufferIncomingOrder serie, SensorsDataBuffer buffer, RobotReal robot, CheminPathfinding chemin, Container container)
Expand All @@ -67,6 +67,7 @@ public ThreadSerialInputCoucheOrdre(Log log, Config config, BufferIncomingOrder
this.robot = robot;
this.chemin = chemin;
debugSerie = config.getBoolean(ConfigInfo.DEBUG_SERIE);
debugCapteurs = config.getBoolean(ConfigInfo.DEBUG_CAPTEURS);
}

@Override
Expand Down Expand Up @@ -153,7 +154,7 @@ else if(paquet.origine == OutOrder.START_STREAM_ALL)
for(int i = 0; i < nbCapteurs; i++)
{
mesures[i] = data[8+i];
if(debugSerie)
if(debugSerie || debugCapteurs)
log.debug("Capteur "+CapteursRobot.values[i].name()+" : "+mesures[i]);
}
if(capteursOn)
Expand Down

0 comments on commit 1dd4070

Please sign in to comment.