Skip to content

Commit 6e79bfe

Browse files
Merge pull request #61 from CommonWealthRobotics/kh/robot-lab
Update Robot Lab
2 parents 9365ac5 + d66e842 commit 6e79bfe

32 files changed

+680
-517
lines changed

src/main/java/com/neuronrobotics/bowlerkernel/Bezier3d/BezierEditor.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,17 @@ public void update() {
192192
ArrayList<Transform> transforms = transforms();
193193
for (int i = 0; i < getNumParts(); i++) {
194194
TransformNR nr = TransformFactory.csgToNR(transforms.get(i));
195-
Affine partsGetGetManipulator = getPartsInternal().get(i).getManipulator();
196-
BowlerKernel.runLater(() -> {
197-
TransformFactory.nrToAffine(nr, partsGetGetManipulator);
198-
});
195+
Affine partsGetGetManipulator;
196+
try {
197+
partsGetGetManipulator = getPartsInternal().get(i).getManipulator();
198+
BowlerKernel.runLater(() -> {
199+
TransformFactory.nrToAffine(nr, partsGetGetManipulator);
200+
});
201+
} catch (MissingManipulatorException e) {
202+
// TODO Auto-generated catch block
203+
e.printStackTrace();
204+
}
205+
199206
}
200207

201208
updateLines(start, cp1Manip, cp1Line, cp1LinePose);

src/main/java/com/neuronrobotics/bowlerstudio/creature/LimbOption.java

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import eu.mihosoft.vrl.v3d.CSG;
4040
import eu.mihosoft.vrl.v3d.FileUtil;
41+
import eu.mihosoft.vrl.v3d.MissingManipulatorException;
4142
import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase;
4243
import eu.mihosoft.vrl.v3d.parametrics.CSGDatabaseInstance;
4344
import javafx.embed.swing.SwingFXUtils;
@@ -65,13 +66,14 @@ public class LimbOption {
6566
private Image image;
6667

6768
public DHParameterKinematics getLimb(CSGDatabaseInstance db,String uniqueName) throws Exception {
68-
String xmlContent = ScriptingEngine.codeFromGit(url, file)[0];
69+
String xmlContent = ScriptingEngine.codeFromGit(getUrl(), getSourceFile())[0];
6970
if (!composite) {
7071
DHParameterKinematics newLimb = new DHParameterKinematics(null, IOUtils.toInputStream(xmlContent, "UTF-8"));
7172
newLimb.setScriptingName(uniqueName);
73+
MobileBaseLoader.setDefaultDhParameterKinematics(db, newLimb);
7274
return newLimb;
7375
} else {
74-
MobileBase base = RobotHelper.fileToRobot(db,url, file);
76+
MobileBase base = RobotHelper.fileToRobot(db,getUrl(), getSourceFile());
7577
DHParameterKinematics newLimb = base.getAllDHChains().get(0);
7678
newLimb.setScriptingName(uniqueName);
7779
return newLimb;
@@ -96,7 +98,7 @@ public static ArrayList<LimbOption> getOptions()
9698

9799
@Override
98100
public String toString() {
99-
return getType() + " " + getName() + " " + url + "/" + file + "\n\tConsumes:" + getConsumes() + "\n\tProvides:" + getProvides();
101+
return getType() + " " + getName() + " " + getUrl() + "/" + getSourceFile() + "\n\tConsumes:" + getConsumes() + "\n\tProvides:" + getProvides();
100102
}
101103

102104
public ControllerFeatures getConsumes() {
@@ -145,26 +147,30 @@ public void build(CaDoodleFile f) throws IOException {
145147
f.getCsgDBinstance().delete(s);
146148
}
147149
}
148-
BowlerKernel.runLater(() -> {
149-
image = ThumbnailImage.get(f.getCsgDBinstance(),so);
150-
});
151-
while(image==null) {
150+
if(f.getImageEngine()!=null) {
151+
BowlerKernel.runLater(() -> {
152+
image = f.getImageEngine().get(f.getCsgDBinstance(),so);
153+
});
154+
long start =System.currentTimeMillis();
155+
156+
while(image==null && (System.currentTimeMillis()-start<250)) {
157+
try {
158+
Thread.sleep(20);
159+
} catch (InterruptedException e) {
160+
// TODO Auto-generated catch block
161+
com.neuronrobotics.sdk.common.Log.error(e);
162+
}
163+
}
152164
try {
153-
Thread.sleep(20);
154-
} catch (InterruptedException e) {
155-
// TODO Auto-generated catch block
165+
BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null);
166+
ImageIO.write(bufferedImage, "png", imageFile);
167+
System.err.println("Thumbnail saved successfully to " + imageFile.getAbsolutePath());
168+
} catch (Exception e) {
169+
// com.neuronrobotics.sdk.common.Log.error("Error saving image: " +
170+
// e.getMessage());
156171
com.neuronrobotics.sdk.common.Log.error(e);
157172
}
158173
}
159-
try {
160-
BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null);
161-
ImageIO.write(bufferedImage, "png", imageFile);
162-
System.err.println("Thumbnail saved successfully to " + imageFile.getAbsolutePath());
163-
} catch (Exception e) {
164-
// com.neuronrobotics.sdk.common.Log.error("Error saving image: " +
165-
// e.getMessage());
166-
com.neuronrobotics.sdk.common.Log.error(e);
167-
}
168174
indicator = get(so.get(0));
169175
if (so.size() > 1) {
170176
for(int i=1;i<so.size();i++) {
@@ -183,12 +189,35 @@ public void build(CaDoodleFile f) throws IOException {
183189

184190
}
185191
CSG get(CSG in) {
186-
return in.transformed(TransformFactory.nrToCSG(TransformFactory.affineToNr(in.getManipulator())));
192+
if(in.hasManipulator())
193+
try {
194+
return in.transformed(TransformFactory.nrToCSG(TransformFactory.affineToNr(in.getManipulator())));
195+
} catch (MissingManipulatorException e) {
196+
// TODO Auto-generated catch block
197+
e.printStackTrace();
198+
}
199+
return in;
187200
}
188201
public javafx.scene.image.Image getImage() {
189202
return image;
190203
}
191204
public CSG getIndicator() {
192205
return indicator;
193206
}
207+
208+
public String getUrl() {
209+
return url;
210+
}
211+
212+
public void setUrl(String url) {
213+
this.url = url;
214+
}
215+
216+
public String getSourceFile() {
217+
return file;
218+
}
219+
220+
public void setSourceFile(String file) {
221+
this.file = file;
222+
}
194223
}

0 commit comments

Comments
 (0)