Skip to content

Commit 09e45df

Browse files
committed
Makre sure CameraStreams dont't get re-created constantly
1 parent c7d62dc commit 09e45df

File tree

2 files changed

+53
-47
lines changed

2 files changed

+53
-47
lines changed

pour/vinoweb/src/RobotApp.svelte

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,31 @@
5151
}
5252
const initialJoints = Array.from(jointGenerator()) as Joint[];
5353
54+
// --- $state-ful joint arrays ---
55+
let leftJoints = $state([...initialJoints]);
56+
let rightJoints = $state([...initialJoints]);
57+
5458
// --- Define panes data ---
55-
let panesData = $derived(
56-
status === "picking" ?
57-
[
58-
{
59-
joints: Array.from(initialJoints) as Joint[],
60-
tableTitle: "Left Arm",
61-
camera: {
62-
name: "cam-left",
63-
partID: "xxx",
64-
label: "Left Camera",
65-
},
66-
},
67-
] :
68-
[
69-
{
70-
joints: Array.from(initialJoints) as Joint[],
71-
tableTitle: "Left Arm",
72-
camera: {
73-
name: "cam-left",
74-
partID: "xxx",
75-
label: "Left Camera",
76-
},
77-
},
78-
{
79-
joints: Array.from(initialJoints) as Joint[],
80-
tableTitle: "Right Arm",
81-
camera: {
82-
name: "cam-right",
83-
partID: "xxx",
84-
label: "Right Camera",
85-
},
59+
let panesData = $state([
60+
{
61+
joints: leftJoints,
62+
tableTitle: "Left Arm",
63+
camera: {
64+
name: "cam-left",
65+
partID: "xxx",
66+
label: "Left Camera",
67+
},
68+
},
69+
{
70+
joints: rightJoints,
71+
tableTitle: "Right Arm",
72+
camera: {
73+
name: "cam-right",
74+
partID: "xxx",
75+
label: "Right Camera",
8676
},
87-
])
77+
},
78+
]);
8879
8980
// --- Robot client and polling logic ---
9081
const robotClientStore = useRobotClient(() => "xxx");
@@ -164,7 +155,10 @@
164155
<div class="app-container">
165156
<aside class="sidebar"></aside>
166157

167-
<MainContent panes={panesData}>
158+
<MainContent
159+
panes={panesData}
160+
status={status}
161+
>
168162
{#snippet statusBar()}
169163
<Status message={statusMessages[status]} />
170164
{/snippet}

pour/vinoweb/src/lib/MainContent.svelte

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
interface Props {
2222
statusBar: Snippet;
2323
panes: PaneData[];
24+
status: string; // Add this line
2425
}
2526
26-
let { statusBar, panes }: Props = $props();
27+
let { statusBar, panes, status }: Props = $props(); // Destructure status from props
2728
</script>
2829

2930
<main class="main-content">
@@ -32,28 +33,39 @@
3233
</header>
3334

3435
<section class="content-panes">
35-
{#each panes as pane, i}
36-
<div
37-
class="expand-pane"
38-
transition:scale={{ duration: 350 }}
36+
<div class="expand-pane">
37+
<DataPane
38+
mode={status === "picking" ? "embedded" : "side-by-side"}
3939
>
40-
<DataPane
41-
mode={panes.length === 1 ? "embedded" : "side-by-side"}
42-
>
40+
{#snippet table()}
41+
<JointTable joints={panes[0].joints} />
42+
{/snippet}
43+
{#snippet camera()}
44+
<CameraFeed
45+
name={panes[0].camera.name}
46+
partID={panes[0].camera.partID}
47+
label={panes[0].camera.label}
48+
overlay={status === "picking" ? table : undefined}
49+
/>
50+
{/snippet}
51+
</DataPane>
52+
</div>
53+
{#if status !== "picking"}
54+
<div class="expand-pane">
55+
<DataPane mode="side-by-side">
4356
{#snippet table()}
44-
<JointTable joints={pane.joints} />
57+
<JointTable joints={panes[1].joints} />
4558
{/snippet}
4659
{#snippet camera()}
4760
<CameraFeed
48-
name={pane.camera.name}
49-
partID={pane.camera.partID}
50-
label={pane.camera.label}
51-
overlay={panes.length === 1 ? table : undefined}
61+
name={panes[1].camera.name}
62+
partID={panes[1].camera.partID}
63+
label={panes[1].camera.label}
5264
/>
5365
{/snippet}
5466
</DataPane>
5567
</div>
56-
{/each}
68+
{/if}
5769
</section>
5870
</main>
5971

0 commit comments

Comments
 (0)