/** * * @param classBuilder Helper class to create empty version of T * @param capacity Capacity of the ring buffer, automatically rounded up to the next power of two */ @SuppressWarnings("unchecked") public ConcurrentRingBuffer(Builder<? extends T> classBuilder, int capacity) { if (capacity < 0) { throw new RuntimeException("Capacity < 0"); } this.capacity = RealtimeTools.nextPowerOfTwo(capacity); this.capacityMask = this.capacity - 1; buffer = (T[]) new Object[this.capacity]; for (int i = 0; i < this.capacity; i++) { buffer[i] = classBuilder.newInstance(); } }
/** * * @param classBuilder Helper class to create empty version of T * @param capacity Capacity of the ring buffer, automatically rounded up to the next power of two */ @SuppressWarnings("unchecked") public ConcurrentRingBuffer(Builder<? extends T> classBuilder, int capacity) { if (capacity < 0) { throw new RuntimeException("Capacity < 0"); } this.capacity = RealtimeTools.nextPowerOfTwo(capacity); this.capacityMask = this.capacity - 1; buffer = (T[]) new Object[this.capacity]; for (int i = 0; i < this.capacity; i++) { buffer[i] = classBuilder.newInstance(); } }
public void startSimulation() throws IOException { SimpleLidarRobot robot = new SimpleLidarRobot(); SimulationConstructionSetParameters parameters = new SimulationConstructionSetParameters(true, RealtimeTools.nextPowerOfTwo(200000)); SimulationConstructionSet scs = new SimulationConstructionSet(robot, parameters); double simDT = 0.0001; double controlDT = 0.01; scs.setDT(simDT, 10); scs.setSimulateDoneCriterion(() -> false); Graphics3DAdapter graphics3dAdapter = scs.getGraphics3dAdapter(); YoGraphicsListRegistry yoGraphicsListRegistry = new YoGraphicsListRegistry(); SimpleLidarRobotController controller = new SimpleLidarRobotController(robot, controlDT, ros2Node, graphics3dAdapter, yoGraphicsListRegistry); robot.setController(controller, (int) (controlDT / simDT)); scs.addYoGraphicsListRegistry(yoGraphicsListRegistry); createGroundTypeListener(scs); scs.setGroundVisible(false); scs.startOnAThread(); scs.simulate(); }