pxt-ev3/tests/motors.ts

43 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-12-19 22:10:40 +01:00
// add tests package
tests.test("lgB set speed 10", () => {
motors.largeB.setSpeed(10);
2017-12-19 22:10:40 +01:00
loops.pause(500)
tests.assertClose("speedB", 10, motors.largeB.speed(), 2)
});
tests.test("lgB set speed 25 (reversed)", () => {
motors.largeB.setReversed(true)
motors.largeB.setSpeed(25)
2017-12-19 22:10:40 +01:00
loops.pause(500)
tests.assertClose("speedB", -25, motors.largeB.speed(), 2)
});
tests.test("lgBC set speed 5", () => {
motors.largeBC.setSpeed(5)
2017-12-19 22:10:40 +01:00
loops.pause(500)
tests.assertClose("speedB", 5, motors.largeB.speed(), 1);
tests.assertClose("speedC", 5, motors.largeC.speed(), 1);
});
tests.test("lgBC steer 50% 2x", () => {
motors.largeBC.setBrake(true)
motors.largeBC.steer(50, 50, 1, MoveUnit.Rotations)
2017-12-19 22:10:40 +01:00
loops.pause(2000)
tests.assertClose("largeB", 360, motors.largeB.angle(), 5)
motors.largeBC.setBrake(false)
2017-12-18 23:31:17 +01:00
})
2017-12-19 22:10:40 +01:00
tests.test("lgBC steer 360deg", () => {
motors.largeBC.setBrake(true)
2017-12-19 22:10:40 +01:00
motors.largeBC.steer(50, 50, 360, MoveUnit.Degrees)
loops.pause(2000)
tests.assertClose("largeB", 360, motors.largeB.angle(), 5)
});
2017-12-19 22:10:40 +01:00
tests.test("lgBC steer 50% 1s", () => {
motors.largeBC.setBrake(true)
2017-12-19 22:10:40 +01:00
motors.largeBC.steer(10, 50, 1000, MoveUnit.MilliSeconds)
loops.pause(2000)
})
2017-12-19 22:10:40 +01:00
tests.test("lgBC tank 50% 180deg", () => {
motors.largeBC.setBrake(true)
motors.largeBC.tank(50, 50, 180, MoveUnit.Degrees)
loops.pause(1000)
tests.assertClose("largeB", 180, motors.largeB.angle(), 5)
});