simulation #66

Merged
Vishnu merged 28 commits from simulation into main 2025-04-16 13:05:40 +00:00
Showing only changes of commit 5c24d7ca71 - Show all commits

View File

@@ -114,10 +114,38 @@ const IKAnimationController = ({
if (prev.needsInitialMovement !== needsInitialMovement && !needsInitialMovement) {
logStatus(`[Arm ${uuid}] Reached rest position, ready for animation`);
}
if (prev.selectedTrigger !== selectedTrigger) {
logStatus(`[Arm ${uuid}] Processing new trigger: ${selectedTrigger}`);
const currentProcess = process.find(p => p.triggerId === prev.selectedTrigger);
if (currentProcess) {
const triggerId = currentProcess.triggerId;
const endPoint = armBot.actions.processes.find((process) => process.triggerId === triggerId)?.endPoint;
// Search simulationStates for a StaticMachine that has a point matching this endPointId
const matchedStaticMachine = simulationStates.find(
(state) =>
state.type === "StaticMachine" &&
state.points?.uuid === endPoint// check for static machine with matching point uuid
) as any;
if (matchedStaticMachine) {
setStaticMachines((machines) => {
return machines.map((machine) => {
if (machine.uuid === matchedStaticMachine.modeluuid) {
return { ...machine, status: "running" };
} else {
return machine;
}
});
});
}
}
}
// Update previous state
@@ -249,35 +277,6 @@ const IKAnimationController = ({
} else if (progress >= startToEndRange[0] && progress < startToEndRange[1]) {
currentSpeed = speed;
currentStatus = "moving"; // Moving between points
if (1 - progress < 0.05) {
// Find the process that matches the current trigger
const currentProcess = process.find(p => p.triggerId === selectedTrigger);
if (currentProcess) {
const triggerId = currentProcess.triggerId;
const endPoint = armBot.actions.processes.find((process) => process.triggerId === triggerId)?.endPoint;
// Search simulationStates for a StaticMachine that has a point matching this endPointId
const matchedStaticMachine = simulationStates.find(
(state) =>
state.type === "StaticMachine" &&
state.points?.uuid === endPoint// check for static machine with matching point uuid
) as any;
if (matchedStaticMachine) {
setStaticMachines((machines) => {
return machines.map((machine) => {
if (machine.uuid === matchedStaticMachine.modeluuid) {
return { ...machine, status: "running" };
} else {
return machine;
}
});
});
}
}
}
} else if (progress >= endToRestRange[0] && progress < 1) {
currentSpeed = restSpeed;
currentStatus = "moving"; // Returning to rest