Search in sources :

Example 1 with SimulatedDrive

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive 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 2 with SimulatedDrive

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

the class TestSimulatedDrive method testTranslation.

@Test
public void testTranslation() {
    Translation translation = new Translation(0, 0, 0);
    SimulatedDrive drive = new SimulatedDrive();
    drive.setTranslation(translation);
    Assertions.assertEquals(translation, drive.getTranslation());
}
Also used : Translation(me.wobblyyyy.pathfinder2.geometry.Translation) Test(org.junit.jupiter.api.Test)

Example 3 with SimulatedDrive

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive 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 SimulatedDrive

use of me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive 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)

Example 5 with SimulatedDrive

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

the class TestExecutorManager method testExecutorManager2.

@Test
public void testExecutorManager2() {
    SimulatedOdometry odometry = new SimulatedOdometry();
    SimulatedDrive drive = new SimulatedDrive();
    Robot robot = new Robot(drive, odometry);
    Trajectory trajectory1 = new LinearTrajectory(new PointXYZ(10, 10, 0), 1.0, 0.1, Angle.fromDeg(3));
    Trajectory trajectory2 = new LinearTrajectory(new PointXYZ(20, 20, 45), 1.0, 0.1, Angle.fromDeg(3));
    Trajectory trajectory3 = new LinearTrajectory(new PointXYZ(30, 30, 90), 1.0, 0.1, Angle.fromDeg(3));
    Controller controller = new GenericTurnController(0.1);
    GenericFollowerGenerator generator = new GenericFollowerGenerator(controller);
    Follower follower1 = generator.generate(robot, trajectory1);
    Follower follower2 = generator.generate(robot, trajectory2);
    Follower follower3 = generator.generate(robot, trajectory3);
    List<Follower> followers = new ArrayList<Follower>() {

        {
            add(follower1);
            add(follower2);
            add(follower3);
        }
    };
    ExecutorManager manager = new ExecutorManager(robot);
    manager.addExecutor(followers);
    manager.tick();
    Assertions.assertTrue(manager.isActive());
    odometry.setRawPosition(new PointXYZ(10, 10, 0));
    manager.tick();
    Assertions.assertTrue(manager.isActive());
    odometry.setRawPosition(new PointXYZ(20, 20, 30));
    manager.tick();
    Assertions.assertTrue(manager.isActive());
    odometry.setRawPosition(new PointXYZ(20, 20, 45));
    manager.tick();
    Assertions.assertTrue(manager.isActive());
    odometry.setRawPosition(new PointXYZ(30, 30, 45));
    manager.tick();
    Assertions.assertTrue(manager.isActive());
    odometry.setRawPosition(new PointXYZ(30, 30, 90));
    manager.tick();
    Assertions.assertFalse(manager.isActive());
}
Also used : LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) SimulatedDrive(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive) GenericTurnController(me.wobblyyyy.pathfinder2.control.GenericTurnController) ArrayList(java.util.ArrayList) Follower(me.wobblyyyy.pathfinder2.follower.Follower) SimulatedOdometry(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) GenericTurnController(me.wobblyyyy.pathfinder2.control.GenericTurnController) Controller(me.wobblyyyy.pathfinder2.control.Controller) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) Robot(me.wobblyyyy.pathfinder2.robot.Robot) GenericFollowerGenerator(me.wobblyyyy.pathfinder2.follower.generators.GenericFollowerGenerator) Test(org.junit.jupiter.api.Test)

Aggregations

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