use of com.neuronrobotics.sdk.addons.kinematics.AbstractLink in project bowler-script-kernel by CommonWealthRobotics.
the class MobileBaseCadManager method generateCad.
/**
* This function iterates through the links generating them
*
* @param dh
* @return
*/
public ArrayList<CSG> generateCad(DHParameterKinematics dh) {
ArrayList<CSG> dhLinks = new ArrayList<>();
if (cadEngine == null) {
try {
setDefaultLinkLevelCadEngine();
} catch (Exception e) {
getUi().highlightException(getCadScript(), e);
}
}
try {
IgenerateCad generatorToUse = getIgenerateCad();
if (dhCadGen.get(dh) != null) {
Object object = dhCadGen.get(dh);
if (IgenerateCad.class.isInstance(object))
generatorToUse = (IgenerateCad) object;
}
int j = 0;
for (DHParameterKinematics dhtest : getMobileBase().getAllDHChains()) {
if (dhtest == dh)
break;
j++;
}
for (int i = 0; i < dh.getNumberOfLinks(); i++) {
set(base, (int) j, (int) i);
if (!bail) {
ArrayList<CSG> tmp = generatorToUse.generateCad(dh, i);
getUi().addCSG(tmp, getCadScript());
LinkConfiguration configuration = dh.getLinkConfiguration(i);
if (getLinktoCadMap().get(configuration) == null) {
getLinktoCadMap().put(configuration, new ArrayList<>());
} else
getLinktoCadMap().get(configuration).clear();
for (CSG c : tmp) {
dhLinks.add(c);
// add to
getLinktoCadMap().get(configuration).add(c);
// the
// regestration
// storage
}
AbstractLink link = dh.getFactory().getLink(configuration);
link.addLinkListener(new ILinkListener() {
@Override
public void onLinkPositionUpdate(AbstractLink arg0, double arg1) {
// TODO Auto-generated method stub
}
@Override
public void onLinkLimit(AbstractLink arg0, PIDLimitEvent arg1) {
if (getAutoRegen())
selectCsgByLink(base, configuration);
}
});
}
}
return dhLinks;
} catch (Exception e) {
getUi().highlightException(getCadScript(), e);
}
return null;
}
Aggregations