fix: 修复接待任务位置比较逻辑并硬编码默认位置
移除从 MQTT 消息动态获取接待位置,改为硬编码为"前台"。引入位置字符串规范化函数,用于统一比较接待任务中的位置信息,避免因空格、大小写或特殊字符导致的匹配失败。同时调整问候语触发逻辑,在接待任务期间即使未到达指定位置也禁用默认问候。
This commit is contained in:
@@ -415,7 +415,8 @@ class MainActivity : AppCompatActivity(), OnRobotReadyListener, TtsListener, OnG
|
||||
taskController.handlePatrolArrival(location)
|
||||
}
|
||||
if (taskController.currentTask == "reception" &&
|
||||
location.equals(taskController.getReceptionLocation(), ignoreCase = true)
|
||||
robotEventHandler.normalizeLocation(location) ==
|
||||
robotEventHandler.normalizeLocation(taskController.getReceptionLocation())
|
||||
) {
|
||||
captureReceptionAnchorYawIfNeeded()
|
||||
taskController.startTaskWaitTimeout()
|
||||
@@ -785,7 +786,9 @@ class MainActivity : AppCompatActivity(), OnRobotReadyListener, TtsListener, OnG
|
||||
if (taskController.currentTask != "reception") {
|
||||
return
|
||||
}
|
||||
val atReceptionLocation = lastArrivalLocation?.equals(taskController.getReceptionLocation(), ignoreCase = true) == true
|
||||
val atReceptionLocation =
|
||||
robotEventHandler.normalizeLocation(lastArrivalLocation) ==
|
||||
robotEventHandler.normalizeLocation(taskController.getReceptionLocation())
|
||||
if (!atReceptionLocation) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ class MqttManager(
|
||||
}
|
||||
"reception" -> {
|
||||
speak("接到接待任务", "zh")
|
||||
val location = obj.optString("location", "前台").trim()
|
||||
val location = "前台"
|
||||
val text = obj.optString("text", "你是我要接待的贵宾吗?").trim()
|
||||
val destination = obj.optString("destination", "会议室").trim()
|
||||
scope.launch(Dispatchers.Main) {
|
||||
|
||||
@@ -15,6 +15,15 @@ class TaskController(
|
||||
private val setEmoji: (AnimatedEmojiView.Expression) -> Unit,
|
||||
private val setReceptionButtonVisible: (Boolean) -> Unit
|
||||
) {
|
||||
private fun normalizeLocation(value: String?): String {
|
||||
return value.orEmpty()
|
||||
.trim()
|
||||
.lowercase()
|
||||
.replace(" ", "")
|
||||
.replace("_", "")
|
||||
.replace("-", "")
|
||||
}
|
||||
|
||||
var currentTask: String = ""
|
||||
private set
|
||||
|
||||
@@ -185,11 +194,11 @@ class TaskController(
|
||||
return true
|
||||
}
|
||||
if (currentTask == "reception") {
|
||||
val isAtReceptionLocation = getLastArrivalLocation()?.trim()
|
||||
?.equals(receptionLocation, ignoreCase = true) == true
|
||||
val isAtReceptionLocation =
|
||||
normalizeLocation(getLastArrivalLocation()) == normalizeLocation(receptionLocation)
|
||||
if (!isAtReceptionLocation) {
|
||||
// Not at reception spot yet, let upper layer continue default behavior.
|
||||
return false
|
||||
// Keep default greeting disabled during reception even before arriving at spot.
|
||||
return true
|
||||
}
|
||||
when (state) {
|
||||
DETECTED -> {
|
||||
|
||||
Reference in New Issue
Block a user