TensorFleet Drone JS Project
JavaScript/Node.js template for drone control over rosbridge using roslib. Includes an OFFBOARD velocity guided mover driven by a mission plan.
Requirements
Install Bun (v1.0.0+)
curl -fsSL https://bun.sh/install | bash
Quick start
- Install JavaScript dependencies:
bun install - Open
Simulation viewandMap View. - Start your VM, then run:
bun run restart- Restart the simulation (resets drone state)bun drone:mover- ARM → TAKEOFF → OFFBOARD waypoint mission → LAND
Scripts
check-runtime.js: Runtime compatibility checker. Verifies your JavaScript runtime (Bun or Node.js) supports modern syntax features like optional chaining. Runbun run checkornpm run checkif you encounter syntax errors. Provides specific troubleshooting steps if issues are detected.src/restart_sim.js: Restart the PX4 simulation via/simulation_manager/start_simulationservice. Useful for resetting drone state between test runs.src/drone_mover.js: Complete autonomous mission: ARM → TAKEOFF → OFFBOARD → fly waypoints frommissions/example_mission.plan→ return home → LAND. Falls back to 8-point circle pattern if mission plan is missing. Uses env orconfig/drone_config.yaml(offboardsection) for tuning.
Tutorials
Learn drone control step-by-step with focused examples:
Beginner (getting started):
bun run tutorial:01- Connect to rosbridge and read drone statebun run tutorial:02- Display all telemetry (position, GPS, battery)bun run tutorial:03- Send ARM/DISARM command
Intermediate (basic flight):
4. bun run tutorial:04 - Takeoff to altitude and land (complete flight cycle)
5. bun run tutorial:05 - Enter OFFBOARD mode and hover
Advanced (autonomous navigation):
6. bun run tutorial:06 - Move forward using velocity control
7. bun run tutorial:07 - Navigate to waypoint with position feedback
Each tutorial is ~50-100 lines and demonstrates one concept clearly. See src/tutorials/ for source code.
Documentation
- Tutorials Overview - Complete tutorial index and navigation
- Technical Reference - Detailed technical implementation details, ROS/MAVROS internals, and API documentation
- Configuration Guide - Comprehensive setup guide for connection methods, proxy configuration, and troubleshooting
- Simulation Guide - PX4 simulation setup and management
- TensorFleet Util - tensorfleet-util package documentation and API reference
Configuration
Edit config/drone_config.yaml or override via env vars:
TENSORFLEET_BASE_URL+TENSORFLEET_JWT- primary TensorFleet connection (other URLs are derived automatically when blank)ROSBRIDGE_URL- rosbridge WebSocket URLSETPOINT_FRAME_ID- frame for setpoints (defaultmap)ALT_TARGET,EDGE_M,V_FAST,V_MIN,WAYPOINT_RADIUS,SLOW_RADIUS,SETPOINT_HZ,R2B_HOST,R2B_PORT- OFFBOARD tuning fordrone_mover.js(defaults favor a small world: ~1m alt, ~5m hop, gentle velocities)MISSION_PLAN_PATH- override the plan file used bydrone_mover.js(defaults tomissions/example_mission.plan) Theoffboardsection in the YAML mirrors the environment overrides fordrone_mover.js.
Layout
.
|-- src/
| |-- tutorials/ # Step-by-step learning scripts
| |-- lib/ # Shared utilities
| |-- drone_mover.js # Advanced mission example
| `-- restart_sim.js # Simulation restart utility
|-- config/ # Network + flight config
|-- missions/ # Example mission plans
|-- launch/ # Optional ROS 2 launch files
|-- package.json
`-- README.md
Tips
- New to drone control? Start with the tutorials (
bun run tutorial:01throughtutorial:07) - rosbridge runs in the VM; no local ROS 2 binaries needed
- Use
bun run restartto reset simulation between test runs - Verify connectivity with
src/drone_mover.jsfor full autonomous mission