mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-20 02:59:50 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
@@ -14,29 +14,29 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls {
|
.controls {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.connected {
|
.connected {
|
||||||
background-color: #d4edda;
|
background-color: #d4edda;
|
||||||
color: #155724;
|
color: #155724;
|
||||||
}
|
}
|
||||||
|
|
||||||
.disconnected {
|
.disconnected {
|
||||||
background-color: #f8d7da;
|
background-color: #f8d7da;
|
||||||
color: #721c24;
|
color: #721c24;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
background-color: #4CAF50;
|
background-color: #4CAF50;
|
||||||
@@ -46,27 +46,27 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
button:hover {
|
||||||
background-color: #45a049;
|
background-color: #45a049;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:disabled {
|
button:disabled {
|
||||||
background-color: #cccccc;
|
background-color: #cccccc;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#canvas-container {
|
#canvas-container {
|
||||||
flex: 3;
|
flex: 3;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
#sidebar {
|
#sidebar {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
@@ -75,22 +75,22 @@
|
|||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
border-left: 1px solid #ddd;
|
border-left: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.joint-info {
|
.joint-info {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.joint-name {
|
.joint-name {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.joint-value {
|
.joint-value {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bar-container {
|
.bar-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: #e0e0e0;
|
background-color: #e0e0e0;
|
||||||
@@ -99,14 +99,14 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bar {
|
.bar {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #4CAF50;
|
background-color: #4CAF50;
|
||||||
width: 0%;
|
width: 0%;
|
||||||
transition: width 0.2s ease-in-out;
|
transition: width 0.2s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-container {
|
.log-container {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
@@ -117,14 +117,14 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
background-color: #f8f9fa;
|
background-color: #f8f9fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-controls {
|
.view-controls {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-button {
|
.view-button {
|
||||||
background-color: rgba(0, 0, 0, 0.5);
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
color: white;
|
color: white;
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
</select>
|
</select>
|
||||||
<span id="statusIndicator" class="status disconnected">Status: Disconnected</span>
|
<span id="statusIndicator" class="status disconnected">Status: Disconnected</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="canvas-container">
|
<div id="canvas-container">
|
||||||
<!-- 3D canvas will be inserted here -->
|
<!-- 3D canvas will be inserted here -->
|
||||||
@@ -160,23 +160,23 @@
|
|||||||
<button class="view-button" id="resetView">Reset</button>
|
<button class="view-button" id="resetView">Reset</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<h3>Joint Values</h3>
|
<h3>Joint Values</h3>
|
||||||
<div id="jointsContainer">
|
<div id="jointsContainer">
|
||||||
<!-- Joint info will be added here -->
|
<!-- Joint info will be added here -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="log-container" id="logContainer">
|
<div class="log-container" id="logContainer">
|
||||||
<!-- Log messages will be added here -->
|
<!-- Log messages will be added here -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Import Three.js -->
|
<!-- Import Three.js -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/controls/OrbitControls.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/controls/OrbitControls.js"></script>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ function initializeJointElements() {
|
|||||||
// Calibration controls
|
// Calibration controls
|
||||||
const calibRow = document.createElement('div');
|
const calibRow = document.createElement('div');
|
||||||
calibRow.className = 'calib-row';
|
calibRow.className = 'calib-row';
|
||||||
|
|
||||||
const resetCalibBtn = document.createElement('button');
|
const resetCalibBtn = document.createElement('button');
|
||||||
resetCalibBtn.textContent = 'Reset Calib';
|
resetCalibBtn.textContent = 'Reset Calib';
|
||||||
resetCalibBtn.className = 'calib-btn';
|
resetCalibBtn.className = 'calib-btn';
|
||||||
@@ -208,11 +208,11 @@ function initializeJointElements() {
|
|||||||
observedMax[i] = -Infinity;
|
observedMax[i] = -Infinity;
|
||||||
addLogMessage(`Reset calibration for ${fingerName} ${jointType}`);
|
addLogMessage(`Reset calibration for ${fingerName} ${jointType}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const calibStatus = document.createElement('span');
|
const calibStatus = document.createElement('span');
|
||||||
calibStatus.className = 'calib-status';
|
calibStatus.className = 'calib-status';
|
||||||
calibStatus.textContent = `Range: --`;
|
calibStatus.textContent = `Range: --`;
|
||||||
|
|
||||||
calibRow.appendChild(resetCalibBtn);
|
calibRow.appendChild(resetCalibBtn);
|
||||||
calibRow.appendChild(calibStatus);
|
calibRow.appendChild(calibStatus);
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ function initializeJointElements() {
|
|||||||
ui.slider.disabled = connected;
|
ui.slider.disabled = connected;
|
||||||
ui.slider.style.display = connected ? 'none' : '';
|
ui.slider.style.display = connected ? 'none' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset calibration when connecting
|
// Reset calibration when connecting
|
||||||
if (connected) {
|
if (connected) {
|
||||||
observedMin.fill(Infinity);
|
observedMin.fill(Infinity);
|
||||||
@@ -299,20 +299,20 @@ async function readSerialData() {
|
|||||||
while ((idx = inputBuffer.indexOf('\n')) !== -1) {
|
while ((idx = inputBuffer.indexOf('\n')) !== -1) {
|
||||||
const line = inputBuffer.slice(0, idx).trim();
|
const line = inputBuffer.slice(0, idx).trim();
|
||||||
inputBuffer = inputBuffer.slice(idx + 1);
|
inputBuffer = inputBuffer.slice(idx + 1);
|
||||||
|
|
||||||
const vals = line.split(/\s+/).map(v => parseInt(v, 10));
|
const vals = line.split(/\s+/).map(v => parseInt(v, 10));
|
||||||
if (vals.length === MAX_JOINTS && vals.every(v => Number.isFinite(v))) {
|
if (vals.length === MAX_JOINTS && vals.every(v => Number.isFinite(v))) {
|
||||||
for (let i = 0; i < MAX_JOINTS; i++) {
|
for (let i = 0; i < MAX_JOINTS; i++) {
|
||||||
const info = fingerJointMap[i];
|
const info = fingerJointMap[i];
|
||||||
if (!info) continue;
|
if (!info) continue;
|
||||||
|
|
||||||
let rawValue = vals[i];
|
let rawValue = vals[i];
|
||||||
|
|
||||||
// Update calibration tracking
|
// Update calibration tracking
|
||||||
if (calibrationEnabled) {
|
if (calibrationEnabled) {
|
||||||
observedMin[i] = Math.min(observedMin[i], rawValue);
|
observedMin[i] = Math.min(observedMin[i], rawValue);
|
||||||
observedMax[i] = Math.max(observedMax[i], rawValue);
|
observedMax[i] = Math.max(observedMax[i], rawValue);
|
||||||
|
|
||||||
// Update calibration display
|
// Update calibration display
|
||||||
const ui = uiRefs[i];
|
const ui = uiRefs[i];
|
||||||
if (ui && ui.calibStatus) {
|
if (ui && ui.calibStatus) {
|
||||||
@@ -320,7 +320,7 @@ async function readSerialData() {
|
|||||||
ui.calibStatus.textContent = `Range: ${observedMin[i]}-${observedMax[i]}`;
|
ui.calibStatus.textContent = `Range: ${observedMin[i]}-${observedMax[i]}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remap observed range to target range
|
// Remap observed range to target range
|
||||||
if (observedMin[i] !== Infinity && observedMax[i] !== -Infinity && observedMax[i] > observedMin[i]) {
|
if (observedMin[i] !== Infinity && observedMax[i] !== -Infinity && observedMax[i] > observedMin[i]) {
|
||||||
const observedRange = observedMax[i] - observedMin[i];
|
const observedRange = observedMax[i] - observedMin[i];
|
||||||
@@ -329,7 +329,7 @@ async function readSerialData() {
|
|||||||
rawValue = info.min + (normalizedValue * targetRange);
|
rawValue = info.min + (normalizedValue * targetRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let v = clamp(rawValue, info.min, info.max);
|
let v = clamp(rawValue, info.min, info.max);
|
||||||
if (info.inverted) v = (info.min + info.max) - v;
|
if (info.inverted) v = (info.min + info.max) - v;
|
||||||
jointValues[i] = v;
|
jointValues[i] = v;
|
||||||
|
|||||||
Reference in New Issue
Block a user