Update docs, rollback accidental version increment
ErrorLogging now has consistent indentation MovementFacade needs to be rolled back
This commit is contained in:
parent
b2b05c50df
commit
7708d1359a
7 changed files with 87 additions and 122 deletions
|
@ -22,7 +22,7 @@ This is a personal/professional project, which makes use of JavaCV, OpenCV, Tess
|
|||
|
||||
## Known Bugs
|
||||
|
||||
- As of v4.1.0, cropping images is done by a temporary window created by OpenCV. This window will crash after being used correctly. This can be safely killed when prompted, without affecting the rest of the project. Investigation into how to fix this crashing is ongoing, but it has not yet been resolved.
|
||||
- As of v4.1.0, cropping images is done by a temporary window created by OpenCV. This window does not close itself, but is re-used if a new cropping region is requested. This can be safely killed when prompted, without affecting the rest of the project.
|
||||
|
||||
## Dependencies
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<groupId>org.baxter.disco</groupId>
|
||||
<artifactId>ocr</artifactId>
|
||||
<name>Disco OCR Accuracy Over Life Testing</name>
|
||||
<version>4.3.6</version>
|
||||
<version>4.3.5</version>
|
||||
<description>Testing Discos for long-term accuracy, using automated optical character recognition.</description>
|
||||
<organization>
|
||||
<name>Baxter International</name>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baxter.disco</groupId>
|
||||
<artifactId>ocr</artifactId>
|
||||
<version>4.3.6</version>
|
||||
<version>4.3.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Disco OCR Accuracy Over Life Testing</name>
|
||||
<description>Testing Discos for long-term accuracy, using automated optical character recognition.</description>
|
||||
|
|
|
@ -25,7 +25,7 @@ public class Cli
|
|||
/**
|
||||
* Complete build version number
|
||||
*/
|
||||
private static final String version = "4.3.6";
|
||||
private static final String version = "4.3.5";
|
||||
|
||||
/**
|
||||
* Currently saved iteration count.
|
||||
|
@ -81,14 +81,40 @@ public class Cli
|
|||
ErrorLogging.logError("Version: " + version);
|
||||
ErrorLogging.logError("========================");
|
||||
try{
|
||||
//inputScanner = new Scanner(System.in);
|
||||
inputScanner = new Scanner(System.in);
|
||||
|
||||
//ConfigFacade.init();
|
||||
|
||||
//int userInput = 0;
|
||||
int userInput = 0;
|
||||
|
||||
ErrorLogging.logError("Initialising fixture movement. This will take a few moments, and may produce some temporary unnerving sounds from the motor. This is expected behaviour, and no damage is being done.");
|
||||
MovementFacade.calibrate();
|
||||
MovementFacade.resetArm();
|
||||
MovementFacade.goDown();
|
||||
MovementFacade.goUp();
|
||||
|
||||
prompt("Did the motor move successfully? (Y/n): ");
|
||||
String successfulMovement = inputScanner.next().trim().toLowerCase();
|
||||
ErrorLogging.logError("DEBUG: user report of motor movement = " + successfulMovement);
|
||||
if(successfulMovement == "" || successfulMovement.charAt(0) != 'y')
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: User reported failed movement of the motor! Allowing reset of frequency...");
|
||||
print("As the default frequency did not work successfully, a new frequency value is required.");
|
||||
print("Higher frequency: Faster motor movement, not guaranteed to work, may cause damage to motor.");
|
||||
print(" Lower frequency: Slower motor movement, safer, but longer iteration time.");
|
||||
boolean frequencyReset = false;
|
||||
while(true)
|
||||
{
|
||||
prompt("Please enter a new frequency value (Default: 50kHz): ");
|
||||
userInput = (int)inputFiltering(inputScanner.next());
|
||||
frequencyReset = MovementFacade.setFrequency(userInput);
|
||||
if(!frequencyReset) continue;
|
||||
MovementFacade.resetArm();
|
||||
MovementFacade.goDown();
|
||||
MovementFacade.goUp();
|
||||
prompt("Did the motor move successfully? (Y/n): ");
|
||||
successfulMovement = inputScanner.next();
|
||||
if(successfulMovement != "" || successfulMovement.toLowerCase().charAt(0) != 'n') break;
|
||||
}
|
||||
}
|
||||
|
||||
//do
|
||||
//{
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
|
|||
* as well as stderr.
|
||||
*
|
||||
* @author Blizzard Finnegan
|
||||
* @version 1.3.1, 09 Feb. 2023
|
||||
* @version 1.3.2, 07 Mar. 2023
|
||||
*/
|
||||
|
||||
public class ErrorLogging
|
||||
|
@ -109,7 +109,7 @@ public class ErrorLogging
|
|||
*/
|
||||
public static void logError(String error)
|
||||
{
|
||||
String errorMessage = datetime.format(LocalDateTime.now()) + " - " + error;
|
||||
String errorMessage = datetime.format(LocalDateTime.now()) + "\t- " + error;
|
||||
fileOut.println(errorMessage);
|
||||
fileOut.flush();
|
||||
if(!error.substring(0,5).equals("DEBUG"))
|
||||
|
|
|
@ -46,23 +46,18 @@ public class MovementFacade
|
|||
*
|
||||
* Frequency (Hz) = Speed (cm/s) * (pulses/rev) * (lead)
|
||||
*/
|
||||
private static final int PWM_FREQ_CONVERT = 19200;
|
||||
private static final double PWM_FREQ_CONVERT = 19200;
|
||||
|
||||
/**
|
||||
* Max allowed speed by current fixture design.
|
||||
* Motor appears to start acting erratically over 192kHz.
|
||||
*/
|
||||
private static final int MAX_FREQUENCY = 192000;
|
||||
|
||||
/**
|
||||
* Amount of buffer between the found absolute speed, and used speed.
|
||||
*/
|
||||
private static final int SPEED_BUFFER = 4000;
|
||||
private static final double MAX_FREQUENCY = 192000;
|
||||
|
||||
/**
|
||||
* Minimum allowed speed of the fixture arm; also used for reset travels.
|
||||
*/
|
||||
private static final int MIN_FREQUENCY = 10000;
|
||||
private static final double MIN_FREQUENCY = 20000;
|
||||
|
||||
/**
|
||||
* Distance in cm the fixture needs to travel.
|
||||
|
@ -70,22 +65,22 @@ public class MovementFacade
|
|||
* Distance between limit switches: ~80cm.
|
||||
* Thickness of fixture arm: ~50cm.
|
||||
*/
|
||||
private static final int TRAVEL_DIST = 30;
|
||||
private static final int TRAVEL_DIST = 10;
|
||||
|
||||
/**
|
||||
* What percentage of the travel to slow down the motor.
|
||||
*/
|
||||
private static final double STEP_1 = 2/3;
|
||||
private static final double STEP_1 = 1.0 / 2.0;
|
||||
|
||||
/**
|
||||
* What percentage of the travel to slow down the motor farther.
|
||||
*/
|
||||
private static final double STEP_2 = 5/6;
|
||||
private static final double STEP_2 = 3.0 / 4.0;
|
||||
|
||||
/**
|
||||
* Frequency fed to the PWM pin, which the motor controller converts into movement speed.
|
||||
* Default frequency fed to the PWM pin, which the motor controller converts into movement speed.
|
||||
*/
|
||||
private static int FREQUENCY = MIN_FREQUENCY;
|
||||
private static int FREQUENCY = 70000;
|
||||
|
||||
/**
|
||||
* PWM Duty Cycle.
|
||||
|
@ -348,7 +343,7 @@ public class MovementFacade
|
|||
{
|
||||
int counter = 0;
|
||||
ErrorLogging.logError("DEBUG: Setting minimum frequency of PWM...");
|
||||
pwm.on(DUTY_CYCLE, MIN_FREQUENCY);
|
||||
pwm.on(DUTY_CYCLE, (int)MIN_FREQUENCY);
|
||||
if(upperLimit.isHigh())
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Motor at highest point! Lowering to reset.");
|
||||
|
@ -378,92 +373,18 @@ public class MovementFacade
|
|||
return counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the motor's max speed.
|
||||
*/
|
||||
public static void calibrate()
|
||||
{
|
||||
ErrorLogging.logError("Initial Calibration reset.");
|
||||
resetArm();
|
||||
ErrorLogging.logError("Coarse calibrating...");
|
||||
FREQUENCY = calib(MIN_FREQUENCY, MAX_FREQUENCY, 10000);
|
||||
ErrorLogging.logError("Fine calibrating...");
|
||||
FREQUENCY = calib(FREQUENCY,(FREQUENCY+10000),1000);
|
||||
ErrorLogging.logError("Calibration complete!");
|
||||
ErrorLogging.logError("DEBUG: Speed set to " + (FREQUENCY - SPEED_BUFFER));
|
||||
setSpeed(FREQUENCY - SPEED_BUFFER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the max speed of the fixure between two points.
|
||||
*
|
||||
* @param start Lowest speed to check
|
||||
* @param max Highest speed to check
|
||||
* @param iterate How much to iterate by
|
||||
*
|
||||
* @return The largest safe value between start and max.
|
||||
*/
|
||||
private static int calib(int start, int max, int iterate)
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Calibrating. Iterating from " + start + " to " + max + " in " + iterate + " steps.");
|
||||
//start -= iterate;
|
||||
for(int i = start; i < max; i+=iterate)
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Testing speed " + i + "...");
|
||||
if(!setSpeed(i))
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Speed set unsuccessfully! returning " + MIN_FREQUENCY + "...");
|
||||
return MIN_FREQUENCY;
|
||||
}
|
||||
ErrorLogging.logError("DEBUG: Motor travelling down.");
|
||||
motorDirection.low();
|
||||
//ErrorLogging.logError("DEBUG: Motor Frequency: " + FREQUENCY);
|
||||
//pwm.on(DUTY_CYCLE,FREQUENCY);
|
||||
ErrorLogging.logError("DEBUG: Motor calibrate on.");
|
||||
motorEnable.on();
|
||||
for(int j = 0; j < 20; j++)
|
||||
{
|
||||
try{ Thread.sleep(100); }
|
||||
catch (Exception e){ ErrorLogging.logError(e); }
|
||||
if(lowerLimit.isHigh())
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Breaking loop early!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
motorEnable.off();
|
||||
ErrorLogging.logError("DEBUG: Motor calibrate off.");
|
||||
if(upperLimit.isHigh())
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Upper limit is high = " + upperLimit.isHigh());
|
||||
ErrorLogging.logError("DEBUG: Motor failed to move! Returning " + (i - iterate));
|
||||
return i-iterate;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ErrorLogging.logError("DEBUG: Motor moved at speed " + i + ". Checking for errors.");
|
||||
if(resetArm() < 10 && i > 3.0)
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Motor failed to move! Returning " + (i - iterate));
|
||||
return i - iterate;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max-iterate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely set the speed of the motor and fixture.
|
||||
*
|
||||
* @return true if set successfully, else false
|
||||
*/
|
||||
private static boolean setSpeed(int newFrequency)
|
||||
public static boolean setFrequency(int newFrequency)
|
||||
{
|
||||
boolean output;
|
||||
if(newFrequency < MIN_FREQUENCY || newFrequency > MAX_FREQUENCY)
|
||||
{
|
||||
FREQUENCY = MIN_FREQUENCY;
|
||||
ErrorLogging.logError("Movement control error!!! - Invalid frequency input.");
|
||||
FREQUENCY = (int)MIN_FREQUENCY;
|
||||
output = false;
|
||||
}
|
||||
else
|
||||
|
@ -493,13 +414,13 @@ public class MovementFacade
|
|||
{
|
||||
motorDirection.high();
|
||||
limitSense = upperLimit;
|
||||
ErrorLogging.logError("Sending fixture up...");
|
||||
ErrorLogging.logError("DEBUG: Sending fixture up...");
|
||||
}
|
||||
else
|
||||
{
|
||||
motorDirection.low();
|
||||
limitSense = lowerLimit;
|
||||
ErrorLogging.logError("Sending fixture down...");
|
||||
ErrorLogging.logError("DEBUG: Sending fixture down...");
|
||||
}
|
||||
|
||||
if(limitSense.isHigh()) return FinalState.SAFE;
|
||||
|
@ -510,35 +431,57 @@ public class MovementFacade
|
|||
int VEL_STEP_1 = (int)(STEP_1 * POLL_COUNT);
|
||||
int VEL_STEP_2 = (int)(STEP_2 * POLL_COUNT);
|
||||
|
||||
ErrorLogging.logError("DEBUG: ========================================");
|
||||
ErrorLogging.logError("DEBUG: Total Poll count: " + POLL_COUNT);
|
||||
ErrorLogging.logError("DEBUG: Transition 1: " + VEL_STEP_1);
|
||||
ErrorLogging.logError("DEBUG: Transition 2: " + VEL_STEP_2);
|
||||
ErrorLogging.logError("DEBUG: Travel time: " + TRAVEL_TIME);
|
||||
ErrorLogging.logError("DEBUG: Travel speed: " + (FREQUENCY/PWM_FREQ_CONVERT));
|
||||
ErrorLogging.logError("DEBUG: STEP_1: " + STEP_1);
|
||||
ErrorLogging.logError("DEBUG: STEP_2: " + STEP_2);
|
||||
ErrorLogging.logError("DEBUG: ========================================");
|
||||
|
||||
ErrorLogging.logError("DEBUG: Motor on.");
|
||||
motorEnable.on();
|
||||
boolean slow = false;
|
||||
boolean slower = false;
|
||||
for(int i = 0; i < (POLL_COUNT);i++)
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Iteration " + i);
|
||||
try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); }
|
||||
if(limitSense.isOn())
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Exiting early due to limit switch activation!");
|
||||
ErrorLogging.logError("DEBUG: Exiting on poll " + i);
|
||||
break;
|
||||
}
|
||||
if(i >= VEL_STEP_1 && i < VEL_STEP_2)
|
||||
{
|
||||
output = FinalState.UNSAFE;
|
||||
if(slow)
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Slowing down.");
|
||||
pwm.on(DUTY_CYCLE, FREQUENCY / 2);
|
||||
slow = true;
|
||||
}
|
||||
pwm.on(DUTY_CYCLE, (int)(FREQUENCY / 1.25));
|
||||
}
|
||||
else if(i >= VEL_STEP_2)
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Slowing down more.");
|
||||
pwm.on(DUTY_CYCLE, FREQUENCY / 4);
|
||||
output = FinalState.SAFE;
|
||||
if(slower)
|
||||
{
|
||||
ErrorLogging.logError("DEBUG: Slowing down more.");
|
||||
slower = true;
|
||||
}
|
||||
pwm.on(DUTY_CYCLE, FREQUENCY / 2);
|
||||
}
|
||||
}
|
||||
motorEnable.off();
|
||||
ErrorLogging.logError("DEBUG: Motor off.");
|
||||
|
||||
if(output == FinalState.FAILED)
|
||||
ErrorLogging.logError("FIXTURE MOVEMENT ERROR! - Motor movement timed out!");
|
||||
ErrorLogging.logError("DEBUG: Motor movement exited early.");
|
||||
else if(output == FinalState.UNSAFE)
|
||||
ErrorLogging.logError("DEBUG: Motor movement slowed down, but not fully.");
|
||||
else if(output == FinalState.SAFE)
|
||||
ErrorLogging.logError("DEBUG: Motor movement successfully slowed fully.");
|
||||
pwm.on(DUTY_CYCLE, FREQUENCY);
|
||||
return output;
|
||||
}
|
||||
|
|
18
toDoList.md
18
toDoList.md
|
@ -2,18 +2,15 @@
|
|||
|
||||
## High-priority fixes
|
||||
|
||||
## Cli(?)
|
||||
### DataSaving
|
||||
|
||||
- [x] enable camera toggling
|
||||
- [ ] Modify initialisation to create formula cells outside data lines
|
||||
- Will need to evaluate functions on every line write
|
||||
|
||||
### OpenCVFacade
|
||||
|
||||
- [ ] completeProcess should have more robust file output checking
|
||||
|
||||
### Gui
|
||||
|
||||
- [ ] Debug and ensure GUI is written properly
|
||||
|
||||
## Low-priority improvements
|
||||
|
||||
### All
|
||||
|
@ -22,13 +19,12 @@
|
|||
- [ ] reduce Javadoc linking to one link per reference per class
|
||||
- [ ] Use generated Javadocs to improve Javadocs (perpetual)
|
||||
|
||||
### Cli
|
||||
### Gui
|
||||
|
||||
- [ ] Find way to kill CanvasFrame protection Thread on exit
|
||||
- [ ] Debug and ensure GUI is written properly
|
||||
|
||||
### TesseractFacade
|
||||
|
||||
- [ ] parse text-based input?
|
||||
- requires further communication with Pete to determine if necessary.
|
||||
- requires retraining Tesseract
|
||||
- [x] parse text-based input?
|
||||
- Determined to be unnecessary, as further data filtering is all that is required.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue