From 06e8965c63abe32f8727132b320cb7d094bc64fb Mon Sep 17 00:00:00 2001 From: Ahnaf Kamal Date: Fri, 2 Oct 2026 00:24:57 -0400 Subject: [PATCH] remove telemetrygraph (unused) --- src/components/TelemetryGraph.tsx | 217 ------------------------------ 1 file changed, 217 deletions(-) delete mode 100644 src/components/TelemetryGraph.tsx diff --git a/src/components/TelemetryGraph.tsx b/src/components/TelemetryGraph.tsx deleted file mode 100644 index 67f05eb..0000000 --- a/src/components/TelemetryGraph.tsx +++ /dev/null @@ -1,217 +0,0 @@ -'use client'; - -import React, { useEffect, useRef, useState } from 'react'; -import ROSLIB from 'roslib'; -import { useROS } from '@/ros/ROSContext'; -import html2canvas from 'html2canvas'; -import { - ResponsiveContainer, - LineChart, - Line, - CartesianGrid, - XAxis, - YAxis, - Tooltip, -} from 'recharts'; - -interface Props { - topic: string; - label: string; - color?: string; -} - -interface Point { - time: number; - value: number; -} - -const TelemetryGraph: React.FC = ({ topic, label, color = '#4da3ff' }) => { - const { ros } = useROS(); - const [data, setData] = useState([]); - const [windowSize, setWindowSize] = useState(30); - const containerRef = useRef(null); - - useEffect(() => { - if (!ros) return; - - const rosTopic = new ROSLIB.Topic({ - ros, - name: topic, - messageType: 'std_msgs/msg/UInt16', - }); - - const handleMsg = (msg: any) => { - const newPoint: Point = { - time: Date.now(), - value: Number(msg.data), - }; - - setData((prev) => { - const updated = [...prev, newPoint]; - return updated.length > windowSize ? updated.slice(-windowSize) : updated; - }); - }; - - rosTopic.subscribe(handleMsg); - return () => rosTopic.unsubscribe(handleMsg); - }, [ros, topic, windowSize]); - - const downloadPNG = async () => { - if (!containerRef.current) return; - - const canvas = await html2canvas(containerRef.current, { - backgroundColor: '#181818', - }); - - const link = document.createElement('a'); - link.download = `${label}.png`; - link.href = canvas.toDataURL('image/png'); - link.click(); - }; - - const formatTime = (time: number) => - new Date(time).toLocaleTimeString([], { - minute: '2-digit', - second: '2-digit', - }); - - return ( -
-
-
-

{label}

-

{data.length > 0 ? data[data.length - 1].value : '--'}

-
- -
- - - -
-
- -
- - - - - - - - - formatTime(Number(value))} - contentStyle={{ - background: '#222', - border: '1px solid #444', - borderRadius: '8px', - color: '#fff', - }} - /> - - - - -
- - -
- ); -}; - -export default TelemetryGraph; \ No newline at end of file