From 72874785fe416e1c99a78e4659818f70ad0d35b5 Mon Sep 17 00:00:00 2001 From: gokhangunduz Date: Fri, 12 Jan 2024 15:29:23 +0300 Subject: [PATCH] feat(version): release 0.30.3 version --- package.json | 2 +- public/css/style.css | 84 +++++++++++-------- .../BarcodeFinder/BarcodeFinder.tsx | 10 +-- .../BarcodeManagementButton.tsx | 20 +++++ .../BarcodeManagementControls.tsx} | 30 +++---- src/contexts/BarcodeContext.tsx | 55 +++++++++++- src/interfaces/barcodeInterfaces.ts | 12 +++ src/layouts/TaskManagementLayout.tsx | 6 +- .../TaskManagement/BarcodeManagement.tsx | 24 +++--- .../TaskManagement/BarcodeManagement2D.tsx | 4 +- .../TaskManagement/BarcodeManagement3D.tsx | 14 ++-- 11 files changed, 183 insertions(+), 78 deletions(-) create mode 100644 src/components/BarcodeManagementButton/BarcodeManagementButton.tsx rename src/components/{BarcodeModeToggle/BarcodeModeToggle.tsx => BarcodeManagementControls/BarcodeManagementControls.tsx} (62%) create mode 100644 src/interfaces/barcodeInterfaces.ts diff --git a/package.json b/package.json index 324048e2..e7168d80 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.30.2", + "version": "0.30.3", "private": true, "scripts": { "dev": "react-scripts start", diff --git a/public/css/style.css b/public/css/style.css index d106c6ce..2aea04a5 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -917,6 +917,10 @@ video { margin-left: 0.5rem; } +.mr-2 { + margin-right: 0.5rem; +} + .mt-0 { margin-top: 0px; } @@ -945,10 +949,6 @@ video { margin-top: 0.1rem; } -.mr-2 { - margin-right: 0.5rem; -} - .block { display: block; } @@ -989,6 +989,10 @@ video { height: 7rem !important; } +.\!h-6 { + height: 1.5rem !important; +} + .\!h-60 { height: 15rem !important; } @@ -997,6 +1001,10 @@ video { height: 2rem !important; } +.\!h-80 { + height: 20rem !important; +} + .\!h-9 { height: 2.25rem !important; } @@ -1123,10 +1131,6 @@ video { height: 3px; } -.h-\[40rem\] { - height: 40rem; -} - .h-\[42rem\] { height: 42rem; } @@ -1157,16 +1161,28 @@ video { height: 100vh; } -.\!h-7 { - height: 1.75rem !important; +.max-h-\[40rem\] { + max-height: 40rem; } -.\!h-6 { - height: 1.5rem !important; +.\!max-h-full { + max-height: 100% !important; } -.max-h-\[40rem\] { - max-height: 40rem; +.\!max-h-fit { + max-height: -webkit-fit-content !important; + max-height: -moz-fit-content !important; + max-height: fit-content !important; +} + +.\!max-h-min { + max-height: -webkit-min-content !important; + max-height: min-content !important; +} + +.\!max-h-max { + max-height: -webkit-max-content !important; + max-height: max-content !important; } .min-h-4 { @@ -1177,6 +1193,10 @@ video { min-height: 1.25rem; } +.min-h-9 { + min-height: 2.25rem; +} + .min-h-\[40rem\] { min-height: 40rem; } @@ -1185,10 +1205,6 @@ video { min-height: 100vh; } -.min-h-9 { - min-height: 2.25rem; -} - .\!w-24 { width: 6rem !important; } @@ -1394,10 +1410,6 @@ video { width: max-content; } -.\!w-60 { - width: 15rem !important; -} - .w-80 { width: 20rem; } @@ -1414,6 +1426,10 @@ video { min-width: 9rem; } +.min-w-9 { + min-width: 2.25rem; +} + .min-w-\[12rem\] { min-width: 12rem; } @@ -1433,10 +1449,6 @@ video { min-width: max-content; } -.min-w-9 { - min-width: 2.25rem; -} - .max-w-fit { max-width: -webkit-fit-content; max-width: -moz-fit-content; @@ -2407,6 +2419,10 @@ video { padding-left: 1.5rem; } +.pr-2 { + padding-right: 0.5rem; +} + .pr-6 { padding-right: 1.5rem; } @@ -2447,14 +2463,6 @@ video { padding-top: 2rem; } -.pl-4 { - padding-left: 1rem; -} - -.pr-2 { - padding-right: 0.5rem; -} - .text-center { text-align: center; } @@ -2820,6 +2828,14 @@ video { opacity: 0.9; } +.opacity-75 { + opacity: 0.75; +} + +.opacity-60 { + opacity: 0.6; +} + .\!shadow { --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1) !important; --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color) !important; diff --git a/src/components/BarcodeFinder/BarcodeFinder.tsx b/src/components/BarcodeFinder/BarcodeFinder.tsx index 3f5d0d5a..38af40b8 100644 --- a/src/components/BarcodeFinder/BarcodeFinder.tsx +++ b/src/components/BarcodeFinder/BarcodeFinder.tsx @@ -1,7 +1,7 @@ import { ReactElement, useState } from "react"; -import { PiMagnifyingGlassBold } from "react-icons/pi"; import InputText from "../InputText/InputText"; import useBarcode from "../../hooks/useBarcode"; +import { BsSearch } from "react-icons/bs"; export default function BarcodeFinder(): ReactElement { const [isActiveFinder, setIsActiveFinder] = useState(false); @@ -10,13 +10,13 @@ export default function BarcodeFinder(): ReactElement { return (
- { setIsActiveFinder(!isActiveFinder); setFindBarcodeInput(""); diff --git a/src/components/BarcodeManagementButton/BarcodeManagementButton.tsx b/src/components/BarcodeManagementButton/BarcodeManagementButton.tsx new file mode 100644 index 00000000..e0bd39e9 --- /dev/null +++ b/src/components/BarcodeManagementButton/BarcodeManagementButton.tsx @@ -0,0 +1,20 @@ +import { ReactElement } from "react"; + +interface IBarcodeManagementButton { + icon: ReactElement; + onClick: () => void; +} + +export default function BarcodeManagementButton({ + icon, + onClick, +}: IBarcodeManagementButton): ReactElement { + return ( +
+ {icon} +
+ ); +} diff --git a/src/components/BarcodeModeToggle/BarcodeModeToggle.tsx b/src/components/BarcodeManagementControls/BarcodeManagementControls.tsx similarity index 62% rename from src/components/BarcodeModeToggle/BarcodeModeToggle.tsx rename to src/components/BarcodeManagementControls/BarcodeManagementControls.tsx index 9a5b20ca..5deef1ad 100644 --- a/src/components/BarcodeModeToggle/BarcodeModeToggle.tsx +++ b/src/components/BarcodeManagementControls/BarcodeManagementControls.tsx @@ -3,6 +3,8 @@ import { BsFullscreen } from "react-icons/bs"; import useBarcode from "../../hooks/useBarcode"; import saveAs from "file-saver"; import BarcodeFinder from "../BarcodeFinder/BarcodeFinder"; +import BarcodeManagementButton from "../BarcodeManagementButton/BarcodeManagementButton"; +import { PiExport } from "react-icons/pi"; interface IBarcodeModeToggle { handleFullScreen: any; @@ -26,25 +28,23 @@ export default function BarcodeModeToggle({ return (
-
{activeTab === "2D" ? "3D" : "2D"} + } onClick={() => setActiveTab(activeTab === "2D" ? "3D" : "2D")} - > - {activeTab === "2D" ? "3D" : "2D"} -
+ /> -
} onClick={handleFullScreen.enter} - > - -
-
+ + } onClick={handleExportJSON} - > - E -
+ /> +
); diff --git a/src/contexts/BarcodeContext.tsx b/src/contexts/BarcodeContext.tsx index d6185b02..19b333bb 100644 --- a/src/contexts/BarcodeContext.tsx +++ b/src/contexts/BarcodeContext.tsx @@ -1,6 +1,7 @@ import { createContext, useEffect, useState } from "react"; import useRobot from "../hooks/useRobot"; import ROSLIB from "roslib"; +import { IBarcodeItem } from "../interfaces/barcodeInterfaces"; export const BarcodeContext: any = createContext(null); @@ -17,7 +18,7 @@ export default ({ children }: any) => { y: 0, z: 0, }); - const [barcodeItems, setBarcodeItems] = useState([]); + const [barcodeItems, setBarcodeItems] = useState([]); useEffect(() => { const barcodes = new ROSLIB.Topic({ @@ -30,8 +31,9 @@ export default ({ children }: any) => { barcodes.subscribe(function ({ data }: any) { const message = JSON.parse(data); - setBarcodeItems((prevData: any) => [...prevData, message]); + barcodeClustering(message); }); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ros]); useEffect(() => { @@ -72,6 +74,55 @@ export default ({ children }: any) => { return Math.atan2(siny_cosp, cosy_cosp); } + function barcodeClustering(newBarcode: IBarcodeItem) { + const clusteringScale = 0.3; + + setBarcodeItems((prevData: IBarcodeItem[]) => { + if (prevData.length > 0) { + const lastItemWaypoint = { + x: Math.abs(prevData[prevData.length - 1]?.waypoint?.x), + y: Math.abs(prevData[prevData.length - 1]?.waypoint?.y), + z: Math.abs(prevData[prevData.length - 1]?.waypoint?.z), + }; + + const newItemWaypoint = { + x: Math.abs(newBarcode?.waypoint?.x), + y: Math.abs(newBarcode?.waypoint?.y), + z: Math.abs(newBarcode?.waypoint?.z), + }; + + const diff = { + x: Math.abs(lastItemWaypoint.x - newItemWaypoint.x), + y: Math.abs(lastItemWaypoint.y - newItemWaypoint.y), + z: Math.abs(lastItemWaypoint.z - newItemWaypoint.z), + }; + + if (diff.x < clusteringScale && diff.y < clusteringScale) { + return [ + ...prevData, + { + robotId: newBarcode.robotId, + fleetId: newBarcode.fleetId, + sensorId: newBarcode.sensorId, + barcode: newBarcode.barcode, + waypoint: { + x: prevData[prevData.length - 1]?.waypoint?.x, + y: prevData[prevData.length - 1]?.waypoint?.y, + z: newBarcode.waypoint.z, + yaw: prevData[prevData.length - 1]?.waypoint?.yaw, + }, + }, + ]; + } else { + return [...prevData, newBarcode]; + } + } else { + // If barcodeItems is initially empty, just return the newBarcode in an array + return [newBarcode]; + } + }); + } + return ( ("Mission Management"); return ( - +
; } })()} - +
); } diff --git a/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement.tsx b/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement.tsx index 37990946..48db64dd 100644 --- a/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement.tsx +++ b/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement.tsx @@ -1,9 +1,9 @@ import { Fragment, ReactElement, useState } from "react"; -import CardLayout from "../../../layouts/CardLayout"; import BarcodeManagement3D from "./BarcodeManagement3D"; import { FullScreen, useFullScreenHandle } from "react-full-screen"; import BarcodeManagement2D from "./BarcodeManagement2D"; -import BarcodeModeToggle from "../../../components/BarcodeModeToggle/BarcodeModeToggle"; +import BarcodeManagementControls from "../../../components/BarcodeManagementControls/BarcodeManagementControls"; +import Card from "../../../components/Card/Card"; export default function BarcodeManagement({ ros }: any): ReactElement { const [activeTab, setActiveTab] = useState<"2D" | "3D">("3D"); @@ -11,8 +11,8 @@ export default function BarcodeManagement({ ros }: any): ReactElement { const handleFullScreen = useFullScreenHandle(); return ( - - + + {activeTab === "2D" ? ( @@ -20,12 +20,16 @@ export default function BarcodeManagement({ ros }: any): ReactElement { )} + - - + ); } diff --git a/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement2D.tsx b/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement2D.tsx index 931e60d4..4cfc3a5d 100644 --- a/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement2D.tsx +++ b/src/pages/EnvironmentPage/TaskManagement/BarcodeManagement2D.tsx @@ -19,7 +19,7 @@ export default function BarcodeManagement2D(): ReactElement { style={{ backgroundRepeat: "repeat", }} - className="flex w-full items-center justify-center gap-10 " + className="animate-fadeIn flex w-full items-center justify-center gap-10" > {barcodeItems?.length ? barcodeItems?.map( @@ -38,7 +38,7 @@ export default function BarcodeManagement2D(): ReactElement { backgroundSize: "contain", }} > -
+
{barcode ? ( - {barcodeItems?.map((barcodeItem: any, barcodeItemIndex: number) => { - return ; - })} - - +
+ + {barcodeItems?.map((barcodeItem: any, barcodeItemIndex: number) => { + return ; + })} + + +
); }