Initial commit
This commit is contained in:
338
srcs/RobotNet10/RobotApp/RobotNet10.RobotApp/Desktop
Executable file
338
srcs/RobotNet10/RobotApp/RobotNet10.RobotApp/Desktop
Executable file
@@ -0,0 +1,338 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Odometry Comparison Test</title>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/8.0.0/signalr.min.js"></script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: white;
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
font-size: 2.5em;
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
.controls {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
button {
|
||||
background: linear-gradient(135deg, #667eea, #764ba2);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 12px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
button:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
#status {
|
||||
flex: 1;
|
||||
font-weight: 600;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.status-disconnected { background: #fee; color: #c33; }
|
||||
.status-connecting { background: #ffeaa7; color: #d63031; }
|
||||
.status-connected { background: #d5f4e6; color: #00b894; }
|
||||
|
||||
.comparison-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.odom-card {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.odom-card h2 {
|
||||
margin-bottom: 20px;
|
||||
color: #667eea;
|
||||
border-bottom: 3px solid #667eea;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.raw h2 { color: #e74c3c; border-bottom-color: #e74c3c; }
|
||||
.filtered h2 { color: #27ae60; border-bottom-color: #27ae60; }
|
||||
|
||||
.data-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 12px;
|
||||
margin: 8px 0;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
border-left: 4px solid #667eea;
|
||||
}
|
||||
|
||||
.raw .data-row { border-left-color: #e74c3c; }
|
||||
.filtered .data-row { border-left-color: #27ae60; }
|
||||
|
||||
.label {
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-family: 'Courier New', monospace;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.diff-card {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.diff-card h2 {
|
||||
margin-bottom: 20px;
|
||||
color: #f39c12;
|
||||
border-bottom: 3px solid #f39c12;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.diff-row {
|
||||
padding: 12px;
|
||||
margin: 8px 0;
|
||||
background: #fff3cd;
|
||||
border-radius: 6px;
|
||||
border-left: 4px solid #f39c12;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background: #fee;
|
||||
border-left-color: #e74c3c;
|
||||
color: #c33;
|
||||
}
|
||||
|
||||
.success {
|
||||
background: #d5f4e6;
|
||||
border-left-color: #27ae60;
|
||||
color: #00b894;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🤖 Odometry Comparison: Raw vs Filtered</h1>
|
||||
|
||||
<div class="controls">
|
||||
<button id="connectBtn" onclick="connect()">Connect</button>
|
||||
<button id="refreshBtn" onclick="refresh()" disabled>🔄 Refresh Data</button>
|
||||
<div id="status" class="status-disconnected">Disconnected</div>
|
||||
</div>
|
||||
|
||||
<div class="comparison-grid">
|
||||
<div class="odom-card raw">
|
||||
<h2>📊 RAW Odometry (Encoder Only)</h2>
|
||||
<div id="rawData">
|
||||
<div class="data-row"><span class="label">Position X:</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Position Y:</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Theta (yaw):</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Linear X:</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Angular Z:</span><span class="value">-</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="odom-card filtered">
|
||||
<h2>✨ FILTERED Odometry (EKF + Slip Detection)</h2>
|
||||
<div id="filteredData">
|
||||
<div class="data-row"><span class="label">Position X:</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Position Y:</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Theta (yaw):</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Linear X:</span><span class="value">-</span></div>
|
||||
<div class="data-row"><span class="label">Angular Z:</span><span class="value">-</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="diff-card">
|
||||
<h2>⚠️ Differences (Slip Impact)</h2>
|
||||
<div id="diffData">
|
||||
<div class="diff-row"><span class="label">ΔX:</span><span class="value">-</span></div>
|
||||
<div class="diff-row"><span class="label">ΔY:</span><span class="value">-</span></div>
|
||||
<div class="diff-row"><span class="label">Δθ:</span><span class="value">-</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let connection = null;
|
||||
let updateInterval = null;
|
||||
|
||||
async function connect() {
|
||||
const statusEl = document.getElementById('status');
|
||||
const connectBtn = document.getElementById('connectBtn');
|
||||
const refreshBtn = document.getElementById('refreshBtn');
|
||||
|
||||
try {
|
||||
statusEl.textContent = 'Connecting...';
|
||||
statusEl.className = 'status-connecting';
|
||||
connectBtn.disabled = true;
|
||||
|
||||
connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("https://0.0.0.0:7002/hubs/odometry", {
|
||||
skipNegotiation: true,
|
||||
transport: signalR.HttpTransportType.WebSockets
|
||||
})
|
||||
.withAutomaticReconnect()
|
||||
.build();
|
||||
|
||||
await connection.start();
|
||||
|
||||
statusEl.textContent = 'Connected ✓';
|
||||
statusEl.className = 'status-connected';
|
||||
refreshBtn.disabled = false;
|
||||
|
||||
// Auto refresh every 500ms
|
||||
updateInterval = setInterval(refresh, 500);
|
||||
refresh();
|
||||
|
||||
} catch (err) {
|
||||
console.error('Connection error:', err);
|
||||
statusEl.textContent = 'Connection failed: ' + err.message;
|
||||
statusEl.className = 'status-disconnected';
|
||||
connectBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
if (!connection) return;
|
||||
|
||||
try {
|
||||
const comparison = await connection.invoke("GetOdometryComparison");
|
||||
updateDisplay(comparison);
|
||||
} catch (err) {
|
||||
console.error('Refresh error:', err);
|
||||
}
|
||||
}
|
||||
|
||||
function updateDisplay(comparison) {
|
||||
const raw = comparison.raw;
|
||||
const filtered = comparison.filtered;
|
||||
|
||||
if (!raw || !filtered) return;
|
||||
|
||||
// Raw data
|
||||
const rawPos = raw.pose?.pose?.position || {};
|
||||
const rawOri = raw.pose?.pose?.orientation || {};
|
||||
const rawTwist = raw.twist?.twist || {};
|
||||
|
||||
document.querySelector('#rawData .data-row:nth-child(1) .value').textContent =
|
||||
(rawPos.x || 0).toFixed(3) + ' m';
|
||||
document.querySelector('#rawData .data-row:nth-child(2) .value').textContent =
|
||||
(rawPos.y || 0).toFixed(3) + ' m';
|
||||
document.querySelector('#rawData .data-row:nth-child(3) .value').textContent =
|
||||
quaternionToYaw(rawOri).toFixed(3) + ' rad';
|
||||
document.querySelector('#rawData .data-row:nth-child(4) .value').textContent =
|
||||
(rawTwist.linear?.x || 0).toFixed(3) + ' m/s';
|
||||
document.querySelector('#rawData .data-row:nth-child(5) .value').textContent =
|
||||
(rawTwist.angular?.z || 0).toFixed(3) + ' rad/s';
|
||||
|
||||
// Filtered data
|
||||
const filtPos = filtered.pose?.pose?.position || {};
|
||||
const filtOri = filtered.pose?.pose?.orientation || {};
|
||||
const filtTwist = filtered.twist?.twist || {};
|
||||
|
||||
document.querySelector('#filteredData .data-row:nth-child(1) .value').textContent =
|
||||
(filtPos.x || 0).toFixed(3) + ' m';
|
||||
document.querySelector('#filteredData .data-row:nth-child(2) .value').textContent =
|
||||
(filtPos.y || 0).toFixed(3) + ' m';
|
||||
document.querySelector('#filteredData .data-row:nth-child(3) .value').textContent =
|
||||
quaternionToYaw(filtOri).toFixed(3) + ' rad';
|
||||
document.querySelector('#filteredData .data-row:nth-child(4) .value').textContent =
|
||||
(filtTwist.linear?.x || 0).toFixed(3) + ' m/s';
|
||||
document.querySelector('#filteredData .data-row:nth-child(5) .value').textContent =
|
||||
(filtTwist.angular?.z || 0).toFixed(3) + ' rad/s';
|
||||
|
||||
// Differences
|
||||
const diffX = Math.abs((rawPos.x || 0) - (filtPos.x || 0));
|
||||
const diffY = Math.abs((rawPos.y || 0) - (filtPos.y || 0));
|
||||
const diffTheta = Math.abs(quaternionToYaw(rawOri) - quaternionToYaw(filtOri));
|
||||
|
||||
const diffRows = document.querySelectorAll('#diffData .diff-row');
|
||||
updateDiffRow(diffRows[0], 'ΔX:', diffX, 'm');
|
||||
updateDiffRow(diffRows[1], 'ΔY:', diffY, 'm');
|
||||
updateDiffRow(diffRows[2], 'Δθ:', diffTheta, 'rad');
|
||||
}
|
||||
|
||||
function updateDiffRow(row, label, value, unit) {
|
||||
row.querySelector('.label').textContent = label;
|
||||
row.querySelector('.value').textContent = value.toFixed(3) + ' ' + unit;
|
||||
|
||||
// Color code based on magnitude
|
||||
if (value > 0.5) {
|
||||
row.className = 'diff-row warning';
|
||||
} else if (value < 0.05) {
|
||||
row.className = 'diff-row success';
|
||||
} else {
|
||||
row.className = 'diff-row';
|
||||
}
|
||||
}
|
||||
|
||||
function quaternionToYaw(q) {
|
||||
if (!q) return 0;
|
||||
const sinYaw = 2.0 * (q.w * q.z + q.x * q.y);
|
||||
const cosYaw = 1.0 - 2.0 * (q.y * q.y + q.z * q.z);
|
||||
return Math.atan2(sinYaw, cosYaw);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user