removed sample data and worked with schema for agv
This commit is contained in:
parent
a704be77d3
commit
2a669f6337
|
@ -19,7 +19,7 @@ function VehicleMechanics() {
|
||||||
const { selectedProduct } = useSelectedProduct();
|
const { selectedProduct } = useSelectedProduct();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedEventData) {
|
if (selectedEventData && selectedEventData.data.type === 'vehicle') {
|
||||||
const point = getPointByUuid(
|
const point = getPointByUuid(
|
||||||
selectedProduct.productId,
|
selectedProduct.productId,
|
||||||
selectedEventData.data.modelUuid,
|
selectedEventData.data.modelUuid,
|
||||||
|
|
|
@ -187,7 +187,7 @@ function processLoadedModel(
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (item.eventData.type === "vehicle") {
|
if (item.eventData.type === "Vehicle") {
|
||||||
const vehicleEvent: VehicleEventSchema = {
|
const vehicleEvent: VehicleEventSchema = {
|
||||||
modelUuid: item.modelUuid,
|
modelUuid: item.modelUuid,
|
||||||
modelName: item.modelName,
|
modelName: item.modelName,
|
||||||
|
|
|
@ -93,9 +93,7 @@ function PointsCreator() {
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onPointerMissed={() => {
|
onPointerMissed={() => {
|
||||||
if (selectedEventData?.data.type !== 'vehicle') {
|
// clearSelectedEventSphere();
|
||||||
clearSelectedEventSphere();
|
|
||||||
}
|
|
||||||
setTransformMode(null);
|
setTransformMode(null);
|
||||||
}}
|
}}
|
||||||
key={`${i}-${j}`}
|
key={`${i}-${j}`}
|
||||||
|
@ -123,7 +121,7 @@ function PointsCreator() {
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onPointerMissed={() => {
|
onPointerMissed={() => {
|
||||||
clearSelectedEventSphere();
|
// clearSelectedEventSphere();
|
||||||
setTransformMode(null);
|
setTransformMode(null);
|
||||||
}}
|
}}
|
||||||
position={new THREE.Vector3(...event.point.position)}
|
position={new THREE.Vector3(...event.point.position)}
|
||||||
|
@ -149,7 +147,7 @@ function PointsCreator() {
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onPointerMissed={() => {
|
onPointerMissed={() => {
|
||||||
clearSelectedEventSphere();
|
// clearSelectedEventSphere();
|
||||||
setTransformMode(null);
|
setTransformMode(null);
|
||||||
}}
|
}}
|
||||||
position={new THREE.Vector3(...event.point.position)}
|
position={new THREE.Vector3(...event.point.position)}
|
||||||
|
@ -175,7 +173,7 @@ function PointsCreator() {
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onPointerMissed={() => {
|
onPointerMissed={() => {
|
||||||
clearSelectedEventSphere();
|
// clearSelectedEventSphere();
|
||||||
setTransformMode(null);
|
setTransformMode(null);
|
||||||
}}
|
}}
|
||||||
position={new THREE.Vector3(...event.point.position)}
|
position={new THREE.Vector3(...event.point.position)}
|
||||||
|
|
|
@ -170,8 +170,8 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const logStatus = (id: string, status: string) => {
|
const logStatus = (id: string, status: string) => {
|
||||||
// console.log(id + "," + status);
|
//
|
||||||
console.log( status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -67,7 +67,7 @@ function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetai
|
||||||
setRestingRotation(true);
|
setRestingRotation(true);
|
||||||
decrementVehicleLoad(agvDetail.modelUuid, 0);
|
decrementVehicleLoad(agvDetail.modelUuid, 0);
|
||||||
const object = scene.getObjectByProperty('uuid', agvUuid);
|
const object = scene.getObjectByProperty('uuid', agvUuid);
|
||||||
console.log('currentPhase: ', currentPhase);
|
|
||||||
if (object) {
|
if (object) {
|
||||||
object.position.set(agvDetail.position[0], agvDetail.position[1], agvDetail.position[2]);
|
object.position.set(agvDetail.position[0], agvDetail.position[1], agvDetail.position[2]);
|
||||||
object.rotation.set(objectRotation.x, objectRotation.y, objectRotation.z);
|
object.rotation.set(objectRotation.x, objectRotation.y, objectRotation.z);
|
||||||
|
|
|
@ -30,7 +30,8 @@ function VehicleInstance({ agvDetail }: any) {
|
||||||
);
|
);
|
||||||
|
|
||||||
function vehicleStatus(modelId: string, status: string) {
|
function vehicleStatus(modelId: string, status: string) {
|
||||||
// console.log(`${modelId} , ${status});
|
// console.log(`${modelId} , ${status}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to reset everything
|
// Function to reset everything
|
||||||
|
@ -44,7 +45,7 @@ function VehicleInstance({ agvDetail }: any) {
|
||||||
const increment = () => {
|
const increment = () => {
|
||||||
if (isIncrememtable.current) {
|
if (isIncrememtable.current) {
|
||||||
|
|
||||||
incrementVehicleLoad(agvDetail.modelUuid, 2);
|
incrementVehicleLoad(agvDetail.modelUuid, 10);
|
||||||
isIncrememtable.current = false;
|
isIncrememtable.current = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +70,7 @@ function VehicleInstance({ agvDetail }: any) {
|
||||||
increment();
|
increment();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
|
||||||
if (agvDetail.currentLoad === agvDetail.point.action.loadCapacity) {
|
if (agvDetail.currentLoad === agvDetail.point.action.loadCapacity) {
|
||||||
const toDrop = computePath(
|
const toDrop = computePath(
|
||||||
agvDetail.point.action.pickUpPoint.position,
|
agvDetail.point.action.pickUpPoint.position,
|
||||||
|
|
|
@ -2,208 +2,38 @@ import React, { useEffect, useState } from "react";
|
||||||
import VehicleInstances from "./instances/vehicleInstances";
|
import VehicleInstances from "./instances/vehicleInstances";
|
||||||
import { useVehicleStore } from "../../../store/simulation/useVehicleStore";
|
import { useVehicleStore } from "../../../store/simulation/useVehicleStore";
|
||||||
import { useFloorItems } from "../../../store/store";
|
import { useFloorItems } from "../../../store/store";
|
||||||
import { useSelectedEventData, useSelectedEventSphere } from "../../../store/simulation/useSimulationStore";
|
import { useSelectedEventData, useSelectedEventSphere, useSelectedProduct } from "../../../store/simulation/useSimulationStore";
|
||||||
import VehicleUI from "../ui/vehicle/vehicleUI";
|
import VehicleUI from "../ui/vehicle/vehicleUI";
|
||||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||||
function Vehicles() {
|
import { useProductStore } from "../../../store/simulation/useProductStore";
|
||||||
|
|
||||||
const { vehicles, addVehicle } = useVehicleStore();
|
function Vehicles() {
|
||||||
|
const { getProductById } = useProductStore();
|
||||||
|
const { selectedProduct } = useSelectedProduct();
|
||||||
|
const { vehicles, addVehicle, removeVehicle } = useVehicleStore();
|
||||||
const { selectedEventSphere } = useSelectedEventSphere();
|
const { selectedEventSphere } = useSelectedEventSphere();
|
||||||
const { selectedEventData } = useSelectedEventData();
|
const { selectedEventData } = useSelectedEventData();
|
||||||
const { floorItems } = useFloorItems();
|
const { floorItems } = useFloorItems();
|
||||||
const { isPlaying } = usePlayButtonStore();
|
const { isPlaying } = usePlayButtonStore();
|
||||||
|
|
||||||
const [vehicleStatusSample, setVehicleStatusSample] = useState<
|
|
||||||
VehicleEventSchema[]
|
|
||||||
>([
|
|
||||||
{
|
|
||||||
modelUuid: "9356f710-4727-4b50-bdb2-9c1e747ecc74",
|
|
||||||
modelName: "AGV",
|
|
||||||
position: [97.9252965204558, 0, 37.96138815638661],
|
|
||||||
rotation: [0, 0, 0],
|
|
||||||
state: "idle",
|
|
||||||
type: "vehicle",
|
|
||||||
speed: 2.5,
|
|
||||||
point: {
|
|
||||||
uuid: "point-789",
|
|
||||||
position: [0, 1, 0],
|
|
||||||
rotation: [0, 0, 0],
|
|
||||||
action: {
|
|
||||||
actionUuid: "action-456",
|
|
||||||
actionName: "Deliver to Zone A",
|
|
||||||
actionType: "travel",
|
|
||||||
unLoadDuration: 10,
|
|
||||||
loadCapacity: 2,
|
|
||||||
steeringAngle:0,
|
|
||||||
pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
|
||||||
unLoadPoint: { position: { x: 105.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
|
||||||
triggers: [
|
|
||||||
{
|
|
||||||
triggerUuid: "trig-001",
|
|
||||||
triggerName: "Start Travel",
|
|
||||||
triggerType: "onComplete",
|
|
||||||
delay: 0,
|
|
||||||
triggeredAsset: {
|
|
||||||
triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" },
|
|
||||||
triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" },
|
|
||||||
triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
triggerUuid: "trig-002",
|
|
||||||
triggerName: "Complete Travel",
|
|
||||||
triggerType: "onComplete",
|
|
||||||
delay: 2,
|
|
||||||
triggeredAsset: null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
modelUuid: "b06960bb-3d2e-41f7-a646-335f389c68b4",
|
|
||||||
modelName: "AGV",
|
|
||||||
position: [89.61609306554463, 0, 33.634136622267356],
|
|
||||||
rotation: [0, 0, 0],
|
|
||||||
state: "idle",
|
|
||||||
type: "vehicle",
|
|
||||||
speed: 2.5,
|
|
||||||
point: {
|
|
||||||
uuid: "point-789",
|
|
||||||
position: [0, 1, 0],
|
|
||||||
rotation: [0, 0, 0],
|
|
||||||
action: {
|
|
||||||
actionUuid: "action-456",
|
|
||||||
actionName: "Deliver to Zone A",
|
|
||||||
actionType: "travel",
|
|
||||||
unLoadDuration: 10,
|
|
||||||
loadCapacity: 2,
|
|
||||||
steeringAngle:0,
|
|
||||||
pickUpPoint: null,
|
|
||||||
unLoadPoint: null,
|
|
||||||
triggers: [
|
|
||||||
{
|
|
||||||
triggerUuid: "trig-001",
|
|
||||||
triggerName: "Start Travel",
|
|
||||||
triggerType: "onStart",
|
|
||||||
delay: 0,
|
|
||||||
triggeredAsset: {
|
|
||||||
triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" },
|
|
||||||
triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" },
|
|
||||||
triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
triggerUuid: "trig-002",
|
|
||||||
triggerName: "Complete Travel",
|
|
||||||
triggerType: "onComplete",
|
|
||||||
delay: 2,
|
|
||||||
triggeredAsset: null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// modelUuid: "cd7d0584-0684-42b4-b051-9e882c1914aa",
|
|
||||||
// modelName: "AGV",
|
|
||||||
// position: [105.90938758014703, 0, 31.584209911095215],
|
|
||||||
// rotation: [0, 0, 0],
|
|
||||||
// state: "idle",
|
|
||||||
// type: "vehicle",
|
|
||||||
// speed: 2.5,
|
|
||||||
// point: {
|
|
||||||
// uuid: "point-789",
|
|
||||||
// position: [0, 1, 0],
|
|
||||||
// rotation: [0, 0, 0],
|
|
||||||
// action: {
|
|
||||||
// actionUuid: "action-456",
|
|
||||||
// actionName: "Deliver to Zone A",
|
|
||||||
// actionType: "travel",
|
|
||||||
// unLoadDuration: 10,
|
|
||||||
// loadCapacity: 2,
|
|
||||||
// steeringAngle:0,
|
|
||||||
// pickUpPoint: null,
|
|
||||||
// unLoadPoint: null,
|
|
||||||
// triggers: [
|
|
||||||
// {
|
|
||||||
// triggerUuid: "trig-001",
|
|
||||||
// triggerName: "Start Travel",
|
|
||||||
// triggerType: "onStart",
|
|
||||||
// delay: 0,
|
|
||||||
// triggeredAsset: {
|
|
||||||
// triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" },
|
|
||||||
// triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" },
|
|
||||||
// triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// triggerUuid: "trig-002",
|
|
||||||
// triggerName: "Complete Travel",
|
|
||||||
// triggerType: "onComplete",
|
|
||||||
// delay: 2,
|
|
||||||
// triggeredAsset: null
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// modelUuid: "e729a4f1-11d2-4778-8d6a-468f1b4f6b79",
|
|
||||||
// modelName: "forklift",
|
|
||||||
// position: [98.85729337188162, 0, 38.36616546567653],
|
|
||||||
// rotation: [0, 0, 0],
|
|
||||||
// state: "idle",
|
|
||||||
// type: "vehicle",
|
|
||||||
// speed: 2.5,
|
|
||||||
// point: {
|
|
||||||
// uuid: "point-789",
|
|
||||||
// position: [0, 1, 0],
|
|
||||||
// rotation: [0, 0, 0],
|
|
||||||
// action: {
|
|
||||||
// actionUuid: "action-456",
|
|
||||||
// actionName: "Deliver to Zone A",
|
|
||||||
// actionType: "travel",
|
|
||||||
// unLoadDuration: 15,
|
|
||||||
// loadCapacity: 5,
|
|
||||||
// steeringAngle:0,
|
|
||||||
// pickUpPoint: null,
|
|
||||||
// unLoadPoint: null,
|
|
||||||
// triggers: [
|
|
||||||
// {
|
|
||||||
// triggerUuid: "trig-001",
|
|
||||||
// triggerName: "Start Travel",
|
|
||||||
// triggerType: "onStart",
|
|
||||||
// delay: 0,
|
|
||||||
// triggeredAsset: {
|
|
||||||
// triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" },
|
|
||||||
// triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" },
|
|
||||||
// triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// triggerUuid: "trig-002",
|
|
||||||
// triggerName: "Complete Travel",
|
|
||||||
// triggerType: "onComplete",
|
|
||||||
// delay: 2,
|
|
||||||
// triggeredAsset: null
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
]);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (selectedProduct.productId) {
|
||||||
|
const product = getProductById(selectedProduct.productId);
|
||||||
|
if (product) {
|
||||||
|
product.eventDatas.forEach(events => {
|
||||||
|
if (events.type === 'vehicle') {
|
||||||
|
removeVehicle(events.modelUuid);
|
||||||
|
addVehicle(selectedProduct.productId, events);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [selectedProduct]);
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
// console.log('vehicles: ', vehicles);
|
// console.log('vehicles: ', vehicles);
|
||||||
}, [vehicles])
|
}, [vehicles])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
addVehicle("123", vehicleStatusSample[0]);
|
|
||||||
addVehicle('123', vehicleStatusSample[1]);
|
|
||||||
// addVehicle('123', vehicleStatusSample[2]);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<VehicleInstances />
|
<VehicleInstances />
|
||||||
|
@ -214,7 +44,4 @@ function Vehicles() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Vehicles;
|
export default Vehicles;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue