Beispiel #1
0
    def test_simple(self):
        child = simulated.Stage("stage", "test", axes=["x", "y"])
        stage = AntiBacklashActuator("absact", "align", {"orig": child},
                                     backlash={"x": 100e-6, "y": -80e-6})

        # moves should just go the same positions
        # abs
        test.assert_pos_almost_equal(stage.position.value, {"x": 0, "y": 0})
        f = stage.moveAbs({"x": 1e-06, "y": 2e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"x": 1e-06, "y": 2e-06})
        test.assert_pos_almost_equal(child.position.value, {"x": 1e-06, "y": 2e-06})
        f = stage.moveAbs({"x": 0, "y": 0})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"x": 0, "y": 0})
        test.assert_pos_almost_equal(child.position.value, {"x": 0, "y": 0})
        f = stage.moveAbs({"x": -23e-06, "y": -15e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"x":-23e-06, "y":-15e-06})
        test.assert_pos_almost_equal(child.position.value, {"x":-23e-06, "y":-15e-06})

        # rel
        f = stage.moveAbs({"x": 0, "y": 0})
        f = stage.moveRel({"x": 1e-06, "y": 2e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"x": 1e-06, "y": 2e-06})
        test.assert_pos_almost_equal(child.position.value, {"x": 1e-06, "y": 2e-06})
        f = stage.moveRel({"x": 0, "y": 0})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"x": 1e-06, "y": 2e-06})
        test.assert_pos_almost_equal(child.position.value, {"x": 1e-06, "y": 2e-06})
        f = stage.moveRel({"x": -1e-06, "y": -2e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"x": 0, "y": 0})
        test.assert_pos_almost_equal(child.position.value, {"x": 0, "y": 0})
Beispiel #2
0
    def test_limited_backlash(self):
        """
        Test when backlash doesn't involve all axes
        """
        child = simulated.Stage("stage", "test", axes=["a", "b"])
        stage = AntiBacklashActuator("absact", "align", {"orig": child},
                                     backlash={"a": 100e-6})

        # moves should just go the same positions
        # abs
        test.assert_pos_almost_equal(stage.position.value, {"a": 0, "b": 0})
        f = stage.moveAbs({"a": 1e-06, "b": 2e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"a": 1e-06, "b": 2e-06})
        test.assert_pos_almost_equal(child.position.value, {"a": 1e-06, "b": 2e-06})
        f = stage.moveAbs({"b": 0})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"a": 1e-06, "b": 0})
        test.assert_pos_almost_equal(child.position.value, {"a": 1e-06, "b": 0})
        f = stage.moveAbs({"a": -23e-06, "b": -15e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"a":-23e-06, "b":-15e-06})
        test.assert_pos_almost_equal(child.position.value, {"a":-23e-06, "b":-15e-06})
        f = stage.moveAbs({"a": -20e-06}) # negative position but positive move
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"a":-20e-06, "b":-15e-06})
        test.assert_pos_almost_equal(child.position.value, {"a":-20e-06, "b":-15e-06})

        # rel
        f = stage.moveAbs({"a": 0})
        f = stage.moveAbs({"b": 0})
        f = stage.moveRel({"a": 1e-06, "b": 2e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"a": 1e-06, "b": 2e-06})
        test.assert_pos_almost_equal(child.position.value, {"a": 1e-06, "b": 2e-06})
        f = stage.moveRel({"a": 0, "b": 0})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"a": 1e-06, "b": 2e-06})
        test.assert_pos_almost_equal(child.position.value, {"a": 1e-06, "b": 2e-06})
        f = stage.moveRel({"a": -1e-06, "b": -2e-06})
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {"a": 0, "b": 0})
        test.assert_pos_almost_equal(child.position.value, {"a": 0, "b": 0})
Beispiel #3
0
    def test_move_update(self):
        child = simulated.Stage("stage", "test", axes=["z"])
        # Slow speed to give some chance of the move update to work
        child.speed.value = {"z": 100e-6}
        stage = AntiBacklashActuator("absact", "abs", {"orig": child},
                                     backlash={"z": 100e-6})

        self.called = 0
        orig_pos = stage.position.value
        stage.position.subscribe(self._on_position)

        for i in range(10):
            if i % 2:
                d = 1
            else:
                d = -1

            dist = d * (i + 1) * 10e-6
            f = stage.moveRel({"z": dist}, update=True)
            time.sleep(0.05)  # 50 ms for 'user update'

        f = stage.moveAbs(orig_pos, update=True)
        f.result()

        # If there is an antibacklash for each move against backlash, we should
        # see ~ 16 moves. If only an antibacklash at the last move
        # (or integrated in last move), we should see 11 or 12 moves.
        self.assertLessEqual(self.called, 12)
        test.assert_pos_almost_equal(child.position.value, orig_pos)
        stage.terminate()
Beispiel #4
0
    def test_limited_backlash(self):
        """
        Test when backlash doesn't involve all axes
        """
        child = simulated.Stage("stage", "test", axes=["a", "b"])
        stage = AntiBacklashActuator("absact", "align", {"orig": child},
                                  backlash={"a": 100e-6})

        # moves should just go the same positions
        # abs
        self.assertPosAlmostEqual(stage.position.value, {"a":0, "b":0})
        f = stage.moveAbs({"a":1e-06, "b":2e-06})
        f.result()
        self.assertPosAlmostEqual(stage.position.value, {"a":1e-06, "b":2e-06})
        self.assertPosAlmostEqual(child.position.value, {"a":1e-06, "b":2e-06})
        f = stage.moveAbs({"b":0})
        f.result()
        self.assertPosAlmostEqual(stage.position.value, {"a":1e-06, "b":0})
        self.assertPosAlmostEqual(child.position.value, {"a":1e-06, "b":0})
        f = stage.moveAbs({"a":-23e-06, "b":-15e-06})
        f.result()
        self.assertPosAlmostEqual(stage.position.value, {"a":-23e-06, "b":-15e-06})
        self.assertPosAlmostEqual(child.position.value, {"a":-23e-06, "b":-15e-06})
        f = stage.moveAbs({"a":-20e-06}) # negative position but positive move
        f.result()
        self.assertPosAlmostEqual(stage.position.value, {"a":-20e-06, "b":-15e-06})
        self.assertPosAlmostEqual(child.position.value, {"a":-20e-06, "b":-15e-06})


        # rel
        f = stage.moveAbs({"a":0})
        f = stage.moveAbs({"b":0})
        f = stage.moveRel({"a":1e-06, "b":2e-06})
        f.result()
        self.assertPosAlmostEqual(stage.position.value, {"a":1e-06, "b":2e-06})
        self.assertPosAlmostEqual(child.position.value, {"a":1e-06, "b":2e-06})
        f = stage.moveRel({"a":0, "b":0})
        f.result()
        self.assertPosAlmostEqual(stage.position.value, {"a":1e-06, "b":2e-06})
        self.assertPosAlmostEqual(child.position.value, {"a":1e-06, "b":2e-06})
        f = stage.moveRel({"a":-1e-06, "b":-2e-06})
        f.result()
        self.assertPosAlmostEqual(stage.position.value, {"a":0, "b":0})
        self.assertPosAlmostEqual(child.position.value, {"a":0, "b":0})
Beispiel #5
0
    def test_error(self):
        child = simulated.Stage("stage", "test", axes=["a", "b"])

        # backlash on non-existing axis
        with self.assertRaises(ValueError):
            stage = AntiBacklashActuator("absact", "align", {"orig": child},
                                         backlash={"a": 100e-6, "x": 50e-6})

        # move on non-existing axis
        stage = AntiBacklashActuator("absact", "align", {"orig": child},
                                     backlash={"a": 100e-6, "b": 50e-6})
        with self.assertRaises(ValueError):
            stage.moveRel({"a": -5e-6, "x": 5e-6})