Skip to content

Commit abcdf59

Browse files
authored
Ignore motor soft limits when they are both zero (#1052)
1 parent aeded11 commit abcdf59

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/ophyd_async/epics/motor.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,21 @@ def set_name(self, name: str, *, child_name_separator: str | None = None) -> Non
107107
self.user_readback.set_name(name)
108108

109109
async def check_motor_limit(self, abs_start_pos: float, abs_end_pos: float):
110-
"""Check the motor limit with the absolute positions."""
110+
"""Check the positions are within limits.
111+
112+
Will raise a MotorLimitsException if the given absolute positions will be
113+
outside the motor soft limits.
114+
"""
111115
motor_lower_limit, motor_upper_limit, egu = await asyncio.gather(
112116
self.low_limit_travel.get_value(),
113117
self.high_limit_travel.get_value(),
114118
self.motor_egu.get_value(),
115119
)
120+
121+
# EPICS motor record treats limits of 0, 0 as no limit
122+
if motor_lower_limit == 0 and motor_upper_limit == 0:
123+
return
124+
116125
if (
117126
not motor_upper_limit >= abs_start_pos >= motor_lower_limit
118127
or not motor_upper_limit >= abs_end_pos >= motor_lower_limit

tests/epics/test_motor.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async def test_set_with_zero_velocity(sim_motor: motor.Motor) -> None:
155155
(10, 9.99, -9.99), # Goes above upper_limit
156156
],
157157
)
158-
async def test_set_motor_limits_error(
158+
async def test_move_outside_motor_limits_causes_error(
159159
sim_motor: motor.Motor,
160160
position,
161161
upper_limit,
@@ -168,6 +168,16 @@ async def test_set_motor_limits_error(
168168
await sim_motor.set(position)
169169

170170

171+
async def test_given_limits_of_0_0_then_move_causes_no_error(
172+
sim_motor: motor.Motor,
173+
):
174+
set_mock_value(sim_motor.velocity, 10)
175+
set_mock_value(sim_motor.low_limit_travel, 0)
176+
set_mock_value(sim_motor.high_limit_travel, 0)
177+
await sim_motor.set(100)
178+
assert (await sim_motor.user_setpoint.get_value()) == 100
179+
180+
171181
@pytest.mark.parametrize(
172182
"setpoint, velocity, timeout",
173183
[

0 commit comments

Comments
 (0)