优化了副驾座椅控制
This commit is contained in:
@@ -74,6 +74,9 @@ class LocalIntentParserTests(unittest.TestCase):
|
||||
"把主驾和副驾温度都设为24度",
|
||||
"风量调到2档",
|
||||
"设置主驾出风模式为吹脸",
|
||||
"把副驾车窗移动到30%",
|
||||
"将主驾空调温度设置为24度",
|
||||
"把遮阳帘转动到20%",
|
||||
)
|
||||
for utterance in utterances:
|
||||
with self.subTest(utterance=utterance):
|
||||
@@ -159,6 +162,128 @@ class LocalIntentParserTests(unittest.TestCase):
|
||||
self.assertEqual(result["actions"][0]["position_pct"], 65)
|
||||
self.assertEqual(result["actions"][0]["motion_intent"]["direction"], "decrease")
|
||||
|
||||
def test_parses_passenger_directional_relative_percentages(self) -> None:
|
||||
context = self.motion_context()
|
||||
for state in context["devices"]["passenger"]["position"].values():
|
||||
state["position_pct"] = 50
|
||||
cases = (
|
||||
("副驾座椅往上移动10%", "cushion_tilt", "decrease", 10),
|
||||
("副驾座椅往上移动20%", "cushion_tilt", "decrease", 20),
|
||||
("副驾往下移动10%", "cushion_tilt", "increase", 10),
|
||||
("副驾往下移动20%", "cushion_tilt", "increase", 20),
|
||||
("副驾座椅往前移动10%", "longitudinal", "decrease", 10),
|
||||
("副驾座椅往前移动20%", "longitudinal", "decrease", 20),
|
||||
("副驾往后移动10%", "longitudinal", "increase", 10),
|
||||
("副驾往后移动20%", "longitudinal", "increase", 20),
|
||||
("副驾座椅靠背往前移动10%", "backrest_recline", "decrease", 10),
|
||||
("副驾座椅靠背往前移动30%", "backrest_recline", "decrease", 30),
|
||||
("副驾靠背往后移动10%", "backrest_recline", "increase", 10),
|
||||
("副驾靠背往后移动30%", "backrest_recline", "increase", 30),
|
||||
("副驾推托往上移动20%", "legrest_height", "increase", 20),
|
||||
("副驾推托往上移动40%", "legrest_height", "increase", 40),
|
||||
("副驾推托往下移动20%", "legrest_height", "decrease", 20),
|
||||
("副驾推托往下移动40%", "legrest_height", "decrease", 40),
|
||||
)
|
||||
|
||||
for utterance, axis, direction, delta in cases:
|
||||
with self.subTest(utterance=utterance):
|
||||
result = parse_local_intent(utterance, context)
|
||||
|
||||
self.assertEqual(result["ambiguities"], [])
|
||||
self.assertEqual(len(result["actions"]), 1)
|
||||
action = result["actions"][0]
|
||||
self.assertEqual(action["axis"], axis)
|
||||
self.assertEqual(action["motion_intent"]["mode"], "relative")
|
||||
self.assertEqual(action["motion_intent"]["direction"], direction)
|
||||
self.assertEqual(action["motion_intent"]["delta_position_pct"], delta)
|
||||
|
||||
def test_motion_verbs_are_weak_signals_for_relative_seat_controls(self) -> None:
|
||||
context = self.motion_context()
|
||||
for state in context["devices"]["passenger"]["position"].values():
|
||||
state["position_pct"] = 50
|
||||
cases = (
|
||||
("副驾座椅往前移动10%", "longitudinal", "decrease", 10),
|
||||
("副驾靠背往后转动20%", "backrest_recline", "increase", 20),
|
||||
("副驾腿托往上调节30%", "legrest_height", "increase", 30),
|
||||
("副驾座椅高度往下设置10%", "cushion_tilt", "increase", 10),
|
||||
("副驾靠背转动往前20%", "backrest_recline", "decrease", 20),
|
||||
("副驾腿托设置往下30%", "legrest_height", "decrease", 30),
|
||||
("副驾靠背往后旋转10度", "backrest_recline", "increase", 10),
|
||||
)
|
||||
|
||||
for utterance, axis, direction, amount in cases:
|
||||
with self.subTest(utterance=utterance):
|
||||
result = parse_local_intent(utterance, context)
|
||||
|
||||
self.assertEqual(result["ambiguities"], [])
|
||||
self.assertEqual(len(result["actions"]), 1)
|
||||
action = result["actions"][0]
|
||||
self.assertEqual(action["axis"], axis)
|
||||
self.assertEqual(action["motion_intent"]["mode"], "relative")
|
||||
self.assertEqual(action["motion_intent"]["direction"], direction)
|
||||
motion = action["motion_intent"]
|
||||
requested = motion.get("requested_delta_angle_deg")
|
||||
if requested is None:
|
||||
requested = motion.get("requested_delta_position_pct")
|
||||
if requested is None:
|
||||
requested = motion.get(
|
||||
"delta_angle_deg", motion.get("delta_position_pct")
|
||||
)
|
||||
self.assertEqual(requested, amount)
|
||||
|
||||
def test_directional_move_to_percentage_is_absolute_not_relative(self) -> None:
|
||||
cases = (
|
||||
("副驾座椅往上移动到10%", "cushion_tilt", 10),
|
||||
("副驾座椅往上移动到20%", "cushion_tilt", 20),
|
||||
("副驾往下移动到10%", "cushion_tilt", 10),
|
||||
("副驾往下移动到20%", "cushion_tilt", 20),
|
||||
("副驾座椅往前移动到10%", "longitudinal", 10),
|
||||
("副驾座椅往前移动到20%", "longitudinal", 20),
|
||||
("副驾往后移动到10%", "longitudinal", 10),
|
||||
("副驾往后移动到20%", "longitudinal", 20),
|
||||
("副驾座椅靠背往前移动到10%", "backrest_recline", 10),
|
||||
("副驾座椅靠背往前移动到30%", "backrest_recline", 30),
|
||||
("副驾靠背往后移动到10%", "backrest_recline", 10),
|
||||
("副驾靠背往后移动到30%", "backrest_recline", 30),
|
||||
("副驾推托往上移动到20%", "legrest_height", 20),
|
||||
("副驾推托往上移动到40%", "legrest_height", 40),
|
||||
("副驾推托往下移动到20%", "legrest_height", 20),
|
||||
("副驾推托往下移动到40%", "legrest_height", 40),
|
||||
)
|
||||
|
||||
for utterance, axis, position in cases:
|
||||
with self.subTest(utterance=utterance):
|
||||
result = parse_local_intent(utterance, self.motion_context())
|
||||
|
||||
self.assertEqual(result["ambiguities"], [])
|
||||
self.assertEqual(len(result["actions"]), 1)
|
||||
action = result["actions"][0]
|
||||
self.assertEqual(action["axis"], axis)
|
||||
self.assertEqual(action["position_pct"], position)
|
||||
self.assertNotIn("motion_intent", action)
|
||||
|
||||
def test_motion_verbs_with_position_markers_are_absolute(self) -> None:
|
||||
cases = (
|
||||
("副驾滑轨移动至60%", "longitudinal", 60),
|
||||
("副驾靠背转动到30%", "backrest_recline", 30),
|
||||
("副驾腿托调节至40%", "legrest_height", 40),
|
||||
("副驾座椅高度设置为20%", "cushion_tilt", 20),
|
||||
("副驾靠背往后转动到35%", "backrest_recline", 35),
|
||||
("副驾腿托往上设置为45%", "legrest_height", 45),
|
||||
("副驾靠背旋转到130度", "backrest_recline", 51),
|
||||
)
|
||||
|
||||
for utterance, axis, position in cases:
|
||||
with self.subTest(utterance=utterance):
|
||||
result = parse_local_intent(utterance, self.motion_context())
|
||||
|
||||
self.assertEqual(result["ambiguities"], [])
|
||||
self.assertEqual(len(result["actions"]), 1)
|
||||
action = result["actions"][0]
|
||||
self.assertEqual(action["axis"], axis)
|
||||
self.assertEqual(action["position_pct"], position)
|
||||
self.assertNotIn("motion_intent", action)
|
||||
|
||||
def test_rejects_relative_motion_without_state_and_clamps_endpoint_overflow(self) -> None:
|
||||
missing = parse_local_intent("靠背向前移动10度")
|
||||
context = self.motion_context()
|
||||
|
||||
Reference in New Issue
Block a user