Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Sync from huggingface/lerobot-dataset-visualizer via hub-sync
Browse files
AGENTS.md
CHANGED
|
@@ -127,7 +127,7 @@ Reserved/bookkeeping columns from lerobot β see `EXCLUDED_COLUMNS` in `src/uti
|
|
| 127 |
- v2.x: `timestamp`, `frame_index`, `episode_index`, `index`, `task_index`, `next.reward`, `next.done`, `next.truncated`
|
| 128 |
- v3.0: `index`, `task_index`, `episode_index`, `frame_index`, `next.reward`, `next.done`, `next.truncated`, `subtask_index`
|
| 129 |
|
| 130 |
-
## 3D Replay viewer (`src/components/
|
| 131 |
|
| 132 |
- Every robot is a USD from the dataset [`lerobot/robot-usds`](https://huggingface.co/datasets/lerobot/robot-usds) (SO-100 uses SO-101's), loaded with `@huggingface/usd-web-viewer`; no URDF is involved. `getRobotConfig` picks it from `robot_type` and, for the G1's hands, the columns.
|
| 133 |
- The USD's UsdPhysics joints move it: `setJointPositions` takes them by prim path, in degrees for revolute joints and meters for prismatic ones (the joint values here are radians), and throws on a value that isn't finite. Mimic joints (OpenArm's second finger, the Inspire fingers' outer joints) follow their joint, so they are left out of the mapping.
|
|
|
|
| 127 |
- v2.x: `timestamp`, `frame_index`, `episode_index`, `index`, `task_index`, `next.reward`, `next.done`, `next.truncated`
|
| 128 |
- v3.0: `index`, `task_index`, `episode_index`, `frame_index`, `next.reward`, `next.done`, `next.truncated`, `subtask_index`
|
| 129 |
|
| 130 |
+
## 3D Replay viewer (`src/components/replay-viewer.tsx`)
|
| 131 |
|
| 132 |
- Every robot is a USD from the dataset [`lerobot/robot-usds`](https://huggingface.co/datasets/lerobot/robot-usds) (SO-100 uses SO-101's), loaded with `@huggingface/usd-web-viewer`; no URDF is involved. `getRobotConfig` picks it from `robot_type` and, for the G1's hands, the columns.
|
| 133 |
- The USD's UsdPhysics joints move it: `setJointPositions` takes them by prim path, in degrees for revolute joints and meters for prismatic ones (the joint values here are radians), and throws on a value that isn't finite. Mimic joints (OpenArm's second finger, the Inspire fingers' outer joints) follow their joint, so they are left out of the mapping.
|
src/app/[org]/[dataset]/[episode]/episode-viewer.tsx
CHANGED
|
@@ -22,7 +22,7 @@ import Loading from "@/components/loading-component";
|
|
| 22 |
import HfAuthButton from "@/components/hf-auth-button";
|
| 23 |
import { EpisodeHeader, ThemeToggle } from "@/components/ui";
|
| 24 |
import { useTheme } from "@/utils/theme";
|
| 25 |
-
import {
|
| 26 |
import {
|
| 27 |
computeColumnMinMax,
|
| 28 |
getEpisodeDataSafe,
|
|
@@ -40,7 +40,7 @@ import { CHART_CONFIG } from "@/utils/constants";
|
|
| 40 |
import { parseInfo } from "@huggingface/lerobot";
|
| 41 |
import type { DatasetMetadata } from "@/utils/parquetUtils";
|
| 42 |
|
| 43 |
-
const
|
| 44 |
const HandReplay = lazy(() => import("@/components/hand-replay"));
|
| 45 |
const ActionInsightsPanel = lazy(
|
| 46 |
() => import("@/components/action-insights-panel"),
|
|
@@ -75,11 +75,16 @@ const TABS = [
|
|
| 75 |
"insights",
|
| 76 |
"filtering",
|
| 77 |
"doctor",
|
| 78 |
-
"
|
| 79 |
"hands",
|
| 80 |
] as const;
|
| 81 |
type ActiveTab = (typeof TABS)[number];
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
// Subscribes to `currentTime` so its parent doesn't have to. Keeping this
|
| 84 |
// in a leaf component means the throttled time ticks (~12.5/s during
|
| 85 |
// playback) only re-render this no-op sub-tree, not the entire 700-line
|
|
@@ -287,11 +292,11 @@ export default function EpisodeViewer({
|
|
| 287 |
// alongside the episode data, rather than once it has loaded and the viewer
|
| 288 |
// mounts. info.json is all it needs, and the episode load fetches it anyway.
|
| 289 |
useEffect(() => {
|
| 290 |
-
if (sessionStorage.getItem("activeTab") !== "
|
| 291 |
getDatasetVersionAndInfo(`${org}/${dataset}`)
|
| 292 |
.then(({ info }) => {
|
| 293 |
if (
|
| 294 |
-
|
| 295 |
info.codebase_version >= "v3.0"
|
| 296 |
) {
|
| 297 |
const { joints } = parseInfo(JSON.stringify(info));
|
|
@@ -300,7 +305,7 @@ export default function EpisodeViewer({
|
|
| 300 |
(n) => `${feature}${CHART_CONFIG.SERIES_NAME_DELIMITER}${n}`,
|
| 301 |
),
|
| 302 |
);
|
| 303 |
-
return import("@/components/
|
| 304 |
m.prefetchRobotModel(info.robot_type ?? null, columns),
|
| 305 |
);
|
| 306 |
}
|
|
@@ -451,8 +456,8 @@ function EpisodeViewerInner({
|
|
| 451 |
|
| 452 |
const router = useRouter();
|
| 453 |
|
| 454 |
-
const
|
| 455 |
-
|
| 456 |
datasetInfo.codebase_version >= "v3.0";
|
| 457 |
|
| 458 |
// Tab state & lazy stats β read sessionStorage in the initializer so the
|
|
@@ -460,18 +465,20 @@ function EpisodeViewerInner({
|
|
| 460 |
// Safe because EpisodeViewerInner only mounts client-side (behind a loading gate).
|
| 461 |
const [activeTab, setActiveTab] = useState<ActiveTab>(() => {
|
| 462 |
if (typeof window !== "undefined") {
|
| 463 |
-
const requested =
|
|
|
|
|
|
|
| 464 |
if (
|
| 465 |
TABS.includes(requested as ActiveTab) &&
|
| 466 |
(requested !== "hands" || data.handTracking) &&
|
| 467 |
-
(requested !== "
|
| 468 |
)
|
| 469 |
return requested as ActiveTab;
|
| 470 |
-
const stored = sessionStorage.getItem("activeTab");
|
| 471 |
/// A tab saved on another dataset may not exist here (3D Replay needs a supported robot).
|
| 472 |
if (
|
| 473 |
TABS.includes(stored as ActiveTab) &&
|
| 474 |
-
(stored !== "
|
| 475 |
(stored !== "hands" || data.handTracking)
|
| 476 |
) {
|
| 477 |
return stored as ActiveTab;
|
|
@@ -529,13 +536,13 @@ function EpisodeViewerInner({
|
|
| 529 |
setCrossEpData(null);
|
| 530 |
}, [datasetInfo.repoId]);
|
| 531 |
|
| 532 |
-
// Eagerly load the
|
| 533 |
// so the 3D Replay tab opens faster.
|
| 534 |
useEffect(() => {
|
| 535 |
-
if (
|
| 536 |
-
void import("@/components/
|
| 537 |
}
|
| 538 |
-
}, [
|
| 539 |
|
| 540 |
// Persist UI state across episode navigations. One effect instead of
|
| 541 |
// three near-identical writes β fewer commit hooks per render and the
|
|
@@ -648,11 +655,13 @@ function EpisodeViewerInner({
|
|
| 648 |
/// Passed to the embedded lerobot-doctor Space, which follows `__theme` like any HF Space.
|
| 649 |
const theme = useTheme();
|
| 650 |
|
| 651 |
-
//
|
| 652 |
-
const
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
|
|
|
|
|
|
| 656 |
|
| 657 |
// Pagination state
|
| 658 |
const pageSize = 100;
|
|
@@ -692,12 +701,12 @@ function EpisodeViewerInner({
|
|
| 692 |
|
| 693 |
// Mirror the values the keydown handler needs into a ref. Without this,
|
| 694 |
// `useCallback` would produce a new handler whenever `activeTab` /
|
| 695 |
-
// `episodeId` / `
|
| 696 |
// detach + reattach the listener each time. Now the listener attaches
|
| 697 |
// once and reads the latest state via the ref.
|
| 698 |
// Vercel rule: advanced-event-handler-refs.
|
| 699 |
-
const keyStateRef = useRef({ activeTab, episodeId, episodes,
|
| 700 |
-
keyStateRef.current = { activeTab, episodeId, episodes,
|
| 701 |
|
| 702 |
useEffect(() => {
|
| 703 |
const onKeyDown = (e: KeyboardEvent) => {
|
|
@@ -708,22 +717,22 @@ function EpisodeViewerInner({
|
|
| 708 |
if (key === " ") {
|
| 709 |
if (inTextEntry) return;
|
| 710 |
e.preventDefault();
|
| 711 |
-
if (s.activeTab === "
|
| 712 |
-
|
| 713 |
} else {
|
| 714 |
setIsPlaying((prev: boolean) => !prev);
|
| 715 |
}
|
| 716 |
} else if (key === "ArrowDown" || key === "ArrowUp") {
|
| 717 |
if (inTextEntry) return;
|
| 718 |
e.preventDefault();
|
| 719 |
-
if (s.activeTab === "
|
| 720 |
const nextEp =
|
| 721 |
-
key === "ArrowDown" ? s.
|
| 722 |
const lowest = s.episodes[0];
|
| 723 |
const highest = s.episodes[s.episodes.length - 1];
|
| 724 |
if (nextEp >= lowest && nextEp <= highest) {
|
| 725 |
-
|
| 726 |
-
|
| 727 |
}
|
| 728 |
} else {
|
| 729 |
const nextEpisodeId =
|
|
@@ -766,9 +775,9 @@ function EpisodeViewerInner({
|
|
| 766 |
title={title}
|
| 767 |
/// Hovering 3D Replay is a strong hint it's next; get the meshes going.
|
| 768 |
onPointerEnter={
|
| 769 |
-
tab === "
|
| 770 |
? () =>
|
| 771 |
-
void import("@/components/
|
| 772 |
m.prefetchRobotModel(
|
| 773 |
datasetInfo.robot_type,
|
| 774 |
Object.keys(data.flatChartData[0] ?? {}),
|
|
@@ -785,7 +794,7 @@ function EpisodeViewerInner({
|
|
| 785 |
{/* Top tab bar */}
|
| 786 |
<div className="relative z-30 flex items-center border-b border-line-subtle bg-[var(--surface-0)] shrink-0">
|
| 787 |
{renderTab("episodes", "Episodes")}
|
| 788 |
-
{
|
| 789 |
<AdvancedTabsMenu
|
| 790 |
activeTab={activeTab}
|
| 791 |
onSelect={handleTabChange}
|
|
@@ -803,11 +812,11 @@ function EpisodeViewerInner({
|
|
| 803 |
{(activeTab === "episodes" ||
|
| 804 |
activeTab === "annotations" ||
|
| 805 |
activeTab === "hands" ||
|
| 806 |
-
activeTab === "
|
| 807 |
<Sidebar
|
| 808 |
datasetInfo={datasetInfo}
|
| 809 |
paginatedEpisodes={paginatedEpisodes}
|
| 810 |
-
episodeId={activeTab === "
|
| 811 |
totalPages={totalPages}
|
| 812 |
currentPage={currentPage}
|
| 813 |
prevPage={prevPage}
|
|
@@ -815,10 +824,10 @@ function EpisodeViewerInner({
|
|
| 815 |
showFlaggedOnly={sidebarFlaggedOnly}
|
| 816 |
onShowFlaggedOnlyChange={setSidebarFlaggedOnly}
|
| 817 |
onEpisodeSelect={
|
| 818 |
-
activeTab === "
|
| 819 |
? (ep) => {
|
| 820 |
-
|
| 821 |
-
|
| 822 |
}
|
| 823 |
: activeTab === "annotations"
|
| 824 |
? (ep) => router.push(`./episode_${ep}`)
|
|
@@ -983,14 +992,14 @@ function EpisodeViewerInner({
|
|
| 983 |
</div>
|
| 984 |
)}
|
| 985 |
|
| 986 |
-
{activeTab === "
|
| 987 |
<Suspense fallback={<Loading />}>
|
| 988 |
-
<
|
| 989 |
data={data}
|
| 990 |
org={org}
|
| 991 |
dataset={dataset}
|
| 992 |
-
episodeChangerRef={
|
| 993 |
-
playToggleRef={
|
| 994 |
/>
|
| 995 |
</Suspense>
|
| 996 |
)}
|
|
|
|
| 22 |
import HfAuthButton from "@/components/hf-auth-button";
|
| 23 |
import { EpisodeHeader, ThemeToggle } from "@/components/ui";
|
| 24 |
import { useTheme } from "@/utils/theme";
|
| 25 |
+
import { hasRobotModel } from "@/lib/so101-robot";
|
| 26 |
import {
|
| 27 |
computeColumnMinMax,
|
| 28 |
getEpisodeDataSafe,
|
|
|
|
| 40 |
import { parseInfo } from "@huggingface/lerobot";
|
| 41 |
import type { DatasetMetadata } from "@/utils/parquetUtils";
|
| 42 |
|
| 43 |
+
const ReplayViewer = lazy(() => import("@/components/replay-viewer"));
|
| 44 |
const HandReplay = lazy(() => import("@/components/hand-replay"));
|
| 45 |
const ActionInsightsPanel = lazy(
|
| 46 |
() => import("@/components/action-insights-panel"),
|
|
|
|
| 75 |
"insights",
|
| 76 |
"filtering",
|
| 77 |
"doctor",
|
| 78 |
+
"replay",
|
| 79 |
"hands",
|
| 80 |
] as const;
|
| 81 |
type ActiveTab = (typeof TABS)[number];
|
| 82 |
|
| 83 |
+
/// 3D Replay's id was `urdf`, which links shared before still carry.
|
| 84 |
+
function tabId(tab: string | null): string | null {
|
| 85 |
+
return tab === "urdf" ? "replay" : tab;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
// Subscribes to `currentTime` so its parent doesn't have to. Keeping this
|
| 89 |
// in a leaf component means the throttled time ticks (~12.5/s during
|
| 90 |
// playback) only re-render this no-op sub-tree, not the entire 700-line
|
|
|
|
| 292 |
// alongside the episode data, rather than once it has loaded and the viewer
|
| 293 |
// mounts. info.json is all it needs, and the episode load fetches it anyway.
|
| 294 |
useEffect(() => {
|
| 295 |
+
if (tabId(sessionStorage.getItem("activeTab")) !== "replay") return;
|
| 296 |
getDatasetVersionAndInfo(`${org}/${dataset}`)
|
| 297 |
.then(({ info }) => {
|
| 298 |
if (
|
| 299 |
+
hasRobotModel(info.robot_type ?? null) &&
|
| 300 |
info.codebase_version >= "v3.0"
|
| 301 |
) {
|
| 302 |
const { joints } = parseInfo(JSON.stringify(info));
|
|
|
|
| 305 |
(n) => `${feature}${CHART_CONFIG.SERIES_NAME_DELIMITER}${n}`,
|
| 306 |
),
|
| 307 |
);
|
| 308 |
+
return import("@/components/replay-viewer").then((m) =>
|
| 309 |
m.prefetchRobotModel(info.robot_type ?? null, columns),
|
| 310 |
);
|
| 311 |
}
|
|
|
|
| 456 |
|
| 457 |
const router = useRouter();
|
| 458 |
|
| 459 |
+
const replaySupported =
|
| 460 |
+
hasRobotModel(datasetInfo.robot_type) &&
|
| 461 |
datasetInfo.codebase_version >= "v3.0";
|
| 462 |
|
| 463 |
// Tab state & lazy stats β read sessionStorage in the initializer so the
|
|
|
|
| 465 |
// Safe because EpisodeViewerInner only mounts client-side (behind a loading gate).
|
| 466 |
const [activeTab, setActiveTab] = useState<ActiveTab>(() => {
|
| 467 |
if (typeof window !== "undefined") {
|
| 468 |
+
const requested = tabId(
|
| 469 |
+
new URLSearchParams(window.location.search).get("tab"),
|
| 470 |
+
);
|
| 471 |
if (
|
| 472 |
TABS.includes(requested as ActiveTab) &&
|
| 473 |
(requested !== "hands" || data.handTracking) &&
|
| 474 |
+
(requested !== "replay" || replaySupported)
|
| 475 |
)
|
| 476 |
return requested as ActiveTab;
|
| 477 |
+
const stored = tabId(sessionStorage.getItem("activeTab"));
|
| 478 |
/// A tab saved on another dataset may not exist here (3D Replay needs a supported robot).
|
| 479 |
if (
|
| 480 |
TABS.includes(stored as ActiveTab) &&
|
| 481 |
+
(stored !== "replay" || replaySupported) &&
|
| 482 |
(stored !== "hands" || data.handTracking)
|
| 483 |
) {
|
| 484 |
return stored as ActiveTab;
|
|
|
|
| 536 |
setCrossEpData(null);
|
| 537 |
}, [datasetInfo.repoId]);
|
| 538 |
|
| 539 |
+
// Eagerly load the ReplayViewer bundle while the user is on the Episodes tab,
|
| 540 |
// so the 3D Replay tab opens faster.
|
| 541 |
useEffect(() => {
|
| 542 |
+
if (replaySupported) {
|
| 543 |
+
void import("@/components/replay-viewer");
|
| 544 |
}
|
| 545 |
+
}, [replaySupported]);
|
| 546 |
|
| 547 |
// Persist UI state across episode navigations. One effect instead of
|
| 548 |
// three near-identical writes β fewer commit hooks per render and the
|
|
|
|
| 655 |
/// Passed to the embedded lerobot-doctor Space, which follows `__theme` like any HF Space.
|
| 656 |
const theme = useTheme();
|
| 657 |
|
| 658 |
+
// ReplayViewer episode changer and play toggle β populated by ReplayViewer on mount
|
| 659 |
+
const replayChangerRef = useRef<((ep: number) => void) | undefined>(
|
| 660 |
+
undefined,
|
| 661 |
+
);
|
| 662 |
+
const replayPlayToggleRef = useRef<(() => void) | undefined>(undefined);
|
| 663 |
+
const [replayEpisode, setReplayEpisode] = useState(episodeId);
|
| 664 |
+
useEffect(() => setReplayEpisode(episodeId), [episodeId]);
|
| 665 |
|
| 666 |
// Pagination state
|
| 667 |
const pageSize = 100;
|
|
|
|
| 701 |
|
| 702 |
// Mirror the values the keydown handler needs into a ref. Without this,
|
| 703 |
// `useCallback` would produce a new handler whenever `activeTab` /
|
| 704 |
+
// `episodeId` / `replayEpisode` changed, and the keydown effect would
|
| 705 |
// detach + reattach the listener each time. Now the listener attaches
|
| 706 |
// once and reads the latest state via the ref.
|
| 707 |
// Vercel rule: advanced-event-handler-refs.
|
| 708 |
+
const keyStateRef = useRef({ activeTab, episodeId, episodes, replayEpisode });
|
| 709 |
+
keyStateRef.current = { activeTab, episodeId, episodes, replayEpisode };
|
| 710 |
|
| 711 |
useEffect(() => {
|
| 712 |
const onKeyDown = (e: KeyboardEvent) => {
|
|
|
|
| 717 |
if (key === " ") {
|
| 718 |
if (inTextEntry) return;
|
| 719 |
e.preventDefault();
|
| 720 |
+
if (s.activeTab === "replay") {
|
| 721 |
+
replayPlayToggleRef.current?.();
|
| 722 |
} else {
|
| 723 |
setIsPlaying((prev: boolean) => !prev);
|
| 724 |
}
|
| 725 |
} else if (key === "ArrowDown" || key === "ArrowUp") {
|
| 726 |
if (inTextEntry) return;
|
| 727 |
e.preventDefault();
|
| 728 |
+
if (s.activeTab === "replay") {
|
| 729 |
const nextEp =
|
| 730 |
+
key === "ArrowDown" ? s.replayEpisode + 1 : s.replayEpisode - 1;
|
| 731 |
const lowest = s.episodes[0];
|
| 732 |
const highest = s.episodes[s.episodes.length - 1];
|
| 733 |
if (nextEp >= lowest && nextEp <= highest) {
|
| 734 |
+
setReplayEpisode(nextEp);
|
| 735 |
+
replayChangerRef.current?.(nextEp);
|
| 736 |
}
|
| 737 |
} else {
|
| 738 |
const nextEpisodeId =
|
|
|
|
| 775 |
title={title}
|
| 776 |
/// Hovering 3D Replay is a strong hint it's next; get the meshes going.
|
| 777 |
onPointerEnter={
|
| 778 |
+
tab === "replay"
|
| 779 |
? () =>
|
| 780 |
+
void import("@/components/replay-viewer").then((m) =>
|
| 781 |
m.prefetchRobotModel(
|
| 782 |
datasetInfo.robot_type,
|
| 783 |
Object.keys(data.flatChartData[0] ?? {}),
|
|
|
|
| 794 |
{/* Top tab bar */}
|
| 795 |
<div className="relative z-30 flex items-center border-b border-line-subtle bg-[var(--surface-0)] shrink-0">
|
| 796 |
{renderTab("episodes", "Episodes")}
|
| 797 |
+
{replaySupported && renderTab("replay", "3D Replay")}
|
| 798 |
<AdvancedTabsMenu
|
| 799 |
activeTab={activeTab}
|
| 800 |
onSelect={handleTabChange}
|
|
|
|
| 812 |
{(activeTab === "episodes" ||
|
| 813 |
activeTab === "annotations" ||
|
| 814 |
activeTab === "hands" ||
|
| 815 |
+
activeTab === "replay") && (
|
| 816 |
<Sidebar
|
| 817 |
datasetInfo={datasetInfo}
|
| 818 |
paginatedEpisodes={paginatedEpisodes}
|
| 819 |
+
episodeId={activeTab === "replay" ? replayEpisode : episodeId}
|
| 820 |
totalPages={totalPages}
|
| 821 |
currentPage={currentPage}
|
| 822 |
prevPage={prevPage}
|
|
|
|
| 824 |
showFlaggedOnly={sidebarFlaggedOnly}
|
| 825 |
onShowFlaggedOnlyChange={setSidebarFlaggedOnly}
|
| 826 |
onEpisodeSelect={
|
| 827 |
+
activeTab === "replay"
|
| 828 |
? (ep) => {
|
| 829 |
+
setReplayEpisode(ep);
|
| 830 |
+
replayChangerRef.current?.(ep);
|
| 831 |
}
|
| 832 |
: activeTab === "annotations"
|
| 833 |
? (ep) => router.push(`./episode_${ep}`)
|
|
|
|
| 992 |
</div>
|
| 993 |
)}
|
| 994 |
|
| 995 |
+
{activeTab === "replay" && (
|
| 996 |
<Suspense fallback={<Loading />}>
|
| 997 |
+
<ReplayViewer
|
| 998 |
data={data}
|
| 999 |
org={org}
|
| 1000 |
dataset={dataset}
|
| 1001 |
+
episodeChangerRef={replayChangerRef}
|
| 1002 |
+
playToggleRef={replayPlayToggleRef}
|
| 1003 |
/>
|
| 1004 |
</Suspense>
|
| 1005 |
)}
|
src/app/[org]/[dataset]/[episode]/fetch-data.ts
CHANGED
|
@@ -2263,7 +2263,7 @@ export async function loadCrossEpisodeActionVariance(
|
|
| 2263 |
};
|
| 2264 |
}
|
| 2265 |
|
| 2266 |
-
// Load only flatChartData for a specific episode (used by
|
| 2267 |
export async function loadEpisodeFlatChartData(
|
| 2268 |
repoId: string,
|
| 2269 |
version: string,
|
|
|
|
| 2263 |
};
|
| 2264 |
}
|
| 2265 |
|
| 2266 |
+
// Load only flatChartData for a specific episode (used by the 3D Replay viewer's episode switching)
|
| 2267 |
export async function loadEpisodeFlatChartData(
|
| 2268 |
repoId: string,
|
| 2269 |
version: string,
|
src/components/{urdf-playback-bar.tsx β replay-playback-bar.tsx}
RENAMED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
import React from "react";
|
| 4 |
import { FaPlay, FaPause, FaArrowDown, FaArrowUp } from "react-icons/fa";
|
| 5 |
|
| 6 |
-
interface
|
| 7 |
frame: number;
|
| 8 |
totalFrames: number;
|
| 9 |
fps: number;
|
|
@@ -15,7 +15,7 @@ interface UrdfPlaybackBarProps {
|
|
| 15 |
disabled?: boolean;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
export default function
|
| 19 |
frame,
|
| 20 |
totalFrames,
|
| 21 |
fps,
|
|
@@ -25,7 +25,7 @@ export default function UrdfPlaybackBar({
|
|
| 25 |
onTrailToggle,
|
| 26 |
onFrameChange,
|
| 27 |
disabled = false,
|
| 28 |
-
}:
|
| 29 |
const currentTime = totalFrames > 0 ? (frame / fps).toFixed(2) : "0.00";
|
| 30 |
const totalTime = (totalFrames / fps).toFixed(2);
|
| 31 |
|
|
|
|
| 3 |
import React from "react";
|
| 4 |
import { FaPlay, FaPause, FaArrowDown, FaArrowUp } from "react-icons/fa";
|
| 5 |
|
| 6 |
+
interface ReplayPlaybackBarProps {
|
| 7 |
frame: number;
|
| 8 |
totalFrames: number;
|
| 9 |
fps: number;
|
|
|
|
| 15 |
disabled?: boolean;
|
| 16 |
}
|
| 17 |
|
| 18 |
+
export default function ReplayPlaybackBar({
|
| 19 |
frame,
|
| 20 |
totalFrames,
|
| 21 |
fps,
|
|
|
|
| 25 |
onTrailToggle,
|
| 26 |
onFrameChange,
|
| 27 |
disabled = false,
|
| 28 |
+
}: ReplayPlaybackBarProps) {
|
| 29 |
const currentTime = totalFrames > 0 ? (frame / fps).toFixed(2) : "0.00";
|
| 30 |
const totalTime = (totalFrames / fps).toFixed(2);
|
| 31 |
|
src/components/{urdf-viewer.tsx β replay-viewer.tsx}
RENAMED
|
@@ -22,7 +22,7 @@ import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
|
|
| 22 |
import { LineGeometry } from "three/examples/jsm/lines/LineGeometry.js";
|
| 23 |
import type { EpisodeData } from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
| 24 |
import { loadEpisodeFlatChartData } from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
| 25 |
-
import
|
| 26 |
import RobotLoader, { type LoaderRobot } from "@/components/robot-loader";
|
| 27 |
import { CHART_CONFIG } from "@/utils/constants";
|
| 28 |
import { getDatasetVersionAndInfo } from "@/utils/versionUtils";
|
|
@@ -730,7 +730,7 @@ function PlaybackDriver({
|
|
| 730 |
// IBL: procedural studio softboxes give mesh highlights somewhere to bounce.
|
| 731 |
// Not preset="studio": drei downloads that 1.6 MB HDR from raw.githack.com and
|
| 732 |
// suspends the canvas until it arrives. Module scope keeps the element's
|
| 733 |
-
// identity across
|
| 734 |
// the cube map and three re-runs PMREM whenever Environment's children change.
|
| 735 |
const STUDIO_ENVIRONMENT = (
|
| 736 |
<Environment resolution={256} background={false}>
|
|
@@ -766,9 +766,9 @@ const STUDIO_ENVIRONMENT = (
|
|
| 766 |
);
|
| 767 |
|
| 768 |
// βββββββββββββββββββββββββββββββββββββββ
|
| 769 |
-
// βββ Main
|
| 770 |
// βββββββββββββββββββββββββββββββββββββββ
|
| 771 |
-
export default function
|
| 772 |
data,
|
| 773 |
org,
|
| 774 |
dataset,
|
|
@@ -1137,7 +1137,7 @@ export default function URDFViewer({
|
|
| 1137 |
|
| 1138 |
{/* Controls */}
|
| 1139 |
<div className="bg-[var(--surface-1)]/90 border-t border-line p-3 space-y-3 shrink-0">
|
| 1140 |
-
<
|
| 1141 |
frame={frame}
|
| 1142 |
totalFrames={totalFrames}
|
| 1143 |
fps={fps}
|
|
|
|
| 22 |
import { LineGeometry } from "three/examples/jsm/lines/LineGeometry.js";
|
| 23 |
import type { EpisodeData } from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
| 24 |
import { loadEpisodeFlatChartData } from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
| 25 |
+
import ReplayPlaybackBar from "@/components/replay-playback-bar";
|
| 26 |
import RobotLoader, { type LoaderRobot } from "@/components/robot-loader";
|
| 27 |
import { CHART_CONFIG } from "@/utils/constants";
|
| 28 |
import { getDatasetVersionAndInfo } from "@/utils/versionUtils";
|
|
|
|
| 730 |
// IBL: procedural studio softboxes give mesh highlights somewhere to bounce.
|
| 731 |
// Not preset="studio": drei downloads that 1.6 MB HDR from raw.githack.com and
|
| 732 |
// suspends the canvas until it arrives. Module scope keeps the element's
|
| 733 |
+
// identity across ReplayViewer renders (one per playback frame): drei re-captures
|
| 734 |
// the cube map and three re-runs PMREM whenever Environment's children change.
|
| 735 |
const STUDIO_ENVIRONMENT = (
|
| 736 |
<Environment resolution={256} background={false}>
|
|
|
|
| 766 |
);
|
| 767 |
|
| 768 |
// βββββββββββββββββββββββββββββββββββββββ
|
| 769 |
+
// βββ Main 3D Replay viewer βββ
|
| 770 |
// βββββββββββββββββββββββββββββββββββββββ
|
| 771 |
+
export default function ReplayViewer({
|
| 772 |
data,
|
| 773 |
org,
|
| 774 |
dataset,
|
|
|
|
| 1137 |
|
| 1138 |
{/* Controls */}
|
| 1139 |
<div className="bg-[var(--surface-1)]/90 border-t border-line p-3 space-y-3 shrink-0">
|
| 1140 |
+
<ReplayPlaybackBar
|
| 1141 |
frame={frame}
|
| 1142 |
totalFrames={totalFrames}
|
| 1143 |
fps={fps}
|
src/lib/so101-robot.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function isG1Robot(robotType: string | null): boolean {
|
|
| 19 |
return lower.includes("g1") || lower.includes("unitree");
|
| 20 |
}
|
| 21 |
|
| 22 |
-
export function
|
| 23 |
return (
|
| 24 |
isSO101Robot(robotType) || isOpenArmRobot(robotType) || isG1Robot(robotType)
|
| 25 |
);
|
|
|
|
| 19 |
return lower.includes("g1") || lower.includes("unitree");
|
| 20 |
}
|
| 21 |
|
| 22 |
+
export function hasRobotModel(robotType: string | null): boolean {
|
| 23 |
return (
|
| 24 |
isSO101Robot(robotType) || isOpenArmRobot(robotType) || isG1Robot(robotType)
|
| 25 |
);
|