human and vehicle bug fix
This commit is contained in:
@@ -38,7 +38,7 @@ export function useRetrieveHandler() {
|
|||||||
echo.info(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const createNewMaterial = useCallback((materialId: string, materialType: string, action: StorageAction) => {
|
const createNewMaterial = useCallback((materialId: string, materialType: string, action: StorageAction, visible: boolean = false) => {
|
||||||
const modelUuid = getModelUuidByActionUuid(selectedProduct.productUuid, action.actionUuid);
|
const modelUuid = getModelUuidByActionUuid(selectedProduct.productUuid, action.actionUuid);
|
||||||
const pointUuid = getPointUuidByActionUuid(selectedProduct.productUuid, action.actionUuid);
|
const pointUuid = getPointUuidByActionUuid(selectedProduct.productUuid, action.actionUuid);
|
||||||
if (!modelUuid || !pointUuid) return null;
|
if (!modelUuid || !pointUuid) return null;
|
||||||
@@ -51,7 +51,7 @@ export function useRetrieveHandler() {
|
|||||||
isActive: false,
|
isActive: false,
|
||||||
isVisible: false,
|
isVisible: false,
|
||||||
isPaused: false,
|
isPaused: false,
|
||||||
isRendered: true,
|
isRendered: false,
|
||||||
startTime: currentTime,
|
startTime: currentTime,
|
||||||
previous: {
|
previous: {
|
||||||
modelUuid: modelUuid,
|
modelUuid: modelUuid,
|
||||||
@@ -168,10 +168,10 @@ export function useRetrieveHandler() {
|
|||||||
|
|
||||||
if (retrieval.action.triggers[0]?.triggeredAsset.triggeredAction?.actionUuid) {
|
if (retrieval.action.triggers[0]?.triggeredAsset.triggeredAction?.actionUuid) {
|
||||||
const action = getActionByUuid(selectedProduct.productUuid, retrieval.action.triggers[0]?.triggeredAsset.triggeredAction.actionUuid);
|
const action = getActionByUuid(selectedProduct.productUuid, retrieval.action.triggers[0]?.triggeredAsset.triggeredAction.actionUuid);
|
||||||
|
const storageAction = getActionByUuid(selectedProduct.productUuid, actionUuid);
|
||||||
if (action && action.triggers.length > 0 && action.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid) {
|
if (action && action.triggers.length > 0 && action.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid) {
|
||||||
const model = getEventByModelUuid(selectedProduct.productUuid, action?.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid || '');
|
const model = getEventByModelUuid(selectedProduct.productUuid, action?.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid || '');
|
||||||
const triggeredAction = getActionByUuid(selectedProduct.productUuid, action?.triggers[0]?.triggeredAsset?.triggeredAction?.actionUuid || '');
|
if (model && storageAction) {
|
||||||
if (model && triggeredAction) {
|
|
||||||
if (model.type === 'vehicle') {
|
if (model.type === 'vehicle') {
|
||||||
const vehicle = getVehicleById(model.modelUuid);
|
const vehicle = getVehicleById(model.modelUuid);
|
||||||
if (vehicle && !vehicle.isActive && vehicle.state === 'idle' && vehicle.isPicking && vehicle.currentLoad < vehicle.point.action.loadCapacity) {
|
if (vehicle && !vehicle.isActive && vehicle.state === 'idle' && vehicle.isPicking && vehicle.currentLoad < vehicle.point.action.loadCapacity) {
|
||||||
@@ -179,7 +179,7 @@ export function useRetrieveHandler() {
|
|||||||
const material = createNewMaterial(
|
const material = createNewMaterial(
|
||||||
lastMaterial.materialId,
|
lastMaterial.materialId,
|
||||||
lastMaterial.materialType,
|
lastMaterial.materialType,
|
||||||
triggeredAction as StorageAction
|
storageAction as StorageAction
|
||||||
);
|
);
|
||||||
if (material) {
|
if (material) {
|
||||||
|
|
||||||
@@ -192,11 +192,11 @@ export function useRetrieveHandler() {
|
|||||||
retrieveLogStatus(material.materialName, `is being picked by ${armBot?.modelName}`);
|
retrieveLogStatus(material.materialName, `is being picked by ${armBot?.modelName}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (triggeredAction) {
|
} else if (storageAction) {
|
||||||
const material = createNewMaterial(
|
const material = createNewMaterial(
|
||||||
lastMaterial.materialId,
|
lastMaterial.materialId,
|
||||||
lastMaterial.materialType,
|
lastMaterial.materialType,
|
||||||
triggeredAction as StorageAction
|
storageAction as StorageAction
|
||||||
);
|
);
|
||||||
if (material) {
|
if (material) {
|
||||||
|
|
||||||
@@ -327,10 +327,7 @@ export function useRetrieveHandler() {
|
|||||||
? getEventByModelUuid(selectedProduct.productUuid, action.triggers[0].triggeredAsset.triggeredModel.modelUuid)
|
? getEventByModelUuid(selectedProduct.productUuid, action.triggers[0].triggeredAsset.triggeredModel.modelUuid)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const triggeredAction = getActionByUuid(
|
const storageAction = getActionByUuid(selectedProduct.productUuid, actionUuid);
|
||||||
selectedProduct.productUuid,
|
|
||||||
action.triggers[0]?.triggeredAsset?.triggeredAction?.actionUuid || ''
|
|
||||||
);
|
|
||||||
|
|
||||||
if (triggeredModel?.type === 'vehicle') {
|
if (triggeredModel?.type === 'vehicle') {
|
||||||
const model = getVehicleById(triggeredModel.modelUuid);
|
const model = getVehicleById(triggeredModel.modelUuid);
|
||||||
@@ -343,7 +340,7 @@ export function useRetrieveHandler() {
|
|||||||
const material = createNewMaterial(
|
const material = createNewMaterial(
|
||||||
lastMaterial.materialId,
|
lastMaterial.materialId,
|
||||||
lastMaterial.materialType,
|
lastMaterial.materialType,
|
||||||
triggeredAction as StorageAction
|
storageAction as StorageAction
|
||||||
);
|
);
|
||||||
if (material) {
|
if (material) {
|
||||||
removeLastMaterial(storageUnit.modelUuid);
|
removeLastMaterial(storageUnit.modelUuid);
|
||||||
@@ -369,7 +366,7 @@ export function useRetrieveHandler() {
|
|||||||
const material = createNewMaterial(
|
const material = createNewMaterial(
|
||||||
lastMaterial.materialId,
|
lastMaterial.materialId,
|
||||||
lastMaterial.materialType,
|
lastMaterial.materialType,
|
||||||
triggeredAction as StorageAction
|
storageAction as StorageAction
|
||||||
);
|
);
|
||||||
if (material) {
|
if (material) {
|
||||||
removeLastMaterial(storageUnit.modelUuid);
|
removeLastMaterial(storageUnit.modelUuid);
|
||||||
@@ -395,7 +392,7 @@ export function useRetrieveHandler() {
|
|||||||
const material = createNewMaterial(
|
const material = createNewMaterial(
|
||||||
lastMaterial.materialId,
|
lastMaterial.materialId,
|
||||||
lastMaterial.materialType,
|
lastMaterial.materialType,
|
||||||
triggeredAction as StorageAction
|
storageAction as StorageAction
|
||||||
);
|
);
|
||||||
if (material) {
|
if (material) {
|
||||||
removeLastMaterial(storageUnit.modelUuid);
|
removeLastMaterial(storageUnit.modelUuid);
|
||||||
@@ -427,7 +424,7 @@ export function useRetrieveHandler() {
|
|||||||
const material = createNewMaterial(
|
const material = createNewMaterial(
|
||||||
lastMaterial.materialId,
|
lastMaterial.materialId,
|
||||||
lastMaterial.materialType,
|
lastMaterial.materialType,
|
||||||
triggeredAction as StorageAction
|
storageAction as StorageAction
|
||||||
);
|
);
|
||||||
if (material) {
|
if (material) {
|
||||||
removeLastMaterial(storageUnit.modelUuid);
|
removeLastMaterial(storageUnit.modelUuid);
|
||||||
@@ -448,7 +445,7 @@ export function useRetrieveHandler() {
|
|||||||
const material = createNewMaterial(
|
const material = createNewMaterial(
|
||||||
lastMaterial.materialId,
|
lastMaterial.materialId,
|
||||||
lastMaterial.materialType,
|
lastMaterial.materialType,
|
||||||
triggeredAction as StorageAction
|
storageAction as StorageAction
|
||||||
);
|
);
|
||||||
if (material) {
|
if (material) {
|
||||||
removeLastMaterial(storageUnit.modelUuid);
|
removeLastMaterial(storageUnit.modelUuid);
|
||||||
@@ -483,6 +480,7 @@ export function useRetrieveHandler() {
|
|||||||
addCurrentActionToCrane(crane.modelUuid, action.actionUuid, material.materialType, material.materialId);
|
addCurrentActionToCrane(crane.modelUuid, action.actionUuid, material.materialType, material.materialId);
|
||||||
addCurrentMaterialToCrane(crane.modelUuid, material.materialType, material.materialId);
|
addCurrentMaterialToCrane(crane.modelUuid, material.materialType, material.materialId);
|
||||||
cranePickupLockRef.current.set(crane.modelUuid, true);
|
cranePickupLockRef.current.set(crane.modelUuid, true);
|
||||||
|
monitoredHumansRef.current.delete(human.modelUuid);
|
||||||
}, action.triggers[0].triggeredAsset.triggeredAction?.actionUuid)
|
}, action.triggers[0].triggeredAsset.triggeredAction?.actionUuid)
|
||||||
}
|
}
|
||||||
monitoredHumansRef.current.add(human.modelUuid);
|
monitoredHumansRef.current.add(human.modelUuid);
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ export default function MaterialAnimator({ crane }: Readonly<MaterialAnimatorPro
|
|||||||
const [isRendered, setIsRendered] = useState<boolean>(false);
|
const [isRendered, setIsRendered] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (crane.isCarrying) {
|
if (crane.isCarrying && (crane.currentPhase === 'pickup-drop' || crane.currentPhase === 'dropping')) {
|
||||||
setIsRendered(true);
|
setIsRendered(true);
|
||||||
} else {
|
} else {
|
||||||
setIsRendered(false);
|
setIsRendered(false);
|
||||||
}
|
}
|
||||||
}, [crane.isCarrying]);
|
}, [crane.isCarrying, crane.currentPhase]);
|
||||||
|
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
const craneModel = scene.getObjectByProperty('uuid', crane.modelUuid);
|
const craneModel = scene.getObjectByProperty('uuid', crane.modelUuid);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useFrame, useThree } from '@react-three/fiber';
|
|||||||
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../../store/usePlayButtonStore';
|
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||||
import { useProductContext } from '../../../products/productContext';
|
import { useProductContext } from '../../../products/productContext';
|
||||||
import { dragAction } from '@use-gesture/react';
|
|
||||||
|
|
||||||
function PillarJibAnimator({
|
function PillarJibAnimator({
|
||||||
crane,
|
crane,
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ function OperatorInstance({ human }: { human: HumanStatus }) {
|
|||||||
setHumanState(human.modelUuid, 'running');
|
setHumanState(human.modelUuid, 'running');
|
||||||
setHumanActive(human.modelUuid, true);
|
setHumanActive(human.modelUuid, true);
|
||||||
setCurrentAnimation(human.modelUuid, 'working_standing', true, false, false);
|
setCurrentAnimation(human.modelUuid, 'working_standing', true, false, false);
|
||||||
}, 1)
|
}, 10)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reset()
|
reset()
|
||||||
|
|||||||
@@ -129,10 +129,13 @@ function WorkerInstance({ human }: { human: HumanStatus }) {
|
|||||||
humanStatus(human.modelUuid, 'Started from pickup point, heading to drop point');
|
humanStatus(human.modelUuid, 'Started from pickup point, heading to drop point');
|
||||||
}
|
}
|
||||||
} else if (human.currentMaterials.length > 0 && human.currentLoad > 0 && humanAsset?.animationState?.current !== 'pickup') {
|
} else if (human.currentMaterials.length > 0 && human.currentLoad > 0 && humanAsset?.animationState?.current !== 'pickup') {
|
||||||
if (human.currentMaterials[0]?.materialId) {
|
setTimeout(()=>{
|
||||||
setIsVisible(human.currentMaterials[0]?.materialId, false);
|
if (human.currentMaterials[0]?.materialId) {
|
||||||
}
|
setIsVisible(human.currentMaterials[0]?.materialId, false);
|
||||||
setCurrentAnimation(human.modelUuid, 'pickup', true, false, false);
|
}
|
||||||
|
humanStatus(human.modelUuid, 'Started to pickup in pickup point');
|
||||||
|
setCurrentAnimation(human.modelUuid, 'pickup', true, false, false);
|
||||||
|
},1)
|
||||||
}
|
}
|
||||||
} else if (!human.isActive && human.state === 'idle' && human.currentPhase === 'dropping' && human.currentLoad === 0) {
|
} else if (!human.isActive && human.state === 'idle' && human.currentPhase === 'dropping' && human.currentLoad === 0) {
|
||||||
if (action.pickUpPoint && action.dropPoint) {
|
if (action.pickUpPoint && action.dropPoint) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
const { armBotStore, productStore, materialStore } = useSceneContext();
|
const { armBotStore, productStore, materialStore } = useSceneContext();
|
||||||
const { getArmBotById } = armBotStore();
|
const { getArmBotById } = armBotStore();
|
||||||
const { getMaterialById, getMaterialPosition } = materialStore();
|
const { getMaterialById, getMaterialPosition } = materialStore();
|
||||||
const { getEventByModelUuid, getActionByUuid, getPointByUuid } = productStore();
|
const { getEventByModelUuid, getActionByUuid, getPointByUuid, getTriggeringModels } = productStore();
|
||||||
const { selectedProductStore } = useProductContext();
|
const { selectedProductStore } = useProductContext();
|
||||||
const { selectedProduct } = selectedProductStore();
|
const { selectedProduct } = selectedProductStore();
|
||||||
const { scene } = useThree();
|
const { scene } = useThree();
|
||||||
@@ -176,10 +176,12 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
if (armbotStatus && currentMaterial && currentAction && (currentPhase === 'rest-to-start' || currentPhase === 'start-to-end' || currentPhase === 'end-to-rest')) {
|
if (armbotStatus && currentMaterial && currentAction && (currentPhase === 'rest-to-start' || currentPhase === 'start-to-end' || currentPhase === 'end-to-rest')) {
|
||||||
const materialData = getMaterialById(currentMaterial);
|
const materialData = getMaterialById(currentMaterial);
|
||||||
if (materialData) {
|
if (materialData) {
|
||||||
const prevModel = getEventByModelUuid(selectedProduct.productUuid, materialData.current.modelUuid);
|
const triggeringModel = getTriggeringModels(selectedProduct.productUuid, currentAction.actionUuid);
|
||||||
|
const prevModel = triggeringModel[0] || null;
|
||||||
const nextModel = getEventByModelUuid(selectedProduct.productUuid, currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || '');
|
const nextModel = getEventByModelUuid(selectedProduct.productUuid, currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || '');
|
||||||
const nextPoint = getPointByUuid(selectedProduct.productUuid, currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || '', currentAction?.triggers[0]?.triggeredAsset?.triggeredPoint?.pointUuid || '');
|
const nextPoint = getPointByUuid(selectedProduct.productUuid, currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || '', currentAction?.triggers[0]?.triggeredAsset?.triggeredPoint?.pointUuid || '');
|
||||||
|
|
||||||
|
console.log('prevModel: ', prevModel);
|
||||||
if (prevModel && prevModel.type === 'transfer') {
|
if (prevModel && prevModel.type === 'transfer') {
|
||||||
const material = scene.getObjectByProperty("uuid", currentMaterial);
|
const material = scene.getObjectByProperty("uuid", currentMaterial);
|
||||||
const armbotModel = scene.getObjectByProperty("uuid", armBot.modelUuid);
|
const armbotModel = scene.getObjectByProperty("uuid", armBot.modelUuid);
|
||||||
|
|||||||
@@ -42,11 +42,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
|||||||
|
|
||||||
const lastRemoved = useRef<{ type: string, materialId: string, modelId: string } | null>(null);
|
const lastRemoved = useRef<{ type: string, materialId: string, modelId: string } | null>(null);
|
||||||
|
|
||||||
function firstFrame() {
|
|
||||||
startTime = performance.now();
|
|
||||||
step();
|
|
||||||
}
|
|
||||||
|
|
||||||
const action = getActionByUuid(selectedProduct.productUuid, armBot.currentAction?.actionUuid || '');
|
const action = getActionByUuid(selectedProduct.productUuid, armBot.currentAction?.actionUuid || '');
|
||||||
|
|
||||||
const handlePickUpTrigger = () => {
|
const handlePickUpTrigger = () => {
|
||||||
@@ -109,68 +104,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function step() {
|
|
||||||
if (isPausedRef.current) {
|
|
||||||
if (!pauseTimeRef.current) {
|
|
||||||
pauseTimeRef.current = performance.now();
|
|
||||||
}
|
|
||||||
requestAnimationFrame(() => step());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (pauseTimeRef.current) {
|
|
||||||
const pauseDuration = performance.now() - pauseTimeRef.current;
|
|
||||||
startTime += pauseDuration;
|
|
||||||
pauseTimeRef.current = null;
|
|
||||||
}
|
|
||||||
const elapsedTime = performance.now() - startTime;
|
|
||||||
if (elapsedTime < 1000) {
|
|
||||||
// Wait until 1500ms has passed
|
|
||||||
requestAnimationFrame(step);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (currentPhase === "picking") {
|
|
||||||
setArmBotActive(armBot.modelUuid, true);
|
|
||||||
setArmBotState(armBot.modelUuid, "running");
|
|
||||||
setCurrentPhase("start-to-end");
|
|
||||||
startTime = 0
|
|
||||||
if (!action) return;
|
|
||||||
const startPoint = (action as RoboticArmAction).process.startPoint;
|
|
||||||
const endPoint = (action as RoboticArmAction).process.endPoint;
|
|
||||||
if (startPoint && endPoint) {
|
|
||||||
let curve = createCurveBetweenTwoPoints(
|
|
||||||
new THREE.Vector3(startPoint[0], startPoint[1], startPoint[2]),
|
|
||||||
new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]));
|
|
||||||
if (curve) {
|
|
||||||
logStatus(armBot.modelUuid, "picking the object");
|
|
||||||
setPath(curve.points.map(point => [point.x, point.y, point.z]))
|
|
||||||
|
|
||||||
handlePickUpTrigger();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logStatus(armBot.modelUuid, "Moving armBot from start point to end position.")
|
|
||||||
} else if (currentPhase === "dropping") {
|
|
||||||
setArmBotActive(armBot.modelUuid, true);
|
|
||||||
setArmBotState(armBot.modelUuid, "running");
|
|
||||||
setCurrentPhase("end-to-rest");
|
|
||||||
startTime = 0;
|
|
||||||
if (!action) return;
|
|
||||||
const endPoint = (action as RoboticArmAction).process.endPoint;
|
|
||||||
if (endPoint) {
|
|
||||||
|
|
||||||
let curve = createCurveBetweenTwoPoints(new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]), restPosition);
|
|
||||||
if (curve) {
|
|
||||||
logStatus(armBot.modelUuid, "dropping the object");
|
|
||||||
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
|
||||||
|
|
||||||
handleDropTrigger();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logStatus(armBot.modelUuid, "Moving armBot from end point to rest position.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
isPausedRef.current = isPaused;
|
isPausedRef.current = isPaused;
|
||||||
}, [isPaused]);
|
}, [isPaused]);
|
||||||
@@ -268,7 +201,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const targetBones = ikSolver?.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
const targetBones = ikSolver?.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
||||||
if (!isReset && isPlaying) {
|
if (!isReset && isPlaying) {
|
||||||
//Moving armBot from initial point to rest position.
|
|
||||||
if (!armBot?.isActive && armBot?.state == "idle" && currentPhase == "init") {
|
if (!armBot?.isActive && armBot?.state == "idle" && currentPhase == "init") {
|
||||||
if (targetBones) {
|
if (targetBones) {
|
||||||
setArmBotActive(armBot.modelUuid, true)
|
setArmBotActive(armBot.modelUuid, true)
|
||||||
@@ -280,13 +212,9 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
logStatus(armBot.modelUuid, "Moving armBot from initial point to rest position.")
|
logStatus(armBot.modelUuid, "Moving armBot from initial point to rest position.")
|
||||||
}
|
} else if (armBot && !armBot.isActive && armBot.state === "idle" && currentPhase === "rest" && !armBot.currentAction) {
|
||||||
//Waiting for trigger.
|
|
||||||
else if (armBot && !armBot.isActive && armBot.state === "idle" && currentPhase === "rest" && !armBot.currentAction) {
|
|
||||||
logStatus(armBot.modelUuid, "Waiting to trigger CurrentAction")
|
logStatus(armBot.modelUuid, "Waiting to trigger CurrentAction")
|
||||||
}
|
} else if (armBot && !armBot.isActive && armBot.state === "idle" && currentPhase === "rest" && armBot.currentAction) {
|
||||||
//Moving to pickup point
|
|
||||||
else if (armBot && !armBot.isActive && armBot.state === "idle" && currentPhase === "rest" && armBot.currentAction) {
|
|
||||||
if (armBot.currentAction) {
|
if (armBot.currentAction) {
|
||||||
|
|
||||||
setArmBotActive(armBot.modelUuid, true);
|
setArmBotActive(armBot.modelUuid, true);
|
||||||
@@ -302,14 +230,45 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
logStatus(armBot.modelUuid, "Moving armBot from rest point to start position.")
|
logStatus(armBot.modelUuid, "Moving armBot from rest point to start position.")
|
||||||
}
|
} else if (armBot && !armBot.isActive && armBot.state === "running" && currentPhase === "picking" && armBot.currentAction) {
|
||||||
// Moving to Pick to Drop position
|
setTimeout(() => {
|
||||||
else if (armBot && !armBot.isActive && armBot.state === "running" && currentPhase === "picking" && armBot.currentAction) {
|
setArmBotActive(armBot.modelUuid, true);
|
||||||
requestAnimationFrame(firstFrame);
|
setArmBotState(armBot.modelUuid, "running");
|
||||||
}
|
setCurrentPhase("start-to-end");
|
||||||
//Moving to drop point to restPosition
|
startTime = 0
|
||||||
else if (armBot && !armBot.isActive && armBot.state === "running" && currentPhase === "dropping" && armBot.currentAction) {
|
if (!action) return;
|
||||||
requestAnimationFrame(firstFrame);
|
const startPoint = (action as RoboticArmAction).process.startPoint;
|
||||||
|
const endPoint = (action as RoboticArmAction).process.endPoint;
|
||||||
|
if (startPoint && endPoint) {
|
||||||
|
let curve = createCurveBetweenTwoPoints(new THREE.Vector3(startPoint[0], startPoint[1], startPoint[2]), new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]));
|
||||||
|
if (curve) {
|
||||||
|
logStatus(armBot.modelUuid, "picking the object");
|
||||||
|
setPath(curve.points.map(point => [point.x, point.y, point.z]))
|
||||||
|
handlePickUpTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logStatus(armBot.modelUuid, "Moving armBot from start point to end position.")
|
||||||
|
}, 100)
|
||||||
|
} else if (armBot && !armBot.isActive && armBot.state === "running" && currentPhase === "dropping" && armBot.currentAction) {
|
||||||
|
setTimeout(() => {
|
||||||
|
setArmBotActive(armBot.modelUuid, true);
|
||||||
|
setArmBotState(armBot.modelUuid, "running");
|
||||||
|
setCurrentPhase("end-to-rest");
|
||||||
|
startTime = 0;
|
||||||
|
if (!action) return;
|
||||||
|
const endPoint = (action as RoboticArmAction).process.endPoint;
|
||||||
|
if (endPoint) {
|
||||||
|
let curve = createCurveBetweenTwoPoints(new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]), restPosition);
|
||||||
|
if (curve) {
|
||||||
|
logStatus(armBot.modelUuid, "dropping the object");
|
||||||
|
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
||||||
|
|
||||||
|
handleDropTrigger();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logStatus(armBot.modelUuid, "Moving armBot from end point to rest position.")
|
||||||
|
}, 100)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logStatus(armBot.modelUuid, "Simulation Play Exited")
|
logStatus(armBot.modelUuid, "Simulation Play Exited")
|
||||||
@@ -348,7 +307,7 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
|||||||
setCurrentPhase("rest");
|
setCurrentPhase("rest");
|
||||||
setPath([])
|
setPath([])
|
||||||
}
|
}
|
||||||
else if (armBot.isActive && armBot.state == "running" && currentPhase == "rest-to-start") {
|
else if (armBot.state == "running" && currentPhase == "rest-to-start") {
|
||||||
logStatus(armBot.modelUuid, "Callback triggered: pick.");
|
logStatus(armBot.modelUuid, "Callback triggered: pick.");
|
||||||
setArmBotActive(armBot.modelUuid, false)
|
setArmBotActive(armBot.modelUuid, false)
|
||||||
setArmBotState(armBot.modelUuid, "running")
|
setArmBotState(armBot.modelUuid, "running")
|
||||||
|
|||||||
@@ -528,24 +528,11 @@ export function useTriggerHandler() {
|
|||||||
|
|
||||||
if (action && armBot) {
|
if (action && armBot) {
|
||||||
|
|
||||||
if (armBot.isActive === false && armBot.state === 'idle') {
|
addArmBotToMonitor(armBot.modelUuid, () => {
|
||||||
|
|
||||||
// Handle current action from arm bot
|
|
||||||
setIsVisible(materialId, false);
|
setIsVisible(materialId, false);
|
||||||
|
|
||||||
handleAction(action, materialId);
|
handleAction(action, materialId);
|
||||||
|
})
|
||||||
} else {
|
|
||||||
|
|
||||||
addArmBotToMonitor(armBot.modelUuid,
|
|
||||||
() => {
|
|
||||||
setIsVisible(materialId, false);
|
|
||||||
|
|
||||||
handleAction(action, materialId);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,6 +147,16 @@ function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetai
|
|||||||
if (angle < 0.01) {
|
if (angle < 0.01) {
|
||||||
object.quaternion.copy(targetQuaternion);
|
object.quaternion.copy(targetQuaternion);
|
||||||
setRestingRotation(false);
|
setRestingRotation(false);
|
||||||
|
setTimeout(() => {
|
||||||
|
setRestingRotation(true);
|
||||||
|
progressRef.current = 0;
|
||||||
|
movingForward.current = !movingForward.current;
|
||||||
|
setCurrentPath([]);
|
||||||
|
handleCallBack();
|
||||||
|
if (currentPhase === 'pickup-drop') {
|
||||||
|
requestAnimationFrame(startUnloadingProcess);
|
||||||
|
}
|
||||||
|
}, 0)
|
||||||
} else {
|
} else {
|
||||||
const step = rotationSpeed * delta * speed * agvDetail.speed;
|
const step = rotationSpeed * delta * speed * agvDetail.speed;
|
||||||
const angle = object.quaternion.angleTo(targetQuaternion);
|
const angle = object.quaternion.angleTo(targetQuaternion);
|
||||||
@@ -169,7 +179,6 @@ function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetai
|
|||||||
handleCallBack();
|
handleCallBack();
|
||||||
if (currentPhase === 'pickup-drop') {
|
if (currentPhase === 'pickup-drop') {
|
||||||
requestAnimationFrame(startUnloadingProcess);
|
requestAnimationFrame(startUnloadingProcess);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -226,13 +235,8 @@ function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetai
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default VehicleAnimator;
|
export default VehicleAnimator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function DraggableSphere({
|
function DraggableSphere({
|
||||||
index,
|
index,
|
||||||
position,
|
position,
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ type ProductsStore = {
|
|||||||
getPointUuidByActionUuid: (productUuid: string, actionUuid: string) => (string) | undefined;
|
getPointUuidByActionUuid: (productUuid: string, actionUuid: string) => (string) | undefined;
|
||||||
getTriggerByUuid: (productUuid: string, triggerUuid: string) => TriggerSchema | undefined;
|
getTriggerByUuid: (productUuid: string, triggerUuid: string) => TriggerSchema | undefined;
|
||||||
getTriggersByTriggeredPointUuid: (productUuid: string, triggeredPointUuid: string) => TriggerSchema[];
|
getTriggersByTriggeredPointUuid: (productUuid: string, triggeredPointUuid: string) => TriggerSchema[];
|
||||||
|
getTriggeringModels: (productUuid: string, actionUUid: string) => EventsSchema[];
|
||||||
getIsEventInProduct: (productUuid: string, modelUuid: string) => boolean;
|
getIsEventInProduct: (productUuid: string, modelUuid: string) => boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -898,6 +899,58 @@ export const createProductStore = () => {
|
|||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTriggeringModels: (productUuid: string, actionUuid: string) => {
|
||||||
|
const product = get().products.find(p => p.productUuid === productUuid);
|
||||||
|
if (!product) return [];
|
||||||
|
|
||||||
|
const triggeringModels: EventsSchema[] = [];
|
||||||
|
const targetModelUuid = get().getModelUuidByActionUuid(productUuid, actionUuid);
|
||||||
|
|
||||||
|
if (!targetModelUuid) return [];
|
||||||
|
|
||||||
|
for (const event of product.eventDatas) {
|
||||||
|
if ('points' in event) {
|
||||||
|
for (const point of (event as ConveyorEventSchema).points) {
|
||||||
|
if (point.action?.triggers) {
|
||||||
|
for (const trigger of point.action.triggers) {
|
||||||
|
if (trigger.triggeredAsset?.triggeredModel?.modelUuid === targetModelUuid &&
|
||||||
|
trigger.triggeredAsset?.triggeredAction?.actionUuid === actionUuid) {
|
||||||
|
triggeringModels.push(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ('point' in event) {
|
||||||
|
const point = (event as any).point;
|
||||||
|
|
||||||
|
if ('action' in point && point.action?.triggers) {
|
||||||
|
for (const trigger of point.action.triggers) {
|
||||||
|
if (trigger.triggeredAsset?.triggeredModel?.modelUuid === targetModelUuid &&
|
||||||
|
trigger.triggeredAsset?.triggeredAction?.actionUuid === actionUuid) {
|
||||||
|
triggeringModels.push(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ('actions' in point) {
|
||||||
|
for (const action of point.actions) {
|
||||||
|
if (action.triggers) {
|
||||||
|
for (const trigger of action.triggers) {
|
||||||
|
if (trigger.triggeredAsset?.triggeredModel?.modelUuid === targetModelUuid &&
|
||||||
|
trigger.triggeredAsset?.triggeredAction?.actionUuid === actionUuid) {
|
||||||
|
triggeringModels.push(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return triggeringModels;
|
||||||
|
},
|
||||||
|
|
||||||
getTriggersByTriggeredPointUuid: (productUuid, triggeredPointUuid) => {
|
getTriggersByTriggeredPointUuid: (productUuid, triggeredPointUuid) => {
|
||||||
const product = get().products.find(p => p.productUuid === productUuid);
|
const product = get().products.find(p => p.productUuid === productUuid);
|
||||||
if (!product) return [];
|
if (!product) return [];
|
||||||
|
|||||||
Reference in New Issue
Block a user