Z轴可利用代码控制移动
This commit is contained in:
@@ -216,6 +216,63 @@ def test_the_guard_names_an_unknown_direction():
|
||||
# ------------------------------------------------------------------------ mover
|
||||
|
||||
|
||||
def test_an_execute_plan_moves_the_four_axes_together_and_leaves_z():
|
||||
"""Calibration execute starts yaw, pitch and X/Y in one command. Z stays put."""
|
||||
service = make_service()
|
||||
called: list[list[tuple[int, float]]] = []
|
||||
|
||||
def record(moves):
|
||||
called.append(list(moves))
|
||||
return MotionResult.success()
|
||||
|
||||
service.move_abs_many = record # type: ignore[method-assign]
|
||||
poller = FakePoller(service)
|
||||
mover = PoseMover(service, poller.submit)
|
||||
plan = plan_pose_move(
|
||||
service,
|
||||
{"x": 2.0, "y": 1.0, "yaw": 10.0, "pitch": -5.0},
|
||||
hold=("z",),
|
||||
together=True,
|
||||
)
|
||||
assert plan.together
|
||||
assert [step.role for step in plan.steps] == ["yaw", "pitch", "x", "y"]
|
||||
assert mover.start(plan).ok
|
||||
assert len(poller.commands) == 1
|
||||
poller.commands[0](service)
|
||||
assert [axis for axis, _value in called[0]] == [3, 2, 0, 1]
|
||||
|
||||
mover.on_snapshot(
|
||||
snapshot_of(service, {0: 1000.0, 1: 0.0, 2: 0.0, 3: 0.0}, idle=False)
|
||||
)
|
||||
assert mover.running
|
||||
assert mover.progress_text().startswith("同时")
|
||||
assert len(poller.commands) == 1, "a later axis was queued instead of moving with the first"
|
||||
|
||||
mover.on_snapshot(
|
||||
snapshot_of(
|
||||
service,
|
||||
{
|
||||
0: 1000.0,
|
||||
1: 500.0,
|
||||
2: -5.0 * 12500.0 / 90.0,
|
||||
3: 10.0 * 29500.0 / 90.0,
|
||||
},
|
||||
)
|
||||
)
|
||||
assert mover.state.finished
|
||||
|
||||
|
||||
def test_return_to_zero_stays_one_axis_at_a_time():
|
||||
service = make_service()
|
||||
poller = FakePoller(service)
|
||||
mover = PoseMover(service, poller.submit)
|
||||
plan = plan_return_to_initial(service)
|
||||
assert not plan.together
|
||||
assert mover.start(plan).ok
|
||||
assert len(poller.commands) == 1
|
||||
assert mover.state.step.role == "z"
|
||||
|
||||
|
||||
def test_the_mover_commands_one_axis_and_waits_for_it_to_arrive():
|
||||
service = make_service()
|
||||
poller = FakePoller(service)
|
||||
|
||||
Reference in New Issue
Block a user