Skip to content

Commit

Permalink
ensure the runlaters have exception handeling
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed May 6, 2024
1 parent c9ce24a commit b4f1973
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.neuronrobotics.bowlerkernel.Bezier3d;

import com.neuronrobotics.bowlerstudio.BowlerKernel;
//import com.neuronrobotics.bowlerstudio.BowlerStudio
import com.neuronrobotics.bowlerstudio.physics.TransformFactory;
import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR;
Expand Down Expand Up @@ -192,7 +193,7 @@ public void update() {
for (int i = 0; i < getNumParts(); i++) {
TransformNR nr = TransformFactory.csgToNR(transforms.get(i));
Affine partsGetGetManipulator = getPartsInternal().get(i).getManipulator();
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
TransformFactory.nrToAffine(nr, partsGetGetManipulator);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.neuronrobotics.bowlerstudio.BowlerKernel;
import com.neuronrobotics.bowlerstudio.opencv.OpenCVManager;
import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine;
import com.neuronrobotics.sdk.common.DeviceManager;
Expand Down Expand Up @@ -148,7 +149,7 @@ public String save() {
}
if (workingMemory != null)
for (UniquePerson up : shortTermMemory) {
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
getUI(up).name.setText(up.name);
});
}
Expand Down Expand Up @@ -304,7 +305,7 @@ private void processBlocking() {
if (workingMemory != null) {
UniquePersonUI UI = getUI(p);
uiElelments.remove(p);
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
workingMemory.getChildren().remove(UI.box);
});
}
Expand Down Expand Up @@ -377,7 +378,7 @@ private boolean processMemory(HashMap<UniquePerson, org.opencv.core.Point> tmpPe
UI.box.getChildren().addAll(new ImageView(tmpImg));

UI.name.setOnAction(setAction(p));
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
workingMemory.getChildren().add(UI.box);
});
}
Expand All @@ -389,7 +390,7 @@ private boolean processMemory(HashMap<UniquePerson, org.opencv.core.Point> tmpPe
double perc = percent;
// println "Trained "+percent;
if (workingMemory != null)
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
UI.percent.setText(" : Trained " + perc + "%");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void runLater(Runnable r) {
}

public static void runLater(Runnable r, Throwable ex) {
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
try {
r.run();
} catch (Throwable t) {
Expand Down Expand Up @@ -146,7 +146,7 @@ public void except(Throwable e, String stacktraceFromCatch) {
runReport(element, body, github);
return;
}
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("An Error occoured");
alert.setHeaderText("Would it be ok if I report this issue back to Kevin so he can fix it?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public void run() {
TransformNR[] vals = tmp.values().stream().toArray(size->new TransformNR[size]);
tmp.clear();
if (iterator.length > 0) {
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
try {
for (int i = 0; i < iterator.length; i++) {
Affine af = iterator[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.bulletphysics.dynamics.RigidBody;
import com.bulletphysics.dynamics.constraintsolver.HingeConstraint;
import com.bulletphysics.linearmath.Transform;
import com.neuronrobotics.bowlerstudio.BowlerKernel;
import com.neuronrobotics.bowlerstudio.creature.MobileBaseCadManager;
import com.neuronrobotics.sdk.addons.kinematics.AbstractLink;
import com.neuronrobotics.sdk.addons.kinematics.DHLink;
Expand Down Expand Up @@ -122,7 +123,7 @@ public MobileBasePhysicsManager(MobileBase base, ArrayList<CSG> baseCad,

TransformFactory.nrToBullet(base.getFiducialToGlobalTransform(), start);
start.origin.z = (float) (start.origin.z - minz + lift);
Platform.runLater(new Runnable() {
BowlerKernel.runLater(new Runnable() {
@Override
public void run() {
TransformFactory.bulletToAffine(baseCad.get(0).getManipulator(), start);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.bulletphysics.dynamics.constraintsolver.SequentialImpulseConstraintSolver;
import com.bulletphysics.linearmath.DefaultMotionState;
import com.bulletphysics.linearmath.Transform;
import com.neuronrobotics.bowlerstudio.BowlerKernel;
import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler;
import com.neuronrobotics.sdk.util.ThreadUtil;

Expand Down Expand Up @@ -206,7 +207,7 @@ public void step(float timeStep) {
o.update(timeStep);
}

Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
for (IPhysicsManager o : getPhysicsObjects()) {
try {
TransformFactory.bulletToAffine(o.getRigidBodyLocation(), o.getUpdateTransform());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.neuronrobotics.sdk.addons.gamepad;


import com.neuronrobotics.bowlerstudio.BowlerKernel;

/**
* Sample Skeleton for "jogTrainerWidget.fxml" Controller Class
* You can copy and paste this code into your favorite IDE
Expand Down Expand Up @@ -117,7 +119,7 @@ public void handle(ActionEvent event) {
grid.add(reset, 1, i);
reset();
if(PersistantControllerMap.areAllAxisMapped(gameController.getName())) {
Platform.runLater(() ->fields.get(0).setDisable(true));
BowlerKernel.runLater(() ->fields.get(0).setDisable(true));
gameController.removeListeners(this);
}else {
gameController.addListeners(this);
Expand Down Expand Up @@ -148,7 +150,7 @@ public void start(Stage primaryStage) throws Exception {
tmp=12;
root.setStyle("-fx-font-size: "+tmp+"pt");
});
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
primaryStage.setTitle("Configure the controller");

Scene scene = new Scene(root);
Expand All @@ -164,9 +166,9 @@ public void start(Stage primaryStage) throws Exception {
public void reset() {
listOfMappedAxis.clear();
mappingIndex=0;
Platform.runLater(() ->fields.get(mappingIndex).setDisable(false));
BowlerKernel.runLater(() ->fields.get(mappingIndex).setDisable(false));
gameController.addListeners(this);
Platform.runLater(() ->controllername.setText(gameController.getName()));
BowlerKernel.runLater(() ->controllername.setText(gameController.getName()));
save.setDisable(true);
}

Expand Down Expand Up @@ -211,7 +213,7 @@ public void onEvent(String name, float value) {
System.out.println("Adding Axis "+name);
listOfMappedAxis.add(name);
timeOfLastAxisSet=System.currentTimeMillis();
Platform.runLater(() -> {
BowlerKernel.runLater(() -> {
TextField textField = fields.get(mappingIndex);
textField.setText(name);

Expand All @@ -228,7 +230,7 @@ public void onEvent(String name, float value) {

public static void run(BowlerJInputDevice c) {
//System.out.println("Launching Controller mapping");
Platform.runLater(new Runnable() {
BowlerKernel.runLater(new Runnable() {
@Override
public void run() {
//System.out.println("Creating stage");
Expand Down

0 comments on commit b4f1973

Please sign in to comment.