);
diff --git a/src/components/Machine3D/Machine3D.tsx b/src/components/Machine3D/Machine3D.tsx
index 8d7b2a1c..faf0c1e4 100644
--- a/src/components/Machine3D/Machine3D.tsx
+++ b/src/components/Machine3D/Machine3D.tsx
@@ -1,6 +1,6 @@
import { Html, useCursor } from "@react-three/drei";
import { useFrame, useThree } from "@react-three/fiber";
-import React, { useMemo, useRef, useState } from "react";
+import { useMemo, useRef, useState } from "react";
import * as THREE from "three";
import MachineBarcode from "../MachineBarcode/MachineBarcode";
diff --git a/src/components/ModeSwitcher/ModeSwitcher.tsx b/src/components/ModeSwitcher/ModeSwitcher.tsx
index 7e354bef..0dc11b93 100644
--- a/src/components/ModeSwitcher/ModeSwitcher.tsx
+++ b/src/components/ModeSwitcher/ModeSwitcher.tsx
@@ -10,19 +10,17 @@ export default function ModeSwitcher(): ReactElement {
const dispatch = useAppDispatch();
return (
- <>
-
{
- setTimeout(() => {
- dispatch(setApplicationMode(e.target.checked));
- window.location.reload();
- }, 1000);
- }}
- />
- >
+ {
+ setTimeout(() => {
+ dispatch(setApplicationMode(e.target.checked));
+ window.location.reload();
+ }, 1000);
+ }}
+ />
);
}
diff --git a/src/components/Robot3D/Robot3D.tsx b/src/components/Robot3D/Robot3D.tsx
index 1dc36f31..796f09b9 100644
--- a/src/components/Robot3D/Robot3D.tsx
+++ b/src/components/Robot3D/Robot3D.tsx
@@ -12,7 +12,7 @@ export default function Robot3D() {
useMemo(() => {
const loader = new GLTFLoader();
loader.load(
- "https://github.com/robolaunch/ui-models/raw/main/robot.glb",
+ "/models/robot.glb",
(gltf: any) => {
console.log("Robot model loaded:", gltf);
setRobotModel(gltf.scene);
diff --git a/src/contexts/BarcodeContext.tsx b/src/contexts/BarcodeContext.tsx
index e882ab05..9605e8a5 100644
--- a/src/contexts/BarcodeContext.tsx
+++ b/src/contexts/BarcodeContext.tsx
@@ -1,6 +1,6 @@
-import React, { createContext, useEffect, useState } from "react";
-import ROSLIB from "roslib";
+import { createContext, useEffect, useState } from "react";
import useRobot from "../hooks/useRobot";
+import ROSLIB from "roslib";
export const BarcodeContext: any = createContext(null);
@@ -26,8 +26,10 @@ export default ({ children }: any) => {
});
ros &&
- barcodes.subscribe(function (barcode: any) {
- console.log("barcode", barcode);
+ barcodes.subscribe(function (message: any) {
+ const messageWithScannerId = JSON.parse(message?.data);
+
+ handleBarcodeSetters(messageWithScannerId);
});
}, [ros]);
@@ -40,7 +42,6 @@ export default ({ children }: any) => {
ros &&
poseTopic.subscribe(function (pose: any) {
- console.log(pose);
setRobotLocation({
...pose?.pose?.position,
z: quaternionToEuler(pose?.pose?.orientation),
@@ -53,6 +54,40 @@ export default ({ children }: any) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ros]);
+ function handleBarcodeSetters(message: any) {
+ setBarcodeItems((prevBarcodeItems: any) => {
+ const updatedBarcodeItems = [...prevBarcodeItems];
+
+ const barcodeIndex = prevBarcodeItems.findIndex(
+ (barcodeItem: any) =>
+ barcodeItem.coordinates &&
+ Math.sqrt(
+ Math.pow(barcodeItem.coordinates.x - message?.coordinates.x, 2) +
+ Math.pow(barcodeItem.coordinates.y - message?.coordinates.y, 2),
+ ) < 0.02,
+ );
+
+ if (barcodeIndex !== -1) {
+ updatedBarcodeItems[barcodeIndex] = {
+ ...prevBarcodeItems[barcodeIndex],
+ barcodes: prevBarcodeItems[barcodeIndex].barcodes.map(
+ (barcode: any, index: number) =>
+ index === message?.scannerId ? message?.barcode : barcode,
+ ),
+ };
+ } else {
+ updatedBarcodeItems.push({
+ barcodes: Array.apply(null, Array(3)).map((_, index: number) =>
+ index === message?.scannerId ? message?.barcode : "",
+ ),
+ coordinates: message?.coordinates,
+ });
+ }
+
+ return updatedBarcodeItems;
+ });
+ }
+
function quaternionToEuler(q: {
x: number;
y: number;
diff --git a/src/layouts/TaskManagementLayout.tsx b/src/layouts/TaskManagementLayout.tsx
index 51ecb806..45725d72 100644
--- a/src/layouts/TaskManagementLayout.tsx
+++ b/src/layouts/TaskManagementLayout.tsx
@@ -1,7 +1,7 @@
import MissionManagement from "../pages/EnvironmentPage/TaskManagement/MissionManagement";
import BarcodeManagement from "../pages/EnvironmentPage/TaskManagement/BarcodeManagement";
+import LayoutTabSwitcher from "../components/LayoutTabSwitcher/LayoutTabSwitcher";
import { Fragment, ReactElement, useState } from "react";
-import Card from "../components/Card/Card";
import useRobot from "../hooks/useRobot";
export default function TaskManagementLayout(): ReactElement {
@@ -13,37 +13,11 @@ export default function TaskManagementLayout(): ReactElement {
return (
-
-
-
+
{(() => {
switch (activeTab) {
case "Mission Management":
diff --git a/src/pages/EnvironmentPage/CodeEditor/CodeEditor.tsx b/src/pages/EnvironmentPage/CodeEditor/CodeEditor.tsx
index 6da443d6..3364e7b5 100644
--- a/src/pages/EnvironmentPage/CodeEditor/CodeEditor.tsx
+++ b/src/pages/EnvironmentPage/CodeEditor/CodeEditor.tsx
@@ -1,4 +1,4 @@
-import CodeEditorSwitcher from "../../../components/CodeEditorSwitcher/CodeEditorSwitcher";
+import LayoutTabSwitcher from "../../../components/LayoutTabSwitcher/LayoutTabSwitcher";
import { FullScreen, useFullScreenHandle } from "react-full-screen";
import ControlBar from "../../../components/ControlBar/ControlBar";
import useCreateRobot from "../../../hooks/useCreateRobot";
@@ -8,7 +8,9 @@ import Card from "../../../components/Card/Card";
import useRobot from "../../../hooks/useRobot";
export default function CodeEditor(): ReactElement {
- const [activeTabCodeEditor, setActiveTabCodeEditor] = useState<1 | 2>(1);
+ const [activeTabCodeEditor, setActiveTabCodeEditor] = useState<
+ "Virtual IDE" | "Physical IDE"
+ >("Virtual IDE");
const handleFullScreen = useFullScreenHandle();
@@ -27,9 +29,10 @@ export default function CodeEditor(): ReactElement {
}
>
{robotData.step1.services.physicalIde?.isEnabled && (
-
)}
@@ -43,7 +46,10 @@ export default function CodeEditor(): ReactElement {
title="Virtual IDE"
allow="clipboard-read"
className={`animate-fadeIn h-full w-full
- ${activeTabCodeEditor === 2 && "absolute -top-[9999px]"}
+ ${
+ activeTabCodeEditor === "Physical IDE" &&
+ "absolute -top-[9999px]"
+ }
${handleFullScreen?.active && "!h-screen"}`}
src={urls?.ide || robotData.step1.services.ide?.httpsEndpoint}
/>
@@ -51,7 +57,10 @@ export default function CodeEditor(): ReactElement {
title="Physical IDE"
allow="clipboard-read"
className={`animate-fadeIn h-full w-full
- ${activeTabCodeEditor === 1 && "absolute -top-[9999px]"}
+ ${
+ activeTabCodeEditor === "Virtual IDE" &&
+ "absolute -top-[9999px]"
+ }
${handleFullScreen?.active && "!h-screen"}`}
src={robotData.step1.services.physicalIde?.httpsEndpoint}
/>
diff --git a/src/toolkit/RobotSlice.ts b/src/toolkit/RobotSlice.ts
index 27f8c32f..8bc707f5 100644
--- a/src/toolkit/RobotSlice.ts
+++ b/src/toolkit/RobotSlice.ts
@@ -400,7 +400,7 @@ export const RobotSlice = createSlice({
urls: {
vdi: isProduction ? "" : "ws://localhost:8080/",
ide: isProduction ? "" : "https://robolaunch.io",
- ros: isProduction ? "" : "",
+ ros: isProduction ? "" : "ws://localhost:9090",
},
},
reducers: {},