-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmakeKinematic.groovy
61 lines (52 loc) · 2.16 KB
/
makeKinematic.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import javafx.scene.paint.Color;
def base =args!=null?args:DeviceManager.getSpecificDevice( "HephaestusWorkCell",{
//If the device does not exist, prompt for the connection
MobileBase m = BowlerStudio.loadMobileBaseFromGit(
"https://github.com/madhephaestus/SeriesElasticActuator.git",
"seaArm.xml"
)
if(m==null)
throw new RuntimeException("Arm failed to assemble itself")
println "Connecting new device robot arm "+m
return m
})
/**
* This function should generate the bed or beds or parts to be used in manufacturing
* If parts are to be ganged up to make print beds then this should happen here
* @param base the base to generate
* @return simulatable CAD objects
*/
ArrayList<CSG> arrangeBed(MobileBase b ){
ArrayList<DHParameterKinematics> limbs = b.getAllDHChains();
double numLimbs = limbs.size();
int i;
// Start by generating the legs using the DH link based generator
ArrayList<CSG> totalAssembly = new ArrayList<>();
double offset = 0;
for (i = 0; i < limbs.size(); i += 1) {
DHParameterKinematics l = limbs.get(i);
ArrayList<LinkConfiguration> links = l.getLinkConfigurations();
for (LinkConfiguration lc:links) {
ArrayList<CSG> cadForThisLink = MobileBaseCadManager.get(b).getLinktoCadMap().get(lc);
CSG linUnified = CSG.unionAll(cadForThisLink);
totalAssembly.add(linUnified);
}
}
// now we genrate the base pieces
totalAssembly.add(CSG.unionAll(MobileBaseCadManager.get(b).getBasetoCadMap().get(b)));
return totalAssembly
}
ThreadUtil.wait(100)
while(MobileBaseCadManager.get( base).getProcesIndictor().get()<1){
ThreadUtil.wait(1000)
println "Waiting for cad to get to 1, currently = "+MobileBaseCadManager.get(base).getProcesIndictor().get()
}
File baseDirForFiles = com.neuronrobotics.nrconsole.util.FileSelectionFactory.GetDirectory(new File(System.getProperty("user.home")))
List<CSG> totalAssembly = arrangeBed(base) ;
BowlerStudioController.setCsg(totalAssembly , null);
//return null
File dir = new File(baseDirForFiles.getAbsolutePath() + "/" + base.getScriptingName() );
if (!dir.exists())
dir.mkdirs();
new CadFileExporter().generateManufacturingParts(totalAssembly, dir);
return totalAssembly