From 7a03fc03adcfdb022d3da22c91fc6df5f8d3f89d Mon Sep 17 00:00:00 2001 From: Zhenbiao Huang Date: Thu, 2 May 2024 16:02:09 +0800 Subject: [PATCH] modified navigation; add joystick visible switch --- src/components/amr-control/MapCreate.vue | 4 +- src/components/amr-control/MapSelector.vue | 6 +-- src/components/amr-control/RobotRelocate.vue | 15 +++++- src/components/amr-control/RosMap2d.vue | 52 ++++++++++---------- src/components/amr-control/RosMapPixi.js | 30 ++++++++++- src/components/ros/JoyStick.vue | 25 ++++++---- src/pages/AmrControl.vue | 4 -- src/pages/JoystickPage.vue | 6 +-- src/pages/RosService.vue | 4 -- 9 files changed, 88 insertions(+), 58 deletions(-) diff --git a/src/components/amr-control/MapCreate.vue b/src/components/amr-control/MapCreate.vue index 61ff4d0..9b9bd92 100644 --- a/src/components/amr-control/MapCreate.vue +++ b/src/components/amr-control/MapCreate.vue @@ -31,6 +31,6 @@ function saveMap () { diff --git a/src/components/amr-control/MapSelector.vue b/src/components/amr-control/MapSelector.vue index d92b9a9..9da12fb 100644 --- a/src/components/amr-control/MapSelector.vue +++ b/src/components/amr-control/MapSelector.vue @@ -23,7 +23,7 @@ function selectMap () { - - diff --git a/src/components/amr-control/RobotRelocate.vue b/src/components/amr-control/RobotRelocate.vue index cb06563..654e527 100644 --- a/src/components/amr-control/RobotRelocate.vue +++ b/src/components/amr-control/RobotRelocate.vue @@ -12,19 +12,29 @@ watch(visible, value => { }) const mapManager = inject('mapManager') + // 重定位置 mapManager.changePose = (pos) => { tempPose.value.position.x = pos.x tempPose.value.position.y = pos.y - mapManager.updateRobotPose(tempPose.value) + if (isNavigate.value) { + mapManager.updateTargetPose(tempPose.value) + } else { + mapManager.updateRobotPose(tempPose.value) + } clicked.value = true } + // 重定方向 mapManager.changeTheta = (pos) => { const theta = Math.atan2(pos.y - tempPose.value.position.y, pos.x - tempPose.value.position.x) tempPose.value.orientation.z = Math.sin(theta / 2) tempPose.value.orientation.w = Math.cos(theta / 2) - mapManager.updateRobotPose(tempPose.value) + if (isNavigate.value) { + mapManager.updateTargetPose(tempPose.value) + } else { + mapManager.updateRobotPose(tempPose.value) + } clicked.value = true } @@ -66,6 +76,7 @@ const publish = inject('publish') function close () { mapManager.changeLocation = false mapManager.changeDirection = false + mapManager.removeTarget() if (clicked.value) { if (isNavigate.value) { diff --git a/src/components/amr-control/RosMap2d.vue b/src/components/amr-control/RosMap2d.vue index 144023b..6e90ad5 100644 --- a/src/components/amr-control/RosMap2d.vue +++ b/src/components/amr-control/RosMap2d.vue @@ -47,32 +47,34 @@ const robotRelocate = ref() - - diff --git a/src/pages/JoystickPage.vue b/src/pages/JoystickPage.vue index ddf5fbc..83fd765 100644 --- a/src/pages/JoystickPage.vue +++ b/src/pages/JoystickPage.vue @@ -18,10 +18,6 @@ onUnmounted(() => { - - diff --git a/src/pages/RosService.vue b/src/pages/RosService.vue index b2374c9..bdf74cc 100644 --- a/src/pages/RosService.vue +++ b/src/pages/RosService.vue @@ -56,7 +56,3 @@ async function call () { - -