feat: CommandPublishGate - chi publish mot lenh zero Twist khi tha dieu khien, them icon cua so

Truoc: publish lien tuc kha ca zero Twist theo timer -> de ghi de /cmd_vel cua publisher khac
khi joystick khong dieu khien. CommandPublishGate: lenh khac-zero publish binh thuong theo chu
ky; ve zero thi publish DUNG MOT LAN roi im, chi publish lai khi co lenh khac-zero moi.
UI: dat className "VirtualJoystickTeleop" cho WM_CLASS (truoc dung chung "Tk" voi moi app Tk
khac, bi gom lan trong taskbar/window picker) + ve icon joystick 32x32 khong can file ngoai.
This commit is contained in:
2026-09-22 15:32:00 +07:00
parent 4d0ade7c6d
commit 6c9f77eaae
7 changed files with 98 additions and 13 deletions

View File

@@ -2,7 +2,28 @@
import unittest
from virtual_joystick_teleop import TeleopModel
from virtual_joystick_teleop import CommandPublishGate, TeleopModel
class CommandPublishGateTest(unittest.TestCase):
def test_idle_is_silent_after_exactly_one_zero_transition(self):
gate = CommandPublishGate()
self.assertFalse(gate.allow_command(0.0, 0.0))
self.assertTrue(gate.allow_command(0.3, 0.0))
self.assertTrue(gate.allow_command(0.3, 0.0))
self.assertTrue(gate.allow_command(0.0, 0.0))
self.assertFalse(gate.allow_command(0.0, 0.0))
self.assertFalse(gate.allow_command(0.0, 0.0))
def test_stop_is_once_unless_explicitly_forced(self):
gate = CommandPublishGate()
gate.allow_command(0.0, 0.7)
self.assertTrue(gate.allow_stop())
self.assertFalse(gate.allow_stop())
self.assertTrue(gate.allow_stop(force=True))
self.assertFalse(gate.allow_stop())
class TeleopModelTest(unittest.TestCase):