Skip to content

Commit 9625450

Browse files
committed
Updated for Tornado
1 parent 725deb1 commit 9625450

File tree

18 files changed

+1354
-38
lines changed

18 files changed

+1354
-38
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
.DS_Store
4+
server/public
5+
vite.config.ts.*
6+
*.tar.gz

donkeycar/utilities/TrackSpeedPlanner/.replit

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
modules = ["nodejs-20", "web", "postgresql-16"]
1+
modules = ["nodejs-20", "web", "postgresql-16", "python-3.11"]
22
run = "npm run dev"
33
hidden = [".config", ".git", "generated-icon.png", "node_modules", "dist"]
44

@@ -14,6 +14,10 @@ run = ["npm", "run", "start"]
1414
localPort = 5000
1515
externalPort = 80
1616

17+
[[ports]]
18+
localPort = 5001
19+
externalPort = 3000
20+
1721
[workflows]
1822
runButton = "Project"
1923

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Quick Start Guide - Raspberry Pi Deployment
2+
3+
## For Donkey Car Path Data Editor
4+
5+
### 1. Copy to Pi
6+
```bash
7+
scp -r . pi@your-pi-ip:/home/pi/path-editor/
8+
```
9+
10+
### 2. Deploy
11+
```bash
12+
ssh pi@your-pi-ip
13+
cd /home/pi/path-editor
14+
chmod +x deploy-pi-tornado.sh
15+
./deploy-pi-tornado.sh
16+
```
17+
18+
### 3. Start Server
19+
```bash
20+
./trackeditor.sh
21+
```
22+
23+
### 4. Access
24+
Open browser: `http://your-pi-ip:5000`
25+
26+
### 5. Stop Server
27+
- Use Exit button in web interface
28+
- Or press Ctrl+C in terminal
29+
30+
---
31+
32+
## Features
33+
- Upload CSV path files (drag & drop)
34+
- Interactive path visualization
35+
- Edit speed values by clicking points
36+
- Export modified CSV files
37+
- Works on all Pi models (Zero to Pi 5)
38+
39+
## Files Included
40+
- `server-tornado.py` - Main Python server
41+
- `trackeditor.sh` - Simple startup script
42+
- `deploy-pi-tornado.sh` - Installation script
43+
- `static/index.html` - Complete web interface
44+
- `uninstall-pi.sh` - Cleanup script
45+
46+
## Troubleshooting
47+
- **Server won't start**: Check `python3 --version` (need 3.6+)
48+
- **Can't access**: Use Pi's actual IP, not localhost
49+
- **Tornado missing**: Run `python3 -m pip install --user tornado`

donkeycar/utilities/TrackSpeedPlanner/README-RaspberryPi.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,37 @@ This guide helps you deploy the Path Data Visualizer & Editor on a Raspberry Pi
2424
./deploy-pi-simple.sh
2525
```
2626

27-
3. **Access your application:**
27+
*Note: The deployment script automatically cleans up any previous installation.*
28+
29+
## Reinstalling or Updating
30+
31+
If you need to reinstall or had a previous version installed:
32+
33+
1. **Clean uninstall (optional):**
34+
```bash
35+
chmod +x uninstall-pi.sh
36+
./uninstall-pi.sh
37+
```
38+
39+
2. **Then run the deployment script normally**
40+
41+
The deployment script automatically handles cleanup, but you can manually uninstall first if needed.
42+
43+
3. **Start the server manually:**
44+
```bash
45+
python3 start-server.py
46+
```
47+
48+
4. **Access your application:**
2849
Open a browser and go to: `http://your-pi-ip:5000`
2950

3051
## What the deployment script does:
3152

3253
- Installs Node.js 20 if not present
3354
- Installs project dependencies
3455
- Builds the application with ESM compatibility fixes
35-
- Creates a systemd service for auto-start
36-
- Starts the service and enables it to run on boot
56+
- Creates manual start scripts (no auto-start on boot)
57+
- Provides both Python and shell script options
3758

3859
## Manual Setup (if script fails)
3960

@@ -55,15 +76,16 @@ This guide helps you deploy the Path Data Visualizer & Editor on a Raspberry Pi
5576

5677
4. **Start manually:**
5778
```bash
79+
python3 start-server.py
80+
# OR
5881
NODE_ENV=production PORT=5000 node dist/start-production.js
5982
```
6083

61-
## Service Management
84+
## Starting the Server
6285

63-
- **Check status:** `sudo systemctl status path-editor`
64-
- **View logs:** `sudo journalctl -u path-editor -f`
65-
- **Restart:** `sudo systemctl restart path-editor`
66-
- **Stop:** `sudo systemctl stop path-editor`
86+
- **Python launcher:** `python3 start-server.py` (recommended)
87+
- **Shell script:** `./start-server.sh`
88+
- **Direct Node.js:** `NODE_ENV=production PORT=5000 node dist/start-production.js`
6789

6890
## Network Access
6991

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Tornado Python Server Deployment for Raspberry Pi
2+
3+
This is a Python-based alternative to the Node.js deployment, using the Tornado web server that's already available on most Raspberry Pi systems.
4+
5+
## Why Use Tornado Version? (Recommended)
6+
7+
- **No Node.js required**: Uses existing Python environment on Pi
8+
- **Lightweight**: Better performance on all Pi models including Pi Zero
9+
- **Minimal dependencies**: Only requires Python and Tornado (usually pre-installed)
10+
- **Faster setup**: No compilation or build steps needed
11+
- **Same functionality**: Full CSV upload, editing, and export features
12+
- **Identical UI**: Same web interface as Node.js version
13+
- **Better reliability**: Python's stability on embedded systems
14+
15+
## Quick Deployment
16+
17+
1. **Copy files to your Pi:**
18+
```bash
19+
scp -r . pi@your-pi-ip:/home/pi/path-editor/
20+
```
21+
22+
2. **SSH into your Pi and run Tornado deployment:**
23+
```bash
24+
ssh pi@your-pi-ip
25+
cd /home/pi/path-editor
26+
chmod +x deploy-pi-tornado.sh
27+
./deploy-pi-tornado.sh
28+
```
29+
30+
3. **Start the server:**
31+
```bash
32+
./trackeditor.sh
33+
# OR
34+
python3 server-tornado.py
35+
```
36+
37+
4. **Access your application:**
38+
Open browser: `http://your-pi-ip:5000`
39+
40+
## Features
41+
42+
- **CSV Upload**: Drag-and-drop or browse for path data files
43+
- **Interactive Visualization**: Canvas-based path display with speed colors
44+
- **Speed Editing**: Click points to adjust speed values (0.1-1.0)
45+
- **CSV Export**: Download modified path data
46+
- **Exit Button**: Clean server shutdown via web interface
47+
- **Mobile Responsive**: Works on phones and tablets
48+
49+
## File Structure
50+
51+
```
52+
path-editor/
53+
├── server-tornado.py # Main Tornado web server
54+
├── start-tornado.py # Startup script
55+
├── deploy-pi-tornado.sh # Deployment script
56+
├── static/
57+
│ └── index.html # Complete web interface
58+
└── uninstall-pi.sh # Cleanup script
59+
```
60+
61+
## Manual Setup
62+
63+
If the deployment script fails:
64+
65+
1. **Install dependencies:**
66+
```bash
67+
python3 -m pip install --user tornado
68+
```
69+
70+
2. **Run server directly:**
71+
```bash
72+
python3 server-tornado.py --port=5000
73+
```
74+
75+
## Server Options
76+
77+
The Tornado server supports command-line options:
78+
79+
```bash
80+
python3 server-tornado.py --port=5000 --debug
81+
```
82+
83+
Options:
84+
- `--port=PORT`: Server port (default: 5000)
85+
- `--debug`: Enable debug mode with auto-reload
86+
87+
## API Endpoints
88+
89+
- `GET /`: Main application interface
90+
- `POST /api/upload`: CSV file upload
91+
- `POST /api/export`: CSV file export
92+
- `POST /api/shutdown`: Server shutdown
93+
- `GET /api/health`: Health check
94+
95+
## Performance Notes
96+
97+
- **Raspberry Pi Zero/1**: Works but may be slow with large files
98+
- **Raspberry Pi 2/3**: Good performance for typical donkey car paths
99+
- **Raspberry Pi 4+**: Excellent performance, handles large datasets
100+
101+
## Troubleshooting
102+
103+
### Server Won't Start
104+
```bash
105+
# Check Python version (3.6+ required)
106+
python3 --version
107+
108+
# Install Tornado if missing
109+
python3 -m pip install --user tornado
110+
111+
# Check if port is in use
112+
sudo netstat -tlnp | grep :5000
113+
```
114+
115+
### Can't Access from Network
116+
```bash
117+
# Check Pi's IP address
118+
hostname -I
119+
120+
# Test locally first
121+
curl http://localhost:5000/api/health
122+
123+
# Check firewall (if enabled)
124+
sudo ufw status
125+
```
126+
127+
### Memory Issues
128+
```bash
129+
# Check available memory
130+
free -h
131+
132+
# For large CSV files, consider splitting them
133+
# Or use Pi 4 with more RAM
134+
```
135+
136+
## Comparison with Node.js Version
137+
138+
| Feature | Tornado | Node.js |
139+
|---------|---------|---------|
140+
| Setup Time | Faster | Slower |
141+
| Dependencies | Minimal | Many |
142+
| Memory Usage | Lower | Higher |
143+
| Performance | Good | Excellent |
144+
| Compatibility | All Pi models | Pi 3+ recommended |
145+
146+
## Integration with Donkey Car
147+
148+
The Tornado version is ideal for donkey car integration:
149+
150+
1. **Lightweight**: Runs alongside other Pi services
151+
2. **Quick Start**: No compilation, instant startup
152+
3. **Reliable**: Python's stability on Pi systems
153+
4. **Portable**: Easy to backup and restore
154+
155+
## Development
156+
157+
To modify the server:
158+
159+
1. Edit `server-tornado.py` for backend changes
160+
2. Edit `static/index.html` for frontend changes
161+
3. Restart server to see changes
162+
163+
The server includes auto-reload in debug mode:
164+
```bash
165+
python3 server-tornado.py --debug
166+
```

donkeycar/utilities/TrackSpeedPlanner/client/src/pages/path-editor.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
11
import { useState } from "react";
2-
import { Route } from "lucide-react";
2+
import { Route, Power } from "lucide-react";
33
import { PathDataPoint } from "@shared/schema";
44
import { FileUpload } from "@/components/file-upload";
55
import { PathCanvas } from "@/components/path-canvas";
66
import { SpeedControls } from "@/components/speed-controls";
7+
import { Button } from "@/components/ui/button";
8+
import { useToast } from "@/hooks/use-toast";
9+
import { apiRequest } from "@/lib/queryClient";
710

811
export default function PathEditor() {
912
const [pathData, setPathData] = useState<PathDataPoint[]>([]);
1013
const [selectedPointIndex, setSelectedPointIndex] = useState(-1);
1114
const [fileName, setFileName] = useState<string>("");
15+
const { toast } = useToast();
1216

1317
const handleDataLoaded = (data: PathDataPoint[], loadedFileName: string) => {
1418
setPathData(data);
1519
setFileName(loadedFileName);
1620
setSelectedPointIndex(-1);
1721
};
1822

23+
const handleShutdown = async () => {
24+
try {
25+
toast({
26+
title: "Shutting down server...",
27+
description: "The server will stop in a few seconds.",
28+
});
29+
30+
await apiRequest('POST', '/api/shutdown');
31+
} catch (error) {
32+
// Expected error since server shuts down before response
33+
setTimeout(() => {
34+
window.location.href = 'about:blank';
35+
}, 2000);
36+
}
37+
};
38+
1939
const handleSpeedChange = (index: number, newSpeed: number) => {
2040
const updatedData = [...pathData];
2141
updatedData[index] = { ...updatedData[index], speed: newSpeed };
@@ -45,6 +65,15 @@ export default function PathEditor() {
4565
<Route className="text-primary text-2xl mr-3 w-8 h-8" />
4666
<h1 className="text-xl font-semibold text-gray-900">Path Data Visualizer & Editor</h1>
4767
</div>
68+
<Button
69+
variant="outline"
70+
size="sm"
71+
onClick={handleShutdown}
72+
className="flex items-center gap-2 text-red-600 border-red-200 hover:bg-red-50 hover:border-red-300"
73+
>
74+
<Power className="w-4 h-4" />
75+
Exit
76+
</Button>
4877
</div>
4978
</div>
5079
</header>

0 commit comments

Comments
 (0)