Update movement algorithm

Movement algorithm now has an upper and lower bound, and warns user if
outside that bound.
Also, modified error logging to not post timestamp to user, for easier
readability.
Finally, muted extraneous logging messages from user.
This commit is contained in:
Blizzard Finnegan 2023-03-16 09:43:09 -04:00
parent e326eee89a
commit 97bcb77e6c
No known key found for this signature in database
GPG key ID: DE547EDF547DDA49
7 changed files with 24 additions and 50 deletions

View file

@ -1,34 +0,0 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Maven Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}

View file

@ -35,6 +35,8 @@ To further develop this software, or to compile it from source, the following is
- A Java-compatible IDE
- Maven
- OpenJDK11
- .NET 6.0
- (Optional, for complete dependency checking)
OpenJDK11 is explicitly required, as it is the only currently available Java development platform compatible with [Pi4J](https://pi4j.com/getting-started/). According to the [documentation for Pi4J](https://pi4j.com/getting-started/developing-on-a-remote-pc/), development on a Raspberry Pi is possible, but given this project's build time (as of 4.0.0-rc3, 2-5 minutes on a Baxter-distributed device, before documentation generation), it is recommended to build on x86-64, and copy to the compiled JAR to the Pi. As such, this repository has been designed with this development model in mind. If you are intending on compiling on a Pi, please see the above-linked documentation to see what should be modified in your local `pom.xml` file.

View file

@ -18,7 +18,7 @@ import java.util.concurrent.locks.ReentrantLock;
* classes).
*
* @author Blizzard Finnegan
* @version 1.7.1, 10 Mar. 2023
* @version 1.8.0, 16 Mar. 2023
*/
public class Cli
{
@ -104,7 +104,9 @@ public class Cli
catch(Exception e)
{
ErrorLogging.logError(e);
ErrorLogging.logError("GPIO initialisation error! Please check GPIO connections.");
ErrorLogging.logError("GPIO initialisation error! Please check GPIO connections,");
ErrorLogging.logError("and ensure that the PWM is set fast enough to the lower limit switch");
ErrorLogging.logError("in less than 3 seconds.");
println("");
prompt("Press enter to try again.");
String userInputString = inputScanner.nextLine();

View file

@ -233,7 +233,7 @@ public class DataSaving
*/
public static boolean writeValues(int cycle, Map<File,Double> inputMap, Map<String,File> cameraToFile)
{
ErrorLogging.logError("Writing values for " + cycle + " cycle to worksheet.");
ErrorLogging.logError("DEBUG: Writing values for " + (cycle + 1) + " cycle to worksheet.");
boolean output = false;
int cellnum = 0;
int startingRow = outputSheet.getLastRowNum();

View file

@ -18,7 +18,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
* as well as stderr.
*
* @author Blizzard Finnegan
* @version 1.3.2, 07 Mar. 2023
* @version 1.4.0, 07 Mar. 2023
*/
public class ErrorLogging
@ -105,8 +105,9 @@ public class ErrorLogging
String errorMessage = datetime.format(LocalDateTime.now()) + "\t- " + error;
fileOut.println(errorMessage);
fileOut.flush();
if(!error.substring(0,5).equals("DEBUG"))
System.out.println(errorMessage);
if(error.length() < 5) System.out.println(error);
else if(!error.substring(0,5).equals("DEBUG"))
System.out.println(error);
}
/**

View file

@ -17,7 +17,7 @@ import com.pi4j.io.gpio.digital.PullResistance;
* Currently missing Run switch compatibility.
*
* @author Blizzard Finnegan
* @version 3.0.1, 10 Mar. 2023
* @version 3.1.0, 16 Mar. 2023
*/
public class MovementFacade
{
@ -51,10 +51,9 @@ public class MovementFacade
/**
* How many polls before assuming bad GPIO connection.
* Fixture movement takes approximately 2.5s, or 250 polls.
* Double this to account for errors, or slower fixtures.
* The DUTs fall asleep after ~6 seconds,so the travel must be less than 3 seconds.
*/
private static final int TIMEOUT = 500;
private static final int TIMEOUT = 300;
//PWM Addresses
@ -285,7 +284,7 @@ public class MovementFacade
}
else
{
ErrorLogging.logError("DEBUG: No motor return after 30 seconds.");
ErrorLogging.logError("DEBUG: No motor return after 3 seconds.");
ErrorLogging.logError("DEBUG: --------------------------------------");
return -1;
}
@ -314,7 +313,7 @@ public class MovementFacade
}
motorOff();
if(lowerLimit.isOff()) ErrorLogging.logError("DEBUG: False positive on findDistance down!");
if(downTravelCounter == TIMEOUT) throw new Exception("Failed GPIO initialisation!");
if(downTravelCounter == TIMEOUT) throw new Exception("PWM set too slow!");
ErrorLogging.logError("DEBUG: Down travel count: " + downTravelCounter);
@ -379,8 +378,12 @@ public class MovementFacade
try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); }
if(limitSense.isOn())
{
motorOff();
break;
try{ Thread.sleep(5); } catch(Exception e){ErrorLogging.logError(e); }
if(limitSense.isOn())
{
motorOff();
break;
}
}
}
motorOff();

View file

@ -402,8 +402,8 @@ public class OpenCVFacade
List<Mat> processedImageList = new ArrayList<>();
Mat finalImage = null;
if(crop) ErrorLogging.logError("Cropping is enabled.");
if(threshold) ErrorLogging.logError("Thresholding is enabled.");
if(crop) ErrorLogging.logError("DEBUG: Cropping is enabled.");
if(threshold) ErrorLogging.logError("DEBUG: Thresholding is enabled.");
for(Mat image : imageList)
{
Mat processedImage = image.clone();