From 8c7d5deae9e2b0e2976419d0882b4c3784a067a0 Mon Sep 17 00:00:00 2001 From: SkyLi Date: Sun, 7 Jun 2026 02:17:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=95=E7=9B=98=E6=8E=A7=E5=88=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=94=B9=E4=B8=BA=20BASE=5FSPEED=20=E5=92=8C=20YAW=5F?= =?UTF-8?q?VELOCITY=EF=BC=8C=E7=9B=B4=E6=8E=A5=E5=8F=91=E5=B8=83=E7=BA=BF?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E5=92=8C=E8=A7=92=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MAX_LINEAR/MAX_ANGULAR/WHEEL_SEPARATION → BASE_SPEED/YAW_VELOCITY - CMD_WHEEL_TOPIC 话题名改为 /cmd_chassis - 移除前端轮速差计算,发布 [linear, angular] 由底盘自行解算左右轮速 --- src/config.js | 7 +++---- src/views/ManualMode.vue | 22 +++++++++------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/config.js b/src/config.js index aa8f381..847e27b 100644 --- a/src/config.js +++ b/src/config.js @@ -8,12 +8,11 @@ export const MJPEG_MANUAL_URL = 'http://192.168.0.11/stream?topic=/vision/result export const MJPEG_DEBUG_URL = 'http://192.168.0.11/stream?topic=/vision/debug_image&mode=debug' // ROS 话题 -export const CMD_WHEEL_TOPIC = '/cmd_wheel' +export const CMD_WHEEL_TOPIC = '/cmd_chassis' export const CMD_GIMBAL_TOPIC = '/cmd_gimbal' // 键盘控制参数 -export const MAX_LINEAR = 0.5 // m/s -export const MAX_ANGULAR = 1.0 // rad/s -export const WHEEL_SEPARATION = 0.2 // 轮距(m) +export const BASE_SPEED = 0.5 // 直线基础速度 +export const YAW_VELOCITY = 1.0 // 角度速率,度每秒 // 云台角度速率 (度/秒) export const GIMBAL_PITCH_DEG_S = 10 diff --git a/src/views/ManualMode.vue b/src/views/ManualMode.vue index e25af1a..807a23b 100644 --- a/src/views/ManualMode.vue +++ b/src/views/ManualMode.vue @@ -24,7 +24,7 @@ import { onBeforeRouteLeave } from 'vue-router' import { MJPEG_MANUAL_URL, ROSBRIDGE_URL, CMD_WHEEL_TOPIC, CMD_GIMBAL_TOPIC, - MAX_LINEAR, MAX_ANGULAR, WHEEL_SEPARATION, + BASE_SPEED, YAW_VELOCITY, GIMBAL_PITCH_DEG_S, GIMBAL_YAW_DEG_S, API_GIMBAL_MODE_SWITCH, API_CHASSIS_MODE_SWITCH, API_LASER, } from '../config.js' @@ -38,7 +38,7 @@ connect(ROSBRIDGE_URL) const pressed = new Set() const laserOn = ref(false) let animId = null -let lastVel = { left: 0, right: 0, pitch: 0, yaw: 0 } +let lastVel = { linear: 0, angular: 0, pitch: 0, yaw: 0 } function onKeyDown(e) { if (['KeyW','KeyA','KeyS','KeyD','ArrowUp','ArrowDown','ArrowLeft','ArrowRight'].includes(e.code)) { @@ -59,33 +59,29 @@ function onKeyUp(e) { } function computeVelocities() { - const linear = (pressed.has('KeyW') ? MAX_LINEAR : 0) - (pressed.has('KeyS') ? MAX_LINEAR : 0) - const angular = (pressed.has('KeyA') ? MAX_ANGULAR : 0) - (pressed.has('KeyD') ? MAX_ANGULAR : 0) + const linear = (pressed.has('KeyW') ? BASE_SPEED : 0) - (pressed.has('KeyS') ? BASE_SPEED : 0) + const angular = (pressed.has('KeyA') ? YAW_VELOCITY : 0) - (pressed.has('KeyD') ? YAW_VELOCITY : 0) const pitch = (pressed.has('ArrowDown') ? GIMBAL_PITCH_DEG_S : 0) - (pressed.has('ArrowUp') ? GIMBAL_PITCH_DEG_S : 0) const yaw = (pressed.has('ArrowLeft') ? GIMBAL_YAW_DEG_S : 0) - (pressed.has('ArrowRight') ? GIMBAL_YAW_DEG_S : 0) - const halfSep = WHEEL_SEPARATION / 2 - const left = linear - angular * halfSep - const right = linear + angular * halfSep - - return { left, right, pitch, yaw } + return { linear, angular, pitch, yaw } } function startLoop() { function tick() { - const { left, right, pitch, yaw } = computeVelocities() - const changed = left !== lastVel.left || right !== lastVel.right || pitch !== lastVel.pitch || yaw !== lastVel.yaw + const { linear, angular, pitch, yaw } = computeVelocities() + const changed = linear !== lastVel.linear || angular !== lastVel.angular || pitch !== lastVel.pitch || yaw !== lastVel.yaw if (changed) { publish(CMD_WHEEL_TOPIC, 'std_msgs/Float32MultiArray', { - data: [left, right], + data: [linear, angular], layout: { dim: [], data_offset: 0 }, }) publish(CMD_GIMBAL_TOPIC, 'geometry_msgs/Twist', { linear: { x: 0, y: 0, z: 0 }, angular: { x: 0, y: pitch, z: yaw }, }) - lastVel = { left, right, pitch, yaw } + lastVel = { linear, angular, pitch, yaw } } if (pressed.size === 0) {