armbot trigger events added

This commit is contained in:
Gomathi 2025-04-28 12:08:57 +05:30
parent fe527a7e52
commit dc77d9ed43
6 changed files with 25 additions and 16 deletions

View File

@ -8,7 +8,7 @@ function RoboticArmAnimator({ armUuid, HandleCallback, currentPhase, ikSolver, t
const { armBots } = useArmBotStore();
const { scene } = useThree();
const restSpeed = 0.1;
const restPosition = new THREE.Vector3(0, 2, 1.6);
const restPosition = new THREE.Vector3(0, 1, -1.6);
const initialCurveRef = useRef<THREE.CatmullRomCurve3 | null>(null);
const initialStartPositionRef = useRef<THREE.Vector3 | null>(null);
const [initialProgress, setInitialProgress] = useState(0);
@ -26,7 +26,7 @@ function RoboticArmAnimator({ armUuid, HandleCallback, currentPhase, ikSolver, t
}, [path])
useEffect(() => {
}, [currentPath])
useFrame((_, delta) => {
@ -42,13 +42,13 @@ function RoboticArmAnimator({ armUuid, HandleCallback, currentPhase, ikSolver, t
currentPath.map(point => new THREE.Vector3(point[0], point[1], point[2]))
);
const next = initialProgressRef.current + delta * 0.5;
if (next >= 1) {
bone.position.copy(restPosition);
// bone.position.copy(restPosition);
HandleCallback(); // Call the callback when the path is completed
initialProgressRef.current = 0; // Set ref to 1 when done
} else {
const point = curve.getPoint(next); // Get the interpolated point from the curve
bone.position.copy(point); // Update the bone position along the curve
initialProgressRef.current = next; // Update progress

View File

@ -16,6 +16,7 @@ interface Process {
endPoint?: Vector3;
speed: number;
}
function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
const { isPlaying } = usePlayButtonStore();
@ -29,7 +30,7 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
const groupRef = useRef<any>(null);
const [processes, setProcesses] = useState<Process[]>([]);
const [armBotCurvePoints, setArmBotCurvePoints] = useState({ start: [], end: [] })
const restPosition = new THREE.Vector3(0, 2, 1.6);
const restPosition = new THREE.Vector3(0, 1, -1.6);
let armBotCurveRef = useRef<THREE.CatmullRomCurve3 | null>(null)
const [path, setPath] = useState<[number, number, number][]>([]);

View File

@ -15,6 +15,7 @@ type IKInstanceProps = {
setArmBotCurvePoints: any
};
function IKInstance({ modelUrl, setIkSolver, ikSolver, robot, groupRef, processes, setArmBotCurvePoints }: IKInstanceProps) {
console.log('robot: ', robot.position, robot.rotation);
const { scene } = useThree();
const gltf = useLoader(GLTFLoader, modelUrl, (loader) => {
const draco = new DRACOLoader();
@ -65,15 +66,24 @@ function IKInstance({ modelUrl, setIkSolver, ikSolver, robot, groupRef, processe
setIkSolver(solver);
const helper = new CCDIKHelper(OOI.Skinned_Mesh, iks, 0.05);
// scene.add(groupRef.current)
if (solver) {
const bone = solver.mesh.skeleton.bones.find(
(b: any) => b.name === targetBoneName
) ?? "";
if (bone) {
const position = new THREE.Vector3();
bone.getWorldPosition(position);
console.log("world position", position.x, position.y, position.z); // this is the bone's world position
}
}
scene.add(helper)
}, [gltf]);
return (
<>
<group ref={groupRef} position={robot.position}>
<group ref={groupRef} position={robot.position} rotation={robot.rotation}>
<primitive
uuid={"ArmBot-X200"}
object={cloned}

View File

@ -12,8 +12,8 @@ function RoboticArm() {
state: "idle",
modelUuid: "armbot-xyz-001",
modelName: "ArmBot-X200",
position: [91.94347308985614, 0, 6.742905194869091],
rotation: [0, 0, 0],
position: [0, 0, 0],
rotation: [-3.141592653589793, 0.3861702258311774, -3.141592653589793],
type: "roboticArm",
speed: 1.5,
point: {
@ -26,8 +26,8 @@ function RoboticArm() {
actionName: "Pick Component",
actionType: "pickAndPlace",
process: {
startPoint: [5.52543010919071, 1, -8.433681161200905],
endPoint: [10.52543010919071, 1, -12.433681161200905],
startPoint: [-1, 2, 1],
endPoint: [-2, 1, -1],
},
triggers: [
{
@ -145,7 +145,7 @@ function RoboticArm() {
];
useEffect(() => {
removeArmBot(armBotStatusSample[0].modelUuid);
addArmBot('123', armBotStatusSample[0]);
// addArmBot('123', armBotStatusSample[1]);

View File

@ -140,8 +140,6 @@ function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetai
const elapsedTime = performance.now() - startTime;
if (elapsedTime >= fixedInterval) {
console.log('fixedInterval: ', fixedInterval);
console.log('elapsedTime: ', elapsedTime);
let droppedMat = droppedMaterial - 1;
decrementVehicleLoad(agvDetail.modelUuid, 1);
if (droppedMat === 0) return;

View File

@ -148,7 +148,7 @@ function Vehicles() {
}, [])
useEffect(() => {
console.log('vehicles: ', vehicles);
// console.log('vehicles: ', vehicles);
}, [vehicles])