-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added layouts for realtime logging - fixed linter
- Loading branch information
Showing
9 changed files
with
136 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function BigNumber(props: { val: number, name: string }) { | ||
return ( | ||
<div className='flex flex-col items-center justify-between bg-[#1f1f1f] p-4 rounded-md w-28 flex-1'> | ||
<div className='text-green-500 text-xs font-mono w-fit ml-auto mb-2'>+16</div> | ||
<div className='font-mono text-3xl'>{props.val}</div> | ||
<div className="opacity-60 text-sm font-extralight">{props.name}</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import useVictoryValue from '@/hooks/useVictoryValue'; | ||
import { LineChart } from '@mantine/charts'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export default function RealtimeLine(props: { element_limit: number }) { | ||
const [pose_z] = useVictoryValue('pose/ned/position/z'); | ||
|
||
const [points, setPoints] = useState<Array<{ z: number; timestamp: number }>>([]); | ||
|
||
useEffect(() => { | ||
const intervalId = setInterval(() => { | ||
if (pose_z !== undefined) { | ||
setPoints((prevPoints) => { | ||
const now = Date.now(); | ||
const updatedPoints = [...prevPoints, { z: pose_z as number, timestamp: now }]; | ||
|
||
if (updatedPoints.length > props.element_limit) { | ||
updatedPoints.shift(); | ||
} | ||
|
||
return updatedPoints; | ||
}); | ||
} else { | ||
const randomZ = Math.random() * 10; | ||
setPoints((prevPoints) => { | ||
const now = Date.now(); | ||
const updatedPoints = [...prevPoints, { z: randomZ, timestamp: now }]; | ||
|
||
if (updatedPoints.length > props.element_limit) { | ||
updatedPoints.shift(); | ||
} | ||
|
||
return updatedPoints; | ||
}); | ||
} | ||
}, 100); // 0.5 seconds interval | ||
|
||
return () => { | ||
clearInterval(intervalId); | ||
}; | ||
}, [pose_z, props.element_limit]); | ||
|
||
return ( | ||
<div className="w-[48%] bg-[#1f1f1f] shadow-sm rounded-md"> | ||
<div className="w-fit p-4">Z index</div> | ||
<hr className="h-px mb-2 bg-gray-200 border-0 dark:bg-zinc-700"></hr> | ||
<div> | ||
<LineChart | ||
h={300} | ||
data={points.map((point) => ({ x: point.timestamp, z: point.z }))} | ||
// xAxisLabel="Time" | ||
// yAxisLabel="Z Position" | ||
series={[{ name: 'z', color: 'indigo.6' }]} | ||
curveType="linear" | ||
dataKey={''} | ||
referenceLines={[{ y: 5, label: 'Nominal', color: 'green.7' }]} | ||
// yAxisProps={{ domain: [0, 10.0] }} | ||
// xAxisProps={{ domain: [-extents, extents] }} | ||
|
||
withXAxis={false} | ||
withYAxis={false} | ||
withDots={false} | ||
|
||
gridAxis="none" | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters