Search in sources :

Example 1 with SimulatedOdometry

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry in project Pathfinder2 by Wobblyyyy.

the class TestMovementRecorder method testMovementRecorder.

public void testMovementRecorder() {
    Pathfinder pf = Pathfinder.newSimulatedPathfinder(0.01);
    SimulatedOdometry odometry = (SimulatedOdometry) pf.getOdometry();
    Translation translation = new Translation(0.51, 0.51, 0);
    odometry.setVelocity(Angle.DEG_45, 0.5);
    odometry.setTranslation(translation);
    pf.setTranslation(translation);
    pf.getRecorder().start();
    pf.tick();
    ElapsedTimer timer = new ElapsedTimer(true);
    while (timer.elapsedSeconds() < 2) pf.tick();
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) Translation(me.wobblyyyy.pathfinder2.geometry.Translation) ElapsedTimer(me.wobblyyyy.pathfinder2.time.ElapsedTimer) SimulatedOdometry(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)

Example 2 with SimulatedOdometry

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry in project Pathfinder2 by Wobblyyyy.

the class TestSimulatedChassis method beforeEach.

@BeforeEach
public void beforeEach() {
    wrapper = new SimulatedWrapper(new SimulatedDrive(), new SimulatedOdometry());
    odometry = wrapper.getOdometry();
    robot = wrapper.getRobot();
    turnController = new ProportionalController(-0.05);
    pathfinder = new Pathfinder(robot, turnController).setSpeed(0.5).setTolerance(DEFAULT_TOLERANCE).setAngleTolerance(Angle.fromDeg(5));
    factory = new SplineBuilderFactory().setSpeed(0.5).setStep(0.1).setTolerance(DEFAULT_TOLERANCE).setAngleTolerance(Angle.fromDeg(5));
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) SplineBuilderFactory(me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory) ProportionalController(me.wobblyyyy.pathfinder2.control.ProportionalController)

Example 3 with SimulatedOdometry

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry in project Pathfinder2 by Wobblyyyy.

the class GenericTrajectoryTester method beforeEach.

@BeforeEach
public void beforeEach() {
    wrapper = new SimulatedWrapper(new SimulatedDrive(), new SimulatedOdometry());
    odometry = wrapper.getOdometry();
    robot = wrapper.getRobot();
    turnController = new ProportionalController(turnCoefficient);
    pathfinder = new Pathfinder(robot, turnController).setSpeed(speed).setTolerance(tolerance).setAngleTolerance(angleTolerance);
    factory = new SplineBuilderFactory().setSpeed(speed).setStep(step).setTolerance(tolerance).setAngleTolerance(angleTolerance);
}
Also used : SplineBuilderFactory(me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory) ProportionalController(me.wobblyyyy.pathfinder2.control.ProportionalController)

Example 4 with SimulatedOdometry

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry in project Pathfinder2 by Wobblyyyy.

the class TestStatTracker method testTicksPerSecond.

public void testTicksPerSecond() {
    Pathfinder pathfinder = Pathfinder.newSimulatedPathfinder(0.01).setSpeed(0.75).setTolerance(2).setAngleTolerance(Angle.fixedDeg(10));
    pathfinder.loadPlugin(new StatTracker());
    pathfinder.goTo(new PointXYZ(10, 10, 0));
    pathfinder.splineTo(new PointXYZ(10, 10, 90), new PointXYZ(12, 11, 45), new PointXYZ(13, 15, 180));
    ElapsedTimer timer = new ElapsedTimer(true);
    SimulatedOdometry odometry = (SimulatedOdometry) pathfinder.getOdometry();
    AtomicInteger i = new AtomicInteger(0);
    try {
        while (timer.elapsedSeconds() < 5) {
            if (Math.random() > 0.5)
                Thread.sleep(2);
            pathfinder.tick();
            Translation translation = pathfinder.getTranslation();
            odometry.setRawPosition(odometry.getRawPosition().add(new PointXYZ(translation.vx() / 50, translation.vy() / 50, Angle.fixedRad(translation.vz() / 50))));
        }
    } catch (Exception ignored) {
    }
    pathfinder.tick();
    System.out.println("tps: " + pathfinder.ticksPerSecond());
    System.out.println("ticks: " + pathfinder.getData("pf_ticks"));
    System.out.println("position: " + pathfinder.getPosition());
    System.out.println("condition met: " + i.get());
    System.out.println("total PointXY: " + PointXY.COUNT);
    System.out.println("total PointXYZ: " + PointXYZ.COUNT);
    System.out.println("total Angle: " + Angle.COUNT);
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) Translation(me.wobblyyyy.pathfinder2.geometry.Translation) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ElapsedTimer(me.wobblyyyy.pathfinder2.time.ElapsedTimer) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) SimulatedOdometry(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)

Example 5 with SimulatedOdometry

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry in project Pathfinder2 by Wobblyyyy.

the class ExampleTimedRobot method robotInit.

@Override
public void robotInit() {
    // initialize everything. if this was a real implementation, you would
    // not want to use SimulatedDrive or SimulatedOdometry
    drive = new SimulatedDrive();
    odometry = new SimulatedOdometry();
    robot = new Robot(drive, odometry);
    pathfinder = new Pathfinder(robot, controller).setSpeed(0.5).setTolerance(2).setAngleTolerance(Angle.fromDeg(5));
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) SimulatedDrive(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive) SimulatedOdometry(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry) TimedRobot(edu.wpi.first.wpilibj.TimedRobot) Robot(me.wobblyyyy.pathfinder2.robot.Robot)

Aggregations

SimulatedOdometry (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)8 PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)7 Robot (me.wobblyyyy.pathfinder2.robot.Robot)6 SimulatedDrive (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive)6 Test (org.junit.jupiter.api.Test)6 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)5 Controller (me.wobblyyyy.pathfinder2.control.Controller)4 GenericTurnController (me.wobblyyyy.pathfinder2.control.GenericTurnController)4 Follower (me.wobblyyyy.pathfinder2.follower.Follower)4 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)4 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)4 ArrayList (java.util.ArrayList)3 GenericFollowerGenerator (me.wobblyyyy.pathfinder2.follower.generators.GenericFollowerGenerator)3 ProportionalController (me.wobblyyyy.pathfinder2.control.ProportionalController)2 Angle (me.wobblyyyy.pathfinder2.geometry.Angle)2 Translation (me.wobblyyyy.pathfinder2.geometry.Translation)2 ElapsedTimer (me.wobblyyyy.pathfinder2.time.ElapsedTimer)2 SplineBuilderFactory (me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory)2 TimedRobot (edu.wpi.first.wpilibj.TimedRobot)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1