Transform real-time desktop mouse cursor movements into canonical ROS 2 velocity commands (geometry_msgs/msg/Twist) for physical and simulated mobile robots.
Quickstart โข Architecture โข Control Mapping โข Simulation โข Documentation
teleop-cursor provides an ultra-lightweight, zero-hardware teleoperation node for ROS 2 (rclpy). Instead of requiring dedicated joysticks or cumbersome keyboard combinations, teleop-cursor tracks your screen cursor position relative to display center, translating cursor displacement vectors into smooth linear (/cmd_vel topic.
Whether you are testing autonomous mobile robots (AMRs), validating navigation pipelines in Gazebo, or demonstrating robot movements, teleop-cursor turns any standard workstation display into a responsive teleoperation interface.
- ๐ Instant Teleoperation: Zero hardware joysticks requiredโteleoperate directly using your mouse or trackpad.
-
๐ Dominant Axis Switching: Automatically calculates magnitude deltas (
$\Delta X, \Delta Y$ ) to distinguish between turning and driving forward/backward. -
๐ค ROS 2 Native: Built on
rclpyand standardgeometry_msgs/msg/Twistpayloads, ensuring 100% compatibility with TurtleBot3, Nav2, and custom robot controllers. -
๐ฏ Dynamic Resolution Handling: Dynamically queries monitor dimensions using
pyautogui, auto-centering controls on any resolution (1080p, 4K, ultrawide). - โฑ๏ธ Real-Time Stream: Operates at a steady 10 Hz control callback frequency with minimal CPU overhead.
-
๐ฆ pip Installable: Available on PyPI โ install with a single
pip install teleop-cursorcommand.
The diagram below demonstrates how host screen cursor events flow through the system to actuate simulated or physical ROS 2 robots:
graph LR
A[Host Display Cursor] -->|X, Y Coordinates| B[PyAutoGUI Interface]
B -->|Screen Offset ฮX, ฮY| C[CursorFollowNode]
subgraph Signal Processing Loop 10Hz
C --> D{Dominant Axis?}
D -->|"abs(ฮX) > abs(ฮY)"| E[Compute Angular Yaw Speed ฯz]
D -->|"abs(ฮY) >= abs(ฮX)"| F[Compute Linear Speed vx]
E --> G[Construct Twist Message]
F --> G
end
G -->|Publish| H((/cmd_vel Topic))
H --> I[TurtleBot3 Gazebo Sim]
H --> J[Physical Mobile Robot]
For complete mathematical details and signal transformations, see docs/ARCHITECTURE.md.
The host display is divided into four primary directional control regions anchored to screen center
โฒ FORWARD (+vx = 0.2 m/s)
โ [|ฮY| >= |ฮX|]
โ
LEFT โโโโโโโโโโโผโโโโโโโโโโบ RIGHT
(ฯz = +1.0 rad/s) โ (ฯz = -1.0 rad/s)
[|ฮX| > |ฮY|] โ [|ฮX| > |ฮY|]
โ
โผ BACKWARD (-vx = -0.2 m/s)
[|ฮY| >= |ฮX|]
| Cursor Displacement | Robot Action |
linear.x (m/s) |
angular.z (rad/s) |
|---|---|---|---|
| Top Half ($ | \Delta Y | \ge | \Delta X |
| Bottom Half ($ | \Delta Y | \ge | \Delta X |
| Left Side ($ | \Delta X | > | \Delta Y |
| Right Side ($ | \Delta X | > | \Delta Y |
Ensure you have a working installation of ROS 2 (Humble, Iron, Jazzy, or Rolling) and Python 3.10+:
# Source your ROS 2 environment
source /opt/ros/$ROS_DISTRO/setup.bashpip install teleop-cursor
teleop-cursorgit clone https://github.com/gaminization/teleop-cursor.git
cd teleop-cursor
pip install -e .
teleop-cursormkdir -p ~/ros2_ws/src && cd ~/ros2_ws/src
git clone https://github.com/gaminization/teleop-cursor.git
cd ~/ros2_ws && colcon build --packages-select teleop_cursor
source install/setup.bash
ros2 run teleop_cursor teleop-cursorgit clone https://github.com/gaminization/teleop-cursor.git
cd teleop-cursor
python3 cursor.pyMove your mouse across your screen to stream velocity commands to your robot!
To test teleop-cursor with TurtleBot3 inside Gazebo:
# Terminal 1: Launch Gazebo Simulation World
export TURTLEBOT3_MODEL=waffle
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
# Terminal 2: Run via pip CLI
teleop-cursor
# Or via ros2 run (after colcon build)
ros2 run teleop_cursor teleop-cursorFor complete simulation launching and debugging guides, see docs/DEVELOPMENT.md.
The node parameters in cursor.py can be easily tuned:
| Parameter | Type | Default | Description |
|---|---|---|---|
max_linear_speed |
float |
0.2 |
Maximum linear speed limit ( |
max_angular_speed |
float |
1.0 |
Maximum angular speed limit ( |
timer frequency |
float |
0.1 (10 Hz) |
Publish rate period in seconds |
teleop-cursor/
โโโ teleop_cursor/ # Pip-installable Python package
โ โโโ __init__.py # Package initialisation & exports
โ โโโ cursor.py # CursorFollowNode ROS 2 node implementation
โโโ resource/ # ROS 2 ament_index resource marker
โ โโโ teleop_cursor
โโโ cursor.py # Backward-compatible script wrapper
โโโ package.xml # ROS 2 ament_python package manifest
โโโ pyproject.toml # PEP 517/518 build system & metadata
โโโ setup.py # Setuptools config (colcon + pip)
โโโ LICENSE # MIT Open Source License
โโโ README.md # Primary repository landing page
โโโ CHANGELOG.md # Version history & release notes
โโโ CONTRIBUTING.md # Open-source contribution & PR guide
โโโ TIMELINE.md # Project roadmap & release milestones
โโโ SECURITY.md # Security & physical robot safety policies
โโโ docs/
โโโ ARCHITECTURE.md # Deep-dive architecture & transformation math
โโโ DEVELOPMENT.md # Developer setup, testing & simulation guide
- ๐ Technical Architecture: Deep dive into signal processing math, coordinate frame transformations, sequence diagrams, and message definitions.
- ๐ป Developer Guide: Workspace setup, colcon building, linting rules (
black/flake8), and ROS 2 debugging utilities. - ๐ค Contributing Guidelines: Standard PR workflows, Conventional Commit requirements, and issue reporting.
- ๐บ๏ธ Project Timeline & Roadmap: Milestone progression, release history, and feature roadmap (proportional control, deadband overlay).
- ๐ Changelog: Formal release logs adhering to Keep a Changelog.
- ๐ Security Policy: Safety standards for teleoperating physical mobile hardware.
This project is open-source software licensed under the MIT License.