feat(web-platform): release V0.7.1 数据模块
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (pull_request) Has been cancelled
web-platform-ci / Playwright E2E (pull_request) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (pull_request) Has been cancelled
web-platform-ci / Playwright E2E (pull_request) Has been cancelled
This commit is contained in:
@@ -43,6 +43,7 @@ import {
|
||||
type UrdfLoadMode,
|
||||
} from '../simulation/PhysicsAdapter';
|
||||
import type { ActuatorParameters } from '../simulation/SimulationSession';
|
||||
import type { DataRecorderConfig } from '../simulation/DataRecorder';
|
||||
import type { ControllerCommand, ControllerStatus } from '../controller/types';
|
||||
import type { RLCommand, RLPolicyStatus } from '../rl/types';
|
||||
import type { MuJoCoViewer, InteractionMode, ViewerTheme } from '../viewer/MuJoCoViewer';
|
||||
@@ -1328,6 +1329,42 @@ export function App() {
|
||||
setPolicyStatus(undefined);
|
||||
state.setSnapshot(adapter.current.snapshot() ?? undefined);
|
||||
};
|
||||
const configureDataRecorder = (patch: Partial<DataRecorderConfig>) => {
|
||||
try {
|
||||
adapter.current.configureDataRecorder(patch);
|
||||
state.setSnapshot(adapter.current.snapshot() ?? undefined);
|
||||
} catch (error) {
|
||||
state.setDiagnostic(diagnostic('仿真', error, state.selectedEntry));
|
||||
}
|
||||
};
|
||||
const startDataRecording = () => {
|
||||
adapter.current.startDataRecording();
|
||||
state.setSnapshot(adapter.current.snapshot() ?? undefined);
|
||||
};
|
||||
const stopDataRecording = () => {
|
||||
adapter.current.stopDataRecording();
|
||||
state.setSnapshot(adapter.current.snapshot() ?? undefined);
|
||||
};
|
||||
const clearDataRecording = () => {
|
||||
adapter.current.clearDataRecording();
|
||||
state.setSnapshot(adapter.current.snapshot() ?? undefined);
|
||||
};
|
||||
const exportDataRecording = (format: 'csv' | 'json') => {
|
||||
try {
|
||||
const stem =
|
||||
(manifest.current?.name ?? 'simulation')
|
||||
.replace(/\.(?:zip|xml|urdf)$/i, '')
|
||||
.replace(/[^\p{L}\p{N}._-]+/gu, '_') || 'simulation';
|
||||
downloadBytes(
|
||||
adapter.current.exportDataRecording(format),
|
||||
`${stem}-telemetry.${format}`,
|
||||
format === 'csv' ? 'text/csv' : 'application/json',
|
||||
);
|
||||
notify(`遥测 ${format.toUpperCase()} 已导出`, `${stem}-telemetry.${format}`);
|
||||
} catch (error) {
|
||||
state.setDiagnostic(diagnostic('仿真', error, state.selectedEntry));
|
||||
}
|
||||
};
|
||||
const notify = (
|
||||
title: string,
|
||||
detail: string,
|
||||
@@ -1769,6 +1806,11 @@ export function App() {
|
||||
setLeftOpen(true);
|
||||
setProjectSidebarTab('assets');
|
||||
}}
|
||||
onDataRecorderConfigure={configureDataRecorder}
|
||||
onDataRecordingStart={startDataRecording}
|
||||
onDataRecordingStop={stopDataRecording}
|
||||
onDataRecordingClear={clearDataRecording}
|
||||
onDataRecordingExport={exportDataRecording}
|
||||
/>
|
||||
</div>
|
||||
{pendingUrdfPath && (
|
||||
|
||||
Reference in New Issue
Block a user