diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/comm/ParameterIdList.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/comm/ParameterIdList.java index 054d526..df3c4ae 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/comm/ParameterIdList.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/comm/ParameterIdList.java @@ -10,7 +10,7 @@ public final class ParameterIdList /* * This parameter list belongs to the communication protocol number 0. */ - public final static byte BATTERY_VOLTAGE = 1, + public final static byte BATTERY_VOLTAGE = 1, GYRO_ANGLE = 2, TACHO_LEFT = 3, TACHO_RIGHT = 4, diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/NXT.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/NXT.java index 7c25a05..fe2b728 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/NXT.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/NXT.java @@ -28,6 +28,7 @@ public class NXT /** * Is the main method on the NXT. Calls the mainMenu method to create the visible menu and initiate the Communication and Balancing Thread. + * * @param unused * @throws InterruptedException */ @@ -36,11 +37,11 @@ public static void main(String[] args) throws InterruptedException { } /** - * Initiates the Connection, by calling the connect method of the COMMUNICATOR. - * - * The method runs in a endless loop until the Escape Button is hold down during a connection timeout, + * Initiates the Connection, by calling the connect method of the COMMUNICATOR. + * The method runs in a endless loop until the Escape Button is hold down during a connection timeout, * if the connection is whether established nor beeing established the NXT tries to connect with the PC. * If startBalancing is set to true, then the Method initiates SensorData and starts the Balancing thread after 3 seconds. + * * @throws InterruptedException */ public static void mainMenu() throws InterruptedException { diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/AbstractConnector.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/AbstractConnector.java index 0328012..cfa29b9 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/AbstractConnector.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/AbstractConnector.java @@ -18,6 +18,7 @@ public AbstractConnector() { /** * Check if an connection is established. + * * @return true iff an connection is established. */ public final boolean connectionEstablished() { diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/BluetoothConnector.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/BluetoothConnector.java index ace779e..745ed21 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/BluetoothConnector.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/BluetoothConnector.java @@ -10,11 +10,11 @@ */ final class BluetoothConnector extends AbstractConnector { - @Override /** * Performs the connection. after 20 seconds it breaks the attempt and sets connection to null. * This method is blocking. */ + @Override public void run() { connection = Bluetooth.waitForConnection(20000, NXTConnection.PACKET); isConnecting = false; diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/CommunicatorNXT.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/CommunicatorNXT.java index ccbe7cb..7815b73 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/CommunicatorNXT.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/CommunicatorNXT.java @@ -31,7 +31,6 @@ public final class CommunicatorNXT extends AbstractCommunicator final private byte protocolVersion = 2; public static boolean sendEvoMeasurement = false; - /** * Constructor of the NXT Communicator. It registers all handlers at the beginning to allow for processing of incoming commands, * after an connection is established. @@ -123,11 +122,10 @@ public void disconnect() { } } - /** * Private class to send an Status Packet and the value of the UltraSonic sensor each tick. It provides the declared auto status package from the communication protokol. + * * @author Gregor - * */ private final class NXTCommandListener extends CommandListener { @@ -175,7 +173,8 @@ protected void logException(IOException ex) { } /** - * Sends the internal Protocol Version that this NXT is using. + * Sends the internal Protocol Version that this NXT is using. + * * @throws IOException */ public void sendProtocolVersion() throws IOException { @@ -186,6 +185,7 @@ public void sendProtocolVersion() throws IOException { /** * This function returns an integer value corresponding the paramID that was asked by the PC. + * * @param param paramID of the requested value. * @param value integer value of the requested variable. * @throws IOException @@ -209,6 +209,7 @@ public void sendGetReturnUltraSensor(byte value) throws IOException { /** * This function returns a float values corresponding the paramID that were asked by the PC. + * * @param param paramID of the requested value. * @param value float value of the requested variable. * @throws IOException @@ -222,6 +223,7 @@ public void sendGetReturn(byte param, float value) throws IOException { /** * This function returns two float values corresponding the paramID that were asked by the PC. + * * @param param paramID of the requested value. * @param value1 float value of the requested variable. * @param value2 float value of the requested variable. @@ -237,6 +239,7 @@ public void sendGetReturn(byte param, float value1, float value2) throws IOExcep /** * This function returns four float values corresponding the paramID that were asked by the PC. + * * @param param paramID of the requested value. * @param value1 float value of the requested variable. * @param value2 float value of the requested variable. @@ -256,6 +259,7 @@ public void sendGetReturn(byte param, float value1, float value2, float value3, /** * This function returns a double value corresponding the paramID that were asked by the PC. + * * @param param paramID of the requested value. * @param value double value of the requested variable. * @throws IOException @@ -269,6 +273,7 @@ public void sendGetReturn(byte param, double value) throws IOException { /** * This function returns four double values corresponding the paramID that were asked by the PC. + * * @param param paramID of the requested value. * @param value1 double value of the requested variable. * @param value2 double value of the requested variable. @@ -288,6 +293,7 @@ public void sendGetReturn(byte param, double value1, double value2, double value /** * This function returns a long value corresponding the paramID that were asked by the PC. + * * @param param paramID of the requested value. * @param value long value of the requested variable. * @throws IOException @@ -301,6 +307,7 @@ public void sendGetReturn(byte param, long value) throws IOException { /** * This function returns a boolean value corresponding the paramID that were asked by the PC. + * * @param param paramID of the requested value. * @param value boolean value of the requested variable. * @throws IOException @@ -314,6 +321,7 @@ public void sendGetReturn(byte param, boolean value) throws IOException { /** * Sends a Messega Info the the PC with an custom message. The length of the message can have between 0 and 255 chars. + * * @param length length of infoMessage * @param infoMessage an array of chars containing the message * @throws IOException @@ -327,6 +335,7 @@ public void sendLogInfo(byte length, byte[] infoMessage) throws IOException { /** * Setter for the autoStatusThread. Activates or deactivetes the sending of auto status packages + * * @param isOn of true, then activates the autoStatusThread, otherwise deactivates it. */ public void setAutoStatusThread(boolean isOn) { @@ -338,6 +347,7 @@ public void setAutoStatusThread(boolean isOn) { /** * Sends a defined error code message to the PC. An IOException is catched in case the error was caused by an connection error. + * * @param errorCode error code defined in errorCodes */ public static void sendErrorCode(byte errorCode) { diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/USBConnector.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/USBConnector.java index 5f50d71..eed06ba 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/USBConnector.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/USBConnector.java @@ -10,11 +10,11 @@ */ final class USBConnector extends AbstractConnector { - @Override /** * Performs the connection. after 5 seconds it breaks the attempt and sets connection to null. * This method is blocking. */ + @Override public void run() { connection = USB.waitForConnection(5000, NXTConnection.PACKET); isConnecting = false; diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/BalancingHandler.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/BalancingHandler.java index 68a8262..def6c79 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/BalancingHandler.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/BalancingHandler.java @@ -14,7 +14,6 @@ */ public class BalancingHandler implements CommandHandler { - @Override /** * This method reads a boolean of the DataInputStream and * either starts or stops the balancing of the NXT depending on the value. @@ -22,6 +21,7 @@ public class BalancingHandler implements CommandHandler * * @param is: The DataInputStream the handler uses to receive data. */ + @Override public void handle(DataInputStream is) throws IOException { final boolean enabled = is.readBoolean(); if (enabled) diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/DisconnectHandler.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/DisconnectHandler.java index 0ba29c2..7d2cb74 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/DisconnectHandler.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/DisconnectHandler.java @@ -14,11 +14,12 @@ */ public class DisconnectHandler implements CommandHandler { - @Override /** * This method calls a static method of the {@link CommunicatorNXT} to disconnect safely. - * @param is: The DataInputStream the handler could use to receive data. This handler does not use the input-stream. + * + * @param is: The DataInputStream the handler could use to receive data. This handler does not use the input-stream. */ + @Override public void handle(DataInputStream is) throws IOException { CommunicatorNXT.staticDisconnect(); } diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/GetHandler.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/GetHandler.java index 65b3804..032ea08 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/GetHandler.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/GetHandler.java @@ -18,7 +18,6 @@ */ public final class GetHandler implements CommandHandler { - @Override /** * This method reads a parameter and switches it. * Depending on the parameter, the number and type of the values to be send varies. @@ -29,6 +28,7 @@ public final class GetHandler implements CommandHandler * * @param is: The DataInputStream the handler uses to receive data */ + @Override public void handle(DataInputStream is) throws IOException { final byte param = is.readByte(); switch (param) { diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/MoveHandler.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/MoveHandler.java index 5efb8ef..004ae53 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/MoveHandler.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/MoveHandler.java @@ -14,7 +14,6 @@ */ public class MoveHandler implements CommandHandler { - @Override /** * This method reads a float of the input-stream * and calls a method of the {@link MotorController} to let the NXT move the distance. @@ -22,6 +21,7 @@ public class MoveHandler implements CommandHandler * * @param is: The DataInputStream the handler uses to receive data. */ + @Override public void handle(DataInputStream is) throws IOException { final float distance = is.readFloat(); MotorController.move(distance); diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/SetHandler.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/SetHandler.java index 056a4f4..795fdc1 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/SetHandler.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/SetHandler.java @@ -17,21 +17,21 @@ */ public final class SetHandler implements CommandHandler { - @Override /** * This method reads a parameter and switches it. * Depending on the parameter, the number and type of the values varies. * In most cases, this method simply sets the internal values of the NXT to the new values. - * + *
* Notable parameters that differ in this: * AUTO_STATUS_PACKET additionally displays the parameter and the value on the NXT. * PID_MOTOR_DISTANCE, PID_MOTOR_SPEED and PARAM_WHEEL_DIAMETER need some calculation. * EVO_COLLECT_TESTDATA eventually calls a method of {@link SensorData} to reset the test data. - * + *
* The default case displays an error message on the NXT that the parameter is unknown. * * @param is: The DataInputStream the handler uses to receive data. */ + @Override public void handle(DataInputStream is) throws IOException { final byte param = is.readByte(); switch (param) { diff --git a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/TurnHandler.java b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/TurnHandler.java index 9818bc6..a8865b2 100644 --- a/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/TurnHandler.java +++ b/NXT/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/ntx/comm/handler/TurnHandler.java @@ -14,7 +14,6 @@ */ public class TurnHandler implements CommandHandler { - @Override /** * This method reads a float and * calls a method of the {@link MotorController} to let the NXT turn by the angle. @@ -22,9 +21,10 @@ public class TurnHandler implements CommandHandler * * @param is: The DataInputStream the handler uses to receive data. */ + @Override public void handle(DataInputStream is) throws IOException { final float angle = is.readFloat(); MotorController.turn(angle); - System.out.println("Turning by " + angle + "°"); + System.out.println("Turning by " + angle + "�"); } } diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/PC.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/PC.java index ca16b5f..43d0591 100644 --- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/PC.java +++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/PC.java @@ -6,7 +6,6 @@ * The main function of the PC Project, that lunches the GUI is started here. * * @author Christian - * */ public class PC diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/CommunicatorPC.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/CommunicatorPC.java index 430d951..f0ed41a 100644 --- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/CommunicatorPC.java +++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/CommunicatorPC.java @@ -31,7 +31,7 @@ public final class CommunicatorPC extends AbstractCommunicator private boolean connected; public byte nxtProtocol = 0; private final NXTData data; - + /** * The constructor of a CommunicatorPC. * Assigns the UI and the NXTData the communicator interacts with. @@ -39,7 +39,7 @@ public final class CommunicatorPC extends AbstractCommunicator * * @param ui: The UI the communicator uses to show messages. Is needed for some handlers, too. * @param data: The NXTData the communicator uses to safe and read current data of the NXT. Is needed for some handlers, too. - * @param navi: The Navigator the GetReturnHandler needs to interact with. + * @param navi: The Navigator the GetReturnHandler needs to interact with. */ public CommunicatorPC(UserInterface ui, NXTData data, Navigator navi) { this.ui = ui; @@ -51,15 +51,14 @@ public CommunicatorPC(UserInterface ui, NXTData data, Navigator navi) { System.out.println("Registered all handlers."); } - @Override /** * This method tries to connect the PC to an NXT in case the PC is not already connected. * If an NXT is successfully linked, the method creates DataStreams for the input and output. * The streams are piped and the AUTO_STATUS_PACKET will be set to true. * Finally, the CommandListener is started. - * * If any of these steps fail, the method prints a corresponding message and disconnects. */ + @Override public void connect() { if (!isConnected()) { ui.showMessage("Trying to connect"); @@ -104,7 +103,6 @@ public void connect() { } } - @Override /** * This method disconnects from an NXT. This does not send the NXT a corresponding command * to close its connection. @@ -112,6 +110,7 @@ public void connect() { * The connection status (saved in the boolean connected) is updated and shown in the UI. * Afterwards, the method tries to close the connection. */ + @Override public void disconnect() { logMessage(connected ? "Connection closed unexpectedly" : "Connection closed cleanly", false); connected = false; // In case connection was closed unexpectedly @@ -139,24 +138,24 @@ public void disconnectInit() { } } - @Override /** - * Returns the connection status. + * Returns the connection status. * This is needed to prevent threads from sending data through closed connections. */ + @Override public boolean isConnected() { return connected; } - @Override /** * Prints an exception in case the reading of the InputStream failed. */ + @Override protected void logException(IOException ex) { System.out.println("Exception in CommunicatorPC on read."); ex.printStackTrace(); } - + /** * The PCCommandListener extends a usual CommandListener * as it synchronizes the incoming and outgoing communication. @@ -167,12 +166,12 @@ public PCCommandListener() { super(true); } - @Override /** * This method synchronizes the read and write process in the communication on the PC side. * As long as there is data available in the InputStream, the data is read and * an equivalent amount of data is written and flushed in the OutputStream. */ + @Override protected void additionalAction() throws IOException { // Flush piped input int availableDataLen = 0; @@ -187,15 +186,17 @@ protected void additionalAction() throws IOException { /** * Sets the protocol version for the GUI. + * * @param version: Received protocol version */ public void setProtocolVersion(byte version) { nxtProtocol = version; } - + /** * This method secures that a command and its parameter will only be sent * if the protocol version of the NXT is valid and can handle the parameter. + * * @param param: The parameter-ID that is to be checked * @return true, if the NXT can handle the parameter concerning its protocol version. */ @@ -345,12 +346,10 @@ public boolean sendGet(byte param) { return sendGet(param, false); } - /** * This method tries to send a GET-command for a parameter and its value. * Calls a method to print a corresponding information in the UI depending on its "quiet"-value. * This is needed as some threads periodically send commands and would flood the UI-output. - * * Checks whether it is legal to send the command first and * then tries to pipe the message to the OutputStream. * @@ -387,7 +386,6 @@ public boolean sendMove(float distance) { * This method tries to send a MOVE-command for a certain distance. * Calls a method to print a corresponding information in the UI depending on its "quiet"-value. * This is needed as some threads periodically send commands and would flood the UI-output. - * * Tries to pipe the message to the OutputStream. * * @param quiet: if true, will not print "Sending ..." @@ -414,12 +412,11 @@ public synchronized boolean sendMove(float distance, boolean quiet) { public boolean sendTurn(float distance) { return sendTurn(distance, false); } - + /** * This method tries to send a TURN-command for a certain angle. * Calls a method to print a corresponding information in the UI depending on its "quiet"-value. * This is needed as some threads periodically send commands and would flood the UI-output. - * * Tries to pipe the message to the OutputStream. * * @param quiet: if true, will not print "Sending ..." @@ -482,6 +479,7 @@ public NXTData getData() { /** * A Method to eventually print a message in the UI, depending on the boolean. + * * @param msg: The message that is to be printed * @param quiet: True, if the message shall not be printed */ @@ -494,6 +492,7 @@ private void logMessage(String msg, boolean quiet) { /** * A method to print a message in the UI. + * * @param msg: The message to be printed */ private void logException(String msg) { @@ -503,6 +502,7 @@ private void logException(String msg) { /** * A method to print an exception and a corresponding message. + * * @param msg: The message to identify the exception * @param ex: The exception to be printed */ diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/ErrorCodeHandler.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/ErrorCodeHandler.java index 1455dfd..5080886 100644 --- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/ErrorCodeHandler.java +++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/ErrorCodeHandler.java @@ -17,19 +17,17 @@ public class ErrorCodeHandler implements CommandHandler { private final UserInterface ui; - + /** * The constructor for an ErrorCodeHandler * * @param ui: The UI on which the handler will print its messages and will call methods to handle the error. */ - + public ErrorCodeHandler(UserInterface ui) { this.ui = ui; } - - @Override /** * This method reads the incoming ERROR_CODE and switches it. * Currently recognized ERROR_CODES: @@ -39,6 +37,7 @@ public ErrorCodeHandler(UserInterface ui) { * * @param is: The DataInputStream the handler uses to receive the ERROR_CODE */ + @Override public void handle(DataInputStream is) throws IOException { final byte param = is.readByte(); switch (param) { diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/GetReturnHandler.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/GetReturnHandler.java index 590958e..0024042 100644 --- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/GetReturnHandler.java +++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/conn/GetReturnHandler.java @@ -9,6 +9,7 @@ import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.gui.MapUpdater; import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.gui.UserInterface; import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.nav.Navigator; + /** * This class handles incoming data marked as GET_RETURN. * The data is sent by an NXT either as an AUTO_STATUS_PACKET or as response to a GET command. @@ -25,8 +26,9 @@ public final class GetReturnHandler implements CommandHandler private final MapUpdater updater; /** - * The constructor for a GetReturnHandler object. + * The constructor for a GetReturnHandler object. * Simply assigns necessary attributes to the object and creates a {@link MapUpdater}. + * * @param ui: The UI on which the handler displays received values for parameters. * @param data: The known data of the NXT which is updated by this handler * @param navi: The navigator the handler sends data of the ultrasonic-sensor to to create a map of the environment. @@ -38,38 +40,38 @@ public GetReturnHandler(UserInterface ui, NXTData data, Navigator navi) { updater = new MapUpdater(ui); } - @Override /** - * This method reads the parameter from the input-stream and switches it. + * This method reads the parameter from the input-stream and switches it. * The type and number of the values depends on the parameter. - * + *
* Currently recognized parameters: - * BATTERY_VOLTAGE: Calls a method of the UI to update the value. - * GYRO_ANGLE: Calls a method of the UI to update the value. - * TACHO_LEFT: Calls a method of the UI to update the value. - * TACHO_RIGHT: Calls a method of the UI to update the value. - * HEADING: Calls a method of the UI to update the value and overwrites the value in the NXTData. - * POSITION: Calls a method of the UI to update the value and overwrites the value in the NXTData. - * MOVEMENT_SPEED: Calls a method of the UI to update the value. - * STATUS_PACKET: Calls a method of the UI to update the values and overwrites the heading and position in NXTData. - * Starts a MapUpdater-thread if possible. - * AUTO_STATUS_PACKET: Calls a method of the UI to update the value. - * PID_GYRO_SPEED: Calls a method of the UI to update the value. - * PID_GYRO_INTEGRAL: Calls a method of the UI to update the value. - * PID_MOTOR_DISTANCE: Calls a method of the UI to update the value. - * PID_MOTOR_SPEED: Calls a method of the UI to update the value. - * PARAM_CONSTANT_ROTATION: Just reads the value to not mess up the input-stream. - * PARAM_CONSTANT_SPEED: Just reads the value to not mess up the input-stream. - * PARAM_WHEEL_DIAMETER: Just reads the value to not mess up the input-stream. - * PARAM_TRACK: Just reads the value to not mess up the input-stream. - * PID_WEIGHT_ALL: Calls a method of the UI to update the value. - * PARAM_ULTRA_SENSOR: Calls a method of the Navigator to update the map. - * EVO_MEASUREMENTS: Calls a method to update the NXTData. - * + *
BATTERY_VOLTAGE: | Calls a method of the UI to update the value. |
GYRO_ANGLE: | Calls a method of the UI to update the value. |
TACHO_LEFT: | Calls a method of the UI to update the value. |
TACHO_RIGHT: | Calls a method of the UI to update the value. |
HEADING: | Calls a method of the UI to update the value and overwrites the value in the NXTData. |
POSITION: | Calls a method of the UI to update the value and overwrites the value in the NXTData. |
MOVEMENT_SPEED: | Calls a method of the UI to update the value. |
STATUS_PACKET: | Calls a method of the UI to update the values and overwrites the heading and position in NXTData. Starts a MapUpdater-thread if possible. |
AUTO_STATUS_PACKET: | Calls a method of the UI to update the value. |
PID_GYRO_SPEED: | Calls a method of the UI to update the value. |
PID_GYRO_INTEGRAL: | Calls a method of the UI to update the value. |
PID_MOTOR_DISTANCE: | Calls a method of the UI to update the value. |
PID_MOTOR_SPEED: | Calls a method of the UI to update the value. |
PARAM_CONSTANT_ROTATION: | Just reads the value to not mess up the input-stream. |
PARAM_CONSTANT_SPEED: | Just reads the value to not mess up the input-stream. |
PARAM_WHEEL_DIAMETER: | Just reads the value to not mess up the input-stream. |
PARAM_TRACK: | Just reads the value to not mess up the input-stream. |
PID_WEIGHT_ALL: | Calls a method of the UI to update the value. |
PARAM_ULTRA_SENSOR: | Calls a method of the Navigator to update the map. |
EVO_MEASUREMENTS: | Calls a method to update the NXTData. |
* The method calculates an obstruction-value in case there is more than one information about the same segment.
* The new value is weighted based on its defective value for the recalculation.
* The weighting is needed to prevent single defective data from damaging the MapData.
diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/evo/EvoAlgorithm.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/evo/EvoAlgorithm.java
index f0d4635..d8be198 100644
--- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/evo/EvoAlgorithm.java
+++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/evo/EvoAlgorithm.java
@@ -16,9 +16,9 @@
import javafx.util.Pair;
/**
- * This class provides functionalities for automated calibration of PID weights for the NXT.
+ * This class provides functionalities for automated calibration of PID weights for the NXT.
* It provides a test, that forces the NXT to balance and make the same movements each run, while it measures control information and sends it after the test to the PC.
- * This class provides two functions to choose next PID-values that have to be testet, a binary search for the optimum and and evolutionary algorithm.
+ * This class provides two functions to choose next PID-values that have to be testet, a binary search for the optimum and and evolutionary algorithm.
*
* @author Gregor, Robin
*/
@@ -36,8 +36,9 @@ public class EvoAlgorithm extends Thread
/**
* class constructor.
+ *
* @param ui reference to the user interface
- * @param comm reference to the PC communicator
+ * @param comm reference to the PC communicator
* @param data NXTData which model the state of the NXT on the PC side
*/
public EvoAlgorithm(UI ui, CommunicatorPC comm, NXTData data) {
@@ -67,9 +68,9 @@ public void run() {
* Provides a binary selection of the PID-values. The PID value defined by {@link weightIdx} will be optimized.
* The algorithm searches first for the upper an lower limit, till it it falls down with the values. Starting with this boundaries it tests
* the selected PID-Weights. In each iteration the algorithm selects the limit with the best fitness value defined by {@link metric} to continue with and halves the
- * limits of the boundaries. The algorithm terminates after an size of the boundaries defined by {@link delta} is reached.
+ * limits of the boundaries. The algorithm terminates after an size of the boundaries defined by {@link delta} is reached.
* The algorithm checks the current database for already measured values to provide faster termination. A minimal size of measurements
- * defined by {@link minGroupSize} has to be reached within the current limits of the current iteration. If the number is not provided by the
+ * defined by {@link minGroupSize} has to be reached within the current limits of the current iteration. If the number is not provided by the
* database, the needed amount of tests will be performed. Each test will start with {@link initial} PIDWeights to allow a clean start.
*
* @param initial PIDvalues used for a clean start
@@ -179,12 +180,10 @@ private double getFitness(PIDWeights weights, int weightIdx, double epsilon, Fit
}
/**
- * Provides an evolutionary selection of PID values that should be tested.
- *
+ * Provides an evolutionary selection of PID values that should be tested.
* The values are selected based the provided {@link metric}. The number of iterations is determined by {@link iterations}.
* In each iteration we create a pool of {@linkplain sizeOfPool} values defined by the following rules.
* {@link epsilon} determines the range of the mutations in percent. This range is halved each iteration.
- *
* In the first Iteration 20% of best values in the current database are selected. The remaining 80% are filled with random mutations.
* In the following Iteration we discard 10% of the current population and select 20% of best individuums from the remaining, last iteration.
* The next 40% of the population are created through linear crossing of values. The remaining 40% are created by randomly mutating the values of the current pool.
@@ -252,6 +251,7 @@ private void evolutionSearch(FitnessMetric metric, int iterations, int sizeOfPoo
/**
* Randomizes the given {@link value} by the percent range defined by {@link epsilon}
+ *
* @param value reference to PID values.
* @param epsilon mutation range in percent.
* @return randomized PID valeus
@@ -268,6 +268,7 @@ private static Pair
* Initially requests every important parameter of the NXT
* to display the values without manual request.
* Proceeds by sending one request in each iteration parameters that
* can be changed.
- *
+ *
* This thread sleeps for 100 ms.
*/
public void run() {
diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/SystemClock.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/SystemClock.java
index 678c568..bdc156d 100644
--- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/SystemClock.java
+++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/SystemClock.java
@@ -15,6 +15,7 @@ public class SystemClock extends Thread
/**
* The constructor for a SystemClock. Assigns necessary attributes.
+ *
* @param ui: The UI which is used to display the connection-time
* @param communicator: The Communicator which is used to determine whether an NXT is connected
*/
@@ -29,7 +30,7 @@ public SystemClock(UserInterface ui, CommunicatorPC communicator) {
* As long as the connection endures (which is determined by calling a method of the {@link CommunicatorPC}),
* a method of the {@link UserInterface} is called to display
* the difference between the current system time and the local variable.
- *
+ *
* The Thread sleeps for 1000 ms.
*/
public void run() {
diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/UI.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/UI.java
index ecc7612..f97136d 100644
--- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/UI.java
+++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/gui/UI.java
@@ -35,7 +35,7 @@
import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.nav.Navigator;
/**
- * This class implements the Graphical User Interface and offers all necessary getter/setter methods
+ * This class implements the Graphical User Interface and offers all necessary getter/setter methods
* for JTextfields and JLabels, as well as ActionListeners for Buttons and Checkboxes.
* Implements abstract @link{UserInterface}, which provides useful methods for connecting to communication
*
@@ -141,6 +141,7 @@ public void showMessage(String text) {
console.append(text + "\n");
console.setCaretPosition(console.getText().length());
}
+
/**
* all necessary getter and setter for labels and texfields
*/
@@ -333,7 +334,6 @@ private void setButtonsEnabled(boolean enabled) {
/**
* clears status Textfields
- *
*/
private void clearLabels() {
tBatteryValtage.setText("");
diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/NavigationThread.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/NavigationThread.java
index 5da3c8a..f546006 100644
--- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/NavigationThread.java
+++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/NavigationThread.java
@@ -1,7 +1,6 @@
package de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.nav;
import java.awt.Point;
-
import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.gui.ApplicationHandler;
/**
@@ -23,7 +22,7 @@ public class NavigationThread extends Thread
private boolean finalMove;
private int idle;
private static final int STANDARD_IDLE_TIME = 10000000;
-
+
/**
* The constructor of the NavigationThread. Assigns important attributes and
* sets the Thread to Daemon to let the JVM exit if this should be the only thread running.
@@ -52,6 +51,7 @@ public NavigationThread(Navigator navi_init, ApplicationHandler app_init, float
/**
* Sets the running boolean and eventually updates the finalMove boolean
+ *
* @param runSet: The value the running boolean will be set to
*/
public void setRunning(boolean runSet) {
@@ -59,29 +59,28 @@ public void setRunning(boolean runSet) {
if (!runSet) {
finalMove = false;
}
-
}
- @Override
/**
* This method is responsible for the navigation of the NXT.
* Once the Thread is started, a corresponding message is printed.
* The Thread is running as long as its boolean running equals true,
* the target has not been reached and the NXT is balancing.
- *
+ *
* Every time the idle timer equals 0, the method calculates the next destination.
* For this, a method of the {@link Navigator} is called and the destination is saved.
* The method catches cases in which the target cannot be reached.
* After the calculation, another method is called to handle the new destination
* and the idle timer is set to its maximum value.
- *
+ *
* The method proceeds to handle blocked positions and reached calculated targets
* by setting the idle timer to 0 and stopping the movement.
* Updates the idle timer and sleeps for 100 ms.
- *
+ *
* Finally stops the movement and, if the thread was not stopped by an external
- * command, send a moveTo-command to the NXT to correct inaccuracies.
+ * command, send a moveTo-command to the NXT to correct inaccuracies.
*/
+ @Override
public void run() {
System.out.println("NaviThread started with " + xTarget + ", " + yTarget);
while (navi.getNXTData().getBalancing() && running && !navi.reachedPosition(xTarget, yTarget)) {
@@ -103,7 +102,7 @@ public void run() {
handleNewTarget((float)nextMove.getX(), (float)nextMove.getY());
idle = STANDARD_IDLE_TIME;
}
-
+
// Collision detection: instantly stop the movement and wait for recalculation
if (navi.isBlocked()) {
idle = 0;
diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/Navigator.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/Navigator.java
index 6b2ea49..2558ffc 100644
--- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/Navigator.java
+++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/Navigator.java
@@ -5,7 +5,6 @@
import java.awt.Shape;
import java.awt.geom.Arc2D;
import java.awt.geom.Area;
-
import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.data.MapData;
import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.data.NXTData;
import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.nav.aStarAlg.AStar;
@@ -70,6 +69,7 @@ public static int discrete(double param) {
/**
* This method calculates a discrete square in which the given coordinates are located
+ *
* @param x: the x-coordinate to be discretized
* @param y: the y-coordinate to be discretized
* @return a Point with discretized coordinates fitting to the given values.
@@ -166,7 +166,7 @@ public Point getNextPoint(float xTarget, float yTarget) {
}
/**
- * Checks if facing an obstacle in a 15 cm, 90° cone.
+ * Checks if facing an obstacle in a 15 cm, 90� cone.
* Ignores obstacles nearer than 7.5cm.
*
* @return true, if an obstacle is marked within the area
diff --git a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/aStarAlg/AStar.java b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/aStarAlg/AStar.java
index fe5dc2d..b60e56e 100644
--- a/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/aStarAlg/AStar.java
+++ b/PC/src/de/rwthaachen/nxtpraktikum/gruppe2_2017/pc/nav/aStarAlg/AStar.java
@@ -1,20 +1,16 @@
package de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.nav.aStarAlg;
import static de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.nav.Navigator.MAP_SQUARE_LENGTH;
-
import java.awt.Point;
import java.awt.geom.Ellipse2D;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Set;
-
import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.data.MapData;
import de.rwthaachen.nxtpraktikum.gruppe2_2017.pc.data.NXTData;
/**
- *
* @author Fabian & Robin
- *
*/
public class AStar
{
@@ -30,6 +26,7 @@ public AStar(MapData map, NXTData data) {
/**
* This algorithm returns a chain of points, which represents the shortest path from position to destination.
+ *
* @param position Starting position
* @param destination Destination position
* @param maxPathLength maxPathLength aborts if path becomes longer than this
@@ -94,6 +91,7 @@ private void expandNode(PointNode current, Point destination, PriorityQueue