@@ -779,9 +779,9 @@ private TransformNR updateBase(MobileBase base, TransformNR baseLoc, HashMap<Aff
779779 return forwardOffset ;
780780 }
781781
782- private MobileBaseCadManager (MobileBase base , IMobileBaseUI myUI ) {
782+ private MobileBaseCadManager (CSGDatabaseInstance csgDatabaseInstance , MobileBase base , IMobileBaseUI myUI ) {
783783 this .setUi (myUI );
784- setMobileBase (base );
784+ setMobileBase (csgDatabaseInstance , base );
785785 }
786786
787787 private Object scriptFromFileInfo (CSGDatabaseInstance db ,String name , String [] args , Runnable runner ) throws Throwable {
@@ -877,25 +877,25 @@ private void closeScriptFromFileInfo(String[] args) {
877877
878878 }
879879
880- private IgenerateBody getIgenerateBody (MobileBase b ) throws Throwable {
880+ private IgenerateBody getIgenerateBody (CSGDatabaseInstance csgDatabaseInstance , MobileBase b ) throws Throwable {
881881 if (isConfigMode ())
882- return getConfigurationDisplay ();
882+ return getConfigurationDisplay (csgDatabaseInstance );
883883 Object cadForBodyEngine = scriptFromFileInfo (getDb (),b .getScriptingName (), b .getGitCadEngine (), () -> {
884884 run ();
885- generateCad ();
885+ generateCad (csgDatabaseInstance );
886886 });
887887 if (IgenerateBody .class .isInstance (cadForBodyEngine )) {
888888 return (IgenerateBody ) cadForBodyEngine ;
889889 }
890890 return null ;
891891 }
892892
893- private IgenerateCad getIgenerateCad (DHParameterKinematics dh ) throws Throwable {
893+ private IgenerateCad getIgenerateCad (CSGDatabaseInstance csgDatabaseInstance , DHParameterKinematics dh ) throws Throwable {
894894 if (isConfigMode ())
895- return getConfigurationDisplay ();
895+ return getConfigurationDisplay (csgDatabaseInstance );
896896 Object cadForBodyEngine = scriptFromFileInfo (getDb (),dh .getScriptingName (), dh .getGitCadEngine (), () -> {
897897 run ();
898- generateCad ();
898+ generateCad (csgDatabaseInstance );
899899 });
900900 if (IgenerateCad .class .isInstance (cadForBodyEngine )) {
901901 return (IgenerateCad ) cadForBodyEngine ;
@@ -913,14 +913,14 @@ public IgenerateBed getIgenerateBed() throws Throwable {
913913 return null ;
914914 }
915915
916- private ICadGenerator getConfigurationDisplay () throws Throwable {
916+ private ICadGenerator getConfigurationDisplay (CSGDatabaseInstance csgDatabaseInstance ) throws Throwable {
917917 if (cadEngineConfiguration == null ) {
918918 String [] args = new String [] { "https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git" ,
919919 "dhcad.groovy" };
920920 Object cadForBodyEngine = scriptFromFileInfo (getDb (),"ConfigDisplay" , args , () -> {
921921 cadEngineConfiguration = null ;
922922 try {
923- getConfigurationDisplay ();
923+ getConfigurationDisplay (csgDatabaseInstance );
924924 } catch (Throwable e ) {
925925 // Auto-generated catch block
926926 com .neuronrobotics .sdk .common .Log .error (e );
@@ -931,7 +931,7 @@ private ICadGenerator getConfigurationDisplay() throws Throwable {
931931 mobileBaseCadManager = cadmap .get (manager );
932932 if (mobileBaseCadManager .autoRegen )
933933 if (mobileBaseCadManager .isConfigMode ())
934- mobileBaseCadManager .generateCad ();
934+ mobileBaseCadManager .generateCad (csgDatabaseInstance );
935935 }
936936 } catch (Exception e ) {
937937 if (mobileBaseCadManager != null )
@@ -949,11 +949,11 @@ private CSGDatabaseInstance getDb() {
949949 return MobileBaseLoader .get (base ).getDb ();
950950 }
951951
952- public ArrayList <CSG > generateBody () {
953- return generateBody (getMobileBase (), true );
952+ public ArrayList <CSG > generateBody (CSGDatabaseInstance csgDatabaseInstance ) {
953+ return generateBody (csgDatabaseInstance , getMobileBase (), true );
954954 }
955955
956- public ArrayList <CSG > generateBody (MobileBase base , boolean clear ) {
956+ public ArrayList <CSG > generateBody (CSGDatabaseInstance csgDatabaseInstance , MobileBase base , boolean clear ) {
957957 if (!base .isAvailable ())
958958 throw new RuntimeException ("Device " + base .getScriptingName () + " is not connected, can not generate cad" );
959959
@@ -981,15 +981,15 @@ public ArrayList<CSG> generateBody(MobileBase base, boolean clear) {
981981
982982 ArrayList <CSG > newcad = null ;
983983 try {
984- newcad = getIgenerateBody (device ).generateBody (device );
984+ newcad = getIgenerateBody (csgDatabaseInstance , device ).generateBody (device );
985985 } catch (Throwable t ) {
986986 getUi ().highlightException (null , t );
987987 }
988988 if (newcad == null ) {
989989 newcad = new ArrayList <CSG >();
990990 }
991991 if (newcad .size () == 0 ) {
992- newcad = getConfigurationDisplay ().generateBody (device );
992+ newcad = getConfigurationDisplay (csgDatabaseInstance ).generateBody (device );
993993 }
994994 if (device .isAvailable ()) {
995995 for (CSG c : newcad ) {
@@ -1050,7 +1050,7 @@ public ArrayList<CSG> generateBody(MobileBase base, boolean clear) {
10501050 arrayList .clear ();
10511051 // System.gc();
10521052 }
1053- ArrayList <CSG > linksCad = generateCad (l );
1053+ ArrayList <CSG > linksCad = generateCad (csgDatabaseInstance , l );
10541054
10551055 for (CSG csg : linksCad ) {
10561056
@@ -1067,7 +1067,7 @@ public ArrayList<CSG> generateBody(MobileBase base, boolean clear) {
10671067
10681068 }
10691069 for (MobileBaseCadManager m : slaves ) {
1070- getAllCad ().addAll (m .generateBody (m .base , false ));
1070+ getAllCad ().addAll (m .generateBody (csgDatabaseInstance , m .base , false ));
10711071 }
10721072 showingStl = false ;
10731073 // setProgress(1);
@@ -1289,7 +1289,7 @@ public MobileBase getMobileBase() {
12891289 return base ;
12901290 }
12911291
1292- public void setMobileBase (MobileBase b ) {
1292+ public void setMobileBase (CSGDatabaseInstance csgDatabaseInstance , MobileBase b ) {
12931293 for (MobileBase mb : cadmap .keySet ()) {
12941294 if (mb == b )
12951295 throw new RuntimeException ("Can not duplicat mobile base" );
@@ -1310,7 +1310,7 @@ public void setMobileBase(MobileBase b) {
13101310 k .setRenderWrangler (this );
13111311 }
13121312 base .setConfigurationUpdate (() -> {
1313- generateCad ();
1313+ generateCad (csgDatabaseInstance );
13141314 });
13151315 run ();
13161316 // new Exception("Adding the mysteryListener
@@ -1350,12 +1350,12 @@ public void onConnect(BowlerAbstractDevice arg0) {
13501350 * @param dh
13511351 * @return
13521352 */
1353- public ArrayList <CSG > generateCad (DHParameterKinematics dh ) {
1353+ public ArrayList <CSG > generateCad (CSGDatabaseInstance csgDatabaseInstance , DHParameterKinematics dh ) {
13541354 ArrayList <CSG > dhLinks = new ArrayList <>();
13551355
13561356 try {
1357- IgenerateCad generatorToUse = getConfigurationDisplay ();
1358- Object object = getIgenerateCad (dh );
1357+ IgenerateCad generatorToUse = getConfigurationDisplay (csgDatabaseInstance );
1358+ Object object = getIgenerateCad (csgDatabaseInstance , dh );
13591359 if (object != null && !isConfigMode ()) {
13601360 if (IgenerateCad .class .isInstance (object ))
13611361 generatorToUse = (IgenerateCad ) object ;
@@ -1372,7 +1372,7 @@ public ArrayList<CSG> generateCad(DHParameterKinematics dh) {
13721372 if (!bail ) {
13731373 ArrayList <CSG > newcad = null ;
13741374 try {
1375- newcad = generatorToUse .generateCad (dh , i );
1375+ newcad = generatorToUse .generateCad (csgDatabaseInstance , dh , i );
13761376 } catch (Throwable t ) {
13771377 Log .error (t );
13781378 getUi ().highlightException (null , t );
@@ -1381,7 +1381,7 @@ public ArrayList<CSG> generateCad(DHParameterKinematics dh) {
13811381 newcad = new ArrayList <CSG >();
13821382 }
13831383 if (newcad .size () == 0 ) {
1384- newcad = getConfigurationDisplay ().generateCad (dh , i );
1384+ newcad = getConfigurationDisplay (csgDatabaseInstance ).generateCad (csgDatabaseInstance , dh , i );
13851385 }
13861386 getUi ().addCSG (newcad , getCadScriptFromLimnb (dh ));
13871387 LinkConfiguration configuration = dh .getLinkConfiguration (i );
@@ -1414,7 +1414,7 @@ public void onLinkLimit(AbstractLink arg0, PIDLimitEvent arg1) {
14141414 });
14151415 DHLink dhl = dh .getDhLink (i );
14161416 if (dhl .getSlaveMobileBase () != null ) {
1417- ArrayList <CSG > slParts = generateBody (dhl .getSlaveMobileBase (), false );
1417+ ArrayList <CSG > slParts = generateBody (csgDatabaseInstance , dhl .getSlaveMobileBase (), false );
14181418 dhLinks .addAll (slParts );
14191419 }
14201420 // ArrayList<CSG> generateBody(MobileBase base)
@@ -1462,11 +1462,11 @@ public void selectCsgByLink(MobileBase base, LinkConfiguration limb) {
14621462 }
14631463 }
14641464
1465- public void generateCad () {
1466- generateCadWithEnd ((Runnable ) null );
1465+ public void generateCad (CSGDatabaseInstance csgDatabaseInstance ) {
1466+ generateCadWithEnd (csgDatabaseInstance , (Runnable ) null );
14671467 }
14681468
1469- public void generateCadWithEnd (Runnable done ) {
1469+ public void generateCadWithEnd (CSGDatabaseInstance csgDatabaseInstance , Runnable done ) {
14701470 if (cadGenerating || !getAutoRegen ())
14711471 return ;
14721472 cadGenerating = true ;
@@ -1489,7 +1489,7 @@ public void run() {
14891489 MobileBaseCadManager .get (base ).clear ();
14901490
14911491 try {
1492- setAllCad (generateBody (device , true ));
1492+ setAllCad (generateBody (csgDatabaseInstance , device , true ));
14931493 } catch (Exception e ) {
14941494
14951495 getUi ().highlightException (getCadScriptFromMobileBase (device ), e );
@@ -1562,11 +1562,11 @@ public void setAllCad(ArrayList<CSG> allCad) {
15621562 this .allCad = allCad ;
15631563 }
15641564
1565- public static MobileBaseCadManager get (MobileBase device , IMobileBaseUI ui ) {
1565+ public static MobileBaseCadManager get (CSGDatabaseInstance csgDatabaseInstance , MobileBase device , IMobileBaseUI ui ) {
15661566 if (cadmap .get (device ) == null ) {
15671567 // new RuntimeException("No Mobile Base Cad Manager UI
15681568 // specified").printStackTrace();
1569- MobileBaseCadManager mbcm = new MobileBaseCadManager (device , ui );
1569+ MobileBaseCadManager mbcm = new MobileBaseCadManager (csgDatabaseInstance , device , ui );
15701570
15711571 }
15721572 MobileBaseCadManager mobileBaseCadManager = cadmap .get (device );
@@ -1577,7 +1577,7 @@ public static MobileBaseCadManager get(MobileBase device, IMobileBaseUI ui) {
15771577 return mobileBaseCadManager ;
15781578 }
15791579
1580- public static MobileBaseCadManager get (MobileBase device ) {
1580+ public static MobileBaseCadManager get (CSGDatabaseInstance csgDatabaseInstance , MobileBase device ) {
15811581 if (cadmap .get (device ) == null ) {
15821582 for (MobileBase mb : cadmap .keySet ()) {
15831583 for (DHParameterKinematics kin : mb .getAllDHChains ()) {
@@ -1606,7 +1606,7 @@ public void onConnect(BowlerAbstractDevice source) {
16061606 }
16071607 });
16081608
1609- return get (device , ui2 );
1609+ return get (csgDatabaseInstance , device , ui2 );
16101610 }
16111611 return cadmap .get (device );
16121612 }
0 commit comments