use of com.neuronrobotics.sdk.pid.PIDConfiguration in project java-bowler by NeuronRobotics.
the class AbstractKinematicsNR method setDevice.
protected void setDevice(LinkFactory f, ArrayList<LinkConfiguration> linkConfigs) {
Log.info("Loading device: " + f.getClass() + " " + f);
setFactory(f);
// Log.enableDebugPrint(true);
for (int i = 0; i < linkConfigs.size(); i++) {
LinkConfiguration c = linkConfigs.get(i);
c.setLinkIndex(i);
getFactory().getLink(c);
Log.info("\nAxis #" + i + " Configuration:\n" + c);
if (c.getType() == LinkType.PID) {
IPidControlNamespace device = getFactory().getPid();
try {
PIDConfiguration tmpConf = device.getPIDConfiguration(c.getHardwareIndex());
tmpConf.setGroup(c.getHardwareIndex());
tmpConf.setKP(c.getKP());
tmpConf.setKI(c.getKI());
tmpConf.setKD(c.getKD());
tmpConf.setEnabled(true);
tmpConf.setInverted(c.isInverted());
tmpConf.setAsync(false);
tmpConf.setUseLatch(false);
tmpConf.setIndexLatch(c.getIndexLatch());
tmpConf.setStopOnIndex(false);
Log.info("\nAxis #" + i + " " + tmpConf);
getAxisPidConfiguration().add(tmpConf);
setLinkCurrentConfiguration(i, tmpConf);
// Send configuration for ONE axis
device.ConfigurePIDController(tmpConf);
} catch (Exception ex) {
Log.error("Configuration #" + i + " failed!!");
ex.printStackTrace();
}
device.addPIDEventListener(this);
}
}
getCurrentTaskSpaceTransform();
getFactory().addLinkListener(this);
getDhParametersChain().setFactory(getFactory());
// filling up the d-h parameters so the chain sizes match
while (getDhParametersChain().getLinks().size() < linkConfigs.size()) {
getDhParametersChain().addLink(new DHLink(0, 0, 0, 0));
}
}
use of com.neuronrobotics.sdk.pid.PIDConfiguration in project java-bowler by NeuronRobotics.
the class AbstractKinematicsNR method homeLink.
public void homeLink(int link) {
if (link < 0 || link >= getNumberOfLinks()) {
throw new IndexOutOfBoundsException("There are only " + getNumberOfLinks() + " known links, requested:" + link);
}
LinkConfiguration conf = getLinkConfiguration(link);
if (conf.getType() == LinkType.PID) {
getFactory().getPid().removePIDEventListener(this);
// Range is in encoder units
double range = Math.abs(conf.getUpperLimit() - conf.getLowerLimit()) * 2;
Log.info("Homing link:" + link + " to latch value: " + conf.getIndexLatch());
PIDConfiguration pidConf = getLinkCurrentConfiguration(link);
PIDChannel joint = getFactory().getPid().getPIDChannel(conf.getHardwareIndex());
// Clear the index
pidConf.setStopOnIndex(false);
pidConf.setUseLatch(false);
pidConf.setIndexLatch(conf.getIndexLatch());
// Sets up the latch
joint.ConfigurePIDController(pidConf);
// Move forward to stop
runHome(joint, (int) (range));
// Enable index
pidConf.setStopOnIndex(true);
pidConf.setUseLatch(true);
pidConf.setIndexLatch(conf.getIndexLatch());
// Sets up the latch
joint.ConfigurePIDController(pidConf);
// Move negative to the index
runHome(joint, (int) (range * -1));
pidConf.setStopOnIndex(false);
pidConf.setUseLatch(false);
pidConf.setIndexLatch(conf.getIndexLatch());
// Shuts down the latch
joint.ConfigurePIDController(pidConf);
try {
// go to zero instead of to the index itself
setDesiredJointAxisValue(link, 0, 0);
} catch (Exception e) {
e.printStackTrace();
}
getFactory().getPid().addPIDEventListener(this);
} else {
getFactory().getLink(getLinkConfiguration(link)).Home();
getFactory().flush(1000);
}
}
use of com.neuronrobotics.sdk.pid.PIDConfiguration in project java-bowler by NeuronRobotics.
the class LinkConfiguration method getPidConfiguration.
public PIDConfiguration getPidConfiguration() {
PIDConfiguration pid = new PIDConfiguration();
pid.setKD(getKD());
pid.setGroup(getHardwareIndex());
pid.setStopOnIndex(isStopOnLatch());
pid.setKI(getKI());
pid.setKP(getKP());
pid.setIndexLatch(getIndexLatch());
pid.setInverted(isInverted());
return pid;
}
Aggregations