3838
3939import eu .mihosoft .vrl .v3d .CSG ;
4040import eu .mihosoft .vrl .v3d .FileUtil ;
41+ import eu .mihosoft .vrl .v3d .MissingManipulatorException ;
4142import eu .mihosoft .vrl .v3d .parametrics .CSGDatabase ;
4243import eu .mihosoft .vrl .v3d .parametrics .CSGDatabaseInstance ;
4344import 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 \t Consumes:" + getConsumes () + "\n \t Provides:" + getProvides ();
101+ return getType () + " " + getName () + " " + getUrl () + "/" + getSourceFile () + "\n \t Consumes:" + getConsumes () + "\n \t Provides:" + 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