/** * Sets this YoInteger to its current value minus one. */ public void decrement() { this.set(this.getLongValue() - 1); }
/** * Creates a new YoLong with the same parameters as this one, and registers it to the passed {@link YoVariableRegistry}. * * @param newRegistry YoVariableRegistry to duplicate this YoLong to * @return the newly created and registered YoLong */ @Override public YoLong duplicate(YoVariableRegistry newRegistry) { YoLong retVar = new YoLong(getName(), getDescription(), newRegistry, getManualScalingMin(), getManualScalingMax()); retVar.set(getLongValue()); return retVar; }
@Override public void doControl() { for (int i = 0; i < controllers.size(); i++) { controllers.get(i).readData(currentControlTick.getLongValue()); controllers.get(i).executeForSimulationTick(currentControlTick.getLongValue()); controllers.get(i).waitAndWriteData(currentControlTick.getLongValue()); } currentControlTick.increment(); } }
/** * Set the value of this YoLong using the given double, passed through {@link #convertFromDoubleToLong(double)}. * * @param doubleValue double to convert and set this YoLong to * @param notifyListeners boolean determining whether or not to call {@link #notifyVariableChangedListeners()} */ @Override public void setValueFromDouble(double doubleValue, boolean notifyListeners) { set(convertFromDoubleToLong(doubleValue), notifyListeners); }
@Override public long getValue() { return getLongValue(); } }
/** * Sets the internal long value of this YoLong using the passed long value. * * <p>Effectively equivalent to {@link #set(long, boolean)}. * * @param value long to set this variable's value to * @param notifyListeners boolean determining whether or not to call {@link #notifyVariableChangedListeners()} */ @Override public void setValueFromLongBits(long value, boolean notifyListeners) { set(value, notifyListeners); }
controllerTimestamp.set(threadDataSynchronizer.getTimestamp()); controllerTime.set(Conversions.nanosecondsToSeconds(controllerTimestamp.getLongValue())); if (expectedEstimatorTick.getLongValue() != threadDataSynchronizer.getEstimatorTick()) if (expectedEstimatorTick.getLongValue() > threadDataSynchronizer.getEstimatorTick()) controllerLeadsEstimatorTicks.increment(); else if (expectedEstimatorTick.getLongValue() < threadDataSynchronizer.getEstimatorTick()) controllerLagsEstimatorTicks.increment(); lastExpectedEstimatorTick.set(expectedEstimatorTick.getLongValue()); lastEstimatorTick.set(threadDataSynchronizer.getEstimatorTick()); lastEstimatorClockStartTime.set(threadDataSynchronizer.getEstimatorClockStartTime()); lastControllerClockTime.set(currentClockTime); timePassedSinceEstimator.set(currentClockTime - lastEstimatorStartTime.getLongValue()); timePassedBetweenEstimatorTicks.set(estimatorStartTime - lastEstimatorStartTime.getLongValue()); expectedEstimatorTick.set(threadDataSynchronizer.getEstimatorTick() + estimatorTicksPerControlTick); controllerStartTime.set(currentClockTime); lastEstimatorStartTime.set(estimatorStartTime);
public YoMultipleFramesHelper(String namePrefix, YoVariableRegistry registry, ReferenceFrame... referenceFrames) { if (referenceFrames == null || referenceFrames.length == 0) throw new RuntimeException("Need to provide at least one ReferenceFrame."); currentFrameId = new YoLong(namePrefix + "FrameId", registry); currentFrameId.set(referenceFrames[0].hashCode()); for (ReferenceFrame referenceFrame : referenceFrames) { this.registerReferenceFrame(referenceFrame); } }
/** * Returns String representation of this YoLong. * * @return a String representing this YoLong and its current value as a long */ @Override public String toString() { return String.format("%s: %d", getName(), getLongValue()); }
@Override public YoLong duplicate(YoVariableRegistry newRegistry) { LongParameter newParameter = new LongParameter(getName(), getDescription(), newRegistry, initialValue, (long) getManualScalingMin(), (long) getManualScalingMax()); newParameter.value.set(value.getValue()); newParameter.loadStatus = getLoadStatus(); return newParameter.value; } }
@Override public void run() { q_j1_d.set(q_j1_d.getDoubleValue() + 0.1); q_j2_d.set(q_j2_d.getDoubleValue() + 0.05); tau_j1.set(kp.getDoubleValue() * (q_j1_d.getDoubleValue() - q_j1.getDoubleValue()) + kd.getDoubleValue() * (-qd_j1.getDoubleValue())); tau_j2.set(kp.getDoubleValue() * (q_j2_d.getDoubleValue() - q_j2.getDoubleValue()) + kd.getDoubleValue() * (-qd_j2.getDoubleValue())); tick.increment(); long start = System.nanoTime(); while(System.nanoTime() - start < Conversions.millisecondsToNanoseconds(10)) { // Busy wait } }
private void updateIsControllerTick() { if (controllerTimerCount == null) { isControllerTick = true; return; } isControllerTick = controllerTimerCount.getLongValue() != lastControllerTimerCount; lastControllerTimerCount = controllerTimerCount.getLongValue(); }
/** * Calls {@link #set(long, boolean)} with value and true. * * @param value long to set this YoInteger's internal integer state to */ public void set(long value) { set(value, true); }
public void update(ByteBuffer buffer) throws IOException lastMicroControllerTime = microControllerTime.getLongValue(); checksumFailures.increment(); totalPacketDropCount.increment(); consecutivePacketDropCount.increment(); return; microControllerTime.set(buffer.getInt() & 0xFFFFFFFFl); actualActuatorDT.set(microControllerTime.getLongValue() - lastMicroControllerTime); inphaseCompositeStatorCurrent.set(buffer.getFloat()); quadratureCompositeStatorCurrent.set(buffer.getFloat()); jointEncoderVelocity.set(buffer.getFloat()*jointEncoderScale*velocityScale); lastReceivedControlID.set(buffer.getInt() & 0xFFFFFFFFl);
nanosecondstime = new YoLong("longtime", registry); total_time = new YoDouble("time", registry); startTime = new YoDouble("startTime", registry); walking_time = new YoDouble("walkingtime", registry); expo_isWalking = new YoBoolean("walk", registry); startingStepCount = new YoLong("expoStartingStepCount", registry); COT = new YoDouble("COT", registry); nanosecondstime.set(1234567890); startTime.set(0.0); expo_isWalking.set(false); walking_time.set(6100.0); init_complete = true; startingStepCount.set(123); distanceTraveled.set(1.0); startDistance.set(0.0); walking_time = new YoDouble("expoWalkingTime", parentRegistry); expo_isWalking = (YoBoolean) parentRegistry.getVariable("DesiredFootstepCalculatorFootstepProviderWrapper","walk"); startingStepCount = new YoLong("expoStartingStepCount", parentRegistry);
@Override public int solve(DenseMatrix64F Q, DenseMatrix64F f, DenseMatrix64F Aeq, DenseMatrix64F beq, DenseMatrix64F Ain, DenseMatrix64F bin, DenseMatrix64F x, boolean initialize) throws NoConvergenceException { //allocate on demand if (linearInequalityActiveSet == null) linearInequalityActiveSet = new boolean[Ain.numRows]; else if (linearInequalityActiveSet.length != Ain.numRows) { System.err.println("linearInequalitySize changes, cold start with empty set"); linearInequalityActiveSet = new boolean[Ain.numRows]; } if (initialize) Arrays.fill(linearInequalityActiveSet, false); int iter = solver.solve(Q, f, Aeq, beq, Ain, bin, linearInequalityActiveSet, x); simpleSolverIterations.set(iter); if (iter < 0) { fullSolverCount.increment(); Arrays.fill(linearInequalityActiveSet, false); fullSolver.solve(Q, f, Aeq, beq, Ain, bin, x, initialize); } return iter; }
public AbstractThreadedRobotController(String name) { this.name = name; this.registry = new YoVariableRegistry(name); this.currentControlTick = new YoLong("currentControlTick", registry); this.yoTime = new YoDouble("time", registry); this.simulatedRobot = null; }
corruptedPackets.increment();