Skip to content

Commit

Permalink
connect the mobile base before generating cad
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Mar 29, 2022
1 parent 7d0f61e commit b17a9f0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
31 changes: 17 additions & 14 deletions src/main/java/com/neuronrobotics/bowlerstudio/BowlerKernel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.neuronrobotics.sdk.addons.kinematics.MobileBase;

import eu.mihosoft.vrl.v3d.CSG;
import eu.mihosoft.vrl.v3d.ICSGProgress;
import eu.mihosoft.vrl.v3d.JavaFXInitializer;
import marytts.signalproc.effects.LpcWhisperiserEffect;
import marytts.signalproc.effects.RobotiserEffect;
Expand All @@ -41,7 +42,7 @@

public class BowlerKernel {

private static final String CSG = null;
//private static final String CSG = null;
private static File historyFile = new File(ScriptingEngine.getWorkspace().getAbsolutePath() + "/bowler.history");

static {
Expand Down Expand Up @@ -298,6 +299,15 @@ public void run() {

}
private static void processReturnedObjects(Object ret) {
CSG.setProgressMoniter(new ICSGProgress() {
@Override
public void progressUpdate(int currentIndex, int finalIndex, String type,
eu.mihosoft.vrl.v3d.CSG intermediateShape) {

}

});

ArrayList<CSG> csgBits = new ArrayList<>();
processReturnedObjects(ret,csgBits);
try {
Expand All @@ -318,20 +328,13 @@ private static void processReturnedObjects(Object ret, ArrayList<CSG> csgBits) {
csgBits.add((CSG)ret);
}
if(MobileBase.class.isInstance(ret)) {
MobileBaseCadManager m=MobileBaseCadManager.get((MobileBase)ret);

MobileBase ret2 = (MobileBase)ret;
ret2.connect();
MobileBaseCadManager m=MobileBaseCadManager.get(ret2);
m.setConfigurationViewerMode(false);
m.generateCad();
while(m.getProcesIndictor().get()<1) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Building cad "+(m.getProcesIndictor().get()*100)+"%");

}
processReturnedObjects(m.getAllCad(),csgBits);
ArrayList<CSG> generateBody = m.generateBody();
processReturnedObjects(generateBody,csgBits);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,12 @@ private static File resetConfigurationScript()
cadEngineConfiguration = (ICadGenerator) ScriptingEngine.inlineFileScriptRun(confFile, null);
return confFile;
}

public ArrayList<CSG> generateBody() {
return generateBody(getMobileBase());
}
public ArrayList<CSG> generateBody(MobileBase base) {
if(base.isAvailable())
throw new RuntimeException("Device "+base.getScriptingName()+" is not connected, can not generate cad");

getProcesIndictor().set(0);
setAllCad(new ArrayList<>());
Expand Down Expand Up @@ -830,15 +834,21 @@ public void run() {
} catch (Exception e) {
getUi().highlightException(getCadScript(), e);
}
// System.out.print("\r\nDone Generating CAD!\r\n");

if (master != null) {
for (int i = 0; i < allCad.size(); i++)
master.allCad.add(allCad.get(i));
getUi().setCsg(master, getCadScript());
} else
getUi().setCsg(MobileBaseCadManager.get(base), getCadScript());
cadGenerating = false;
System.out.print("\r\nDone Generating CAD!\r\n");
System.out.print("\r\nDone Generating CAD! num parts: "+allCad.size()+"\r\n");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
getProcesIndictor().set(1);
// System.gc();
}
Expand Down

0 comments on commit b17a9f0

Please sign in to comment.