use of com.neuronrobotics.sdk.pid.PIDEvent in project java-bowler by NeuronRobotics.
the class AbstractKinematicsNR method runHome.
private void runHome(PIDChannel joint, int tps) {
IPIDEventListener listen = new IPIDEventListener() {
@Override
public void onPIDReset(int group, int currentValue) {
}
@Override
public void onPIDLimitEvent(PIDLimitEvent e) {
// short circut the waiting loop
homeTime = 0;
Log.debug("Homing PID Limit event " + e);
}
@Override
public void onPIDEvent(PIDEvent e) {
homeTime = System.currentTimeMillis();
}
};
joint.addPIDEventListener(listen);
homeTime = System.currentTimeMillis();
joint.SetPIDSetPoint(tps, 0);
Log.info("Homing output to value: " + tps);
while ((System.currentTimeMillis() < homeTime + 3000)) {
ThreadUtil.wait(100);
}
joint.removePIDEventListener(listen);
}
use of com.neuronrobotics.sdk.pid.PIDEvent in project java-bowler by NeuronRobotics.
the class PidNamespaceImp method onAsyncResponse.
@Override
public void onAsyncResponse(BowlerDatagram data) {
// Log.debug("\nPID ASYNC<<"+data);
if (data.getRPC().contains("_pid")) {
PIDEvent e = new PIDEvent(data);
firePIDEvent(e);
}
if (data.getRPC().contains("apid")) {
int[] pos = new int[getNumberOfChannels()];
for (int i = 0; i < getNumberOfChannels(); i++) {
pos[i] = ByteList.convertToInt(data.getData().getBytes(i * 4, 4), true);
PIDEvent e = new PIDEvent(i, pos[i], System.currentTimeMillis(), 0);
firePIDEvent(e);
}
}
if (data.getRPC().contains("pidl")) {
firePIDLimitEvent(new PIDLimitEvent(data));
}
}
use of com.neuronrobotics.sdk.pid.PIDEvent in project java-bowler by NeuronRobotics.
the class VirtualPuckBot method init.
private void init(VirtualWorld w, int botStartX, int botStartY) {
world = w;
world.addRobot(this, botStartX, botStartY);
controller = new VirtualGenericPIDDevice(getMaxTicksPerSeconds());
controller.addPIDEventListener(new IPIDEventListener() {
public void onPIDReset(int group, int currentValue) {
}
public void onPIDLimitEvent(PIDLimitEvent e) {
}
public void onPIDEvent(PIDEvent e) {
world.updateMap();
}
});
setPIDChanels(controller.getPIDChannel(0), controller.getPIDChannel(1));
}
use of com.neuronrobotics.sdk.pid.PIDEvent in project java-bowler by NeuronRobotics.
the class PidPrismaticLink method setPIDChannel.
public void setPIDChannel(PIDChannel channel) {
channel.addPIDEventListener(new IPIDEventListener() {
@Override
public void onPIDReset(int group, int currentValue) {
}
@Override
public void onPIDLimitEvent(PIDLimitEvent e) {
}
@Override
public void onPIDEvent(PIDEvent e) {
fireLinkListener(e.getValue());
}
});
this.channel = channel;
}
use of com.neuronrobotics.sdk.pid.PIDEvent in project java-bowler by NeuronRobotics.
the class PuckBotDefaultKinematics method pair.
private void pair(PIDEvent e) {
if (rightPidEvent == null && leftPidEvent == null) {
if (e.getGroup() == leftIndex) {
leftPidEvent = e;
}
if (e.getGroup() == rightIndex) {
rightPidEvent = e;
}
}
if (rightPidEvent != null && leftPidEvent == null) {
if (e.getGroup() == rightIndex) {
rightPidEvent = e;
leftPidEvent = new PIDEvent(leftIndex, leftEncoderValue, e.getTimeStamp(), 0);
}
if (e.getGroup() == leftIndex) {
if (e.getTimeStamp() == rightPidEvent.getTimeStamp()) {
leftPidEvent = e;
} else {
leftPidEvent = e;
rightPidEvent = null;
}
}
}
if (rightPidEvent == null && leftPidEvent != null) {
if (e.getGroup() == leftIndex) {
rightPidEvent = new PIDEvent(rightIndex, rightEncoderValue, e.getTimeStamp(), 0);
leftPidEvent = e;
}
if (e.getGroup() == rightIndex) {
if (e.getTimeStamp() == leftPidEvent.getTimeStamp()) {
rightPidEvent = e;
} else {
rightPidEvent = e;
leftPidEvent = null;
}
}
}
}
Aggregations