timeout added
This commit is contained in:
@@ -63,7 +63,7 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||||||
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logStatus(robot.modelUuid, "Starting from init to rest")
|
logStatus(robot.modelUuid, "Moving armBot from initial point to rest position.")
|
||||||
}
|
}
|
||||||
//Waiting for trigger.
|
//Waiting for trigger.
|
||||||
else if (robot && !robot.isActive && robot.state === "idle" && currentPhase === "rest" && !robot.currentAction) {
|
else if (robot && !robot.isActive && robot.state === "idle" && currentPhase === "rest" && !robot.currentAction) {
|
||||||
@@ -85,7 +85,7 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logStatus(robot.modelUuid, "Starting from rest to start")
|
logStatus(robot.modelUuid, "Moving armBot from rest point to start position.")
|
||||||
}
|
}
|
||||||
else if (robot && !robot.isActive && robot.state === "idle" && currentPhase === "picking" && robot.currentAction) {
|
else if (robot && !robot.isActive && robot.state === "idle" && currentPhase === "picking" && robot.currentAction) {
|
||||||
setArmBotActive(robot.modelUuid, true);
|
setArmBotActive(robot.modelUuid, true);
|
||||||
@@ -99,10 +99,13 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||||||
new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2])
|
new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2])
|
||||||
);
|
);
|
||||||
if (curve) {
|
if (curve) {
|
||||||
|
setTimeout(() => {
|
||||||
|
logStatus(robot.modelUuid, "waiting to pick box");
|
||||||
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
||||||
|
}, 1500)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logStatus(robot.modelUuid, "Starting from start to end")
|
logStatus(robot.modelUuid, "Moving armBot from start point to end position.")
|
||||||
}
|
}
|
||||||
else if (robot && !robot.isActive && robot.state === "idle" && currentPhase === "dropping" && robot.currentAction) {
|
else if (robot && !robot.isActive && robot.state === "idle" && currentPhase === "dropping" && robot.currentAction) {
|
||||||
setArmBotActive(robot.modelUuid, true);
|
setArmBotActive(robot.modelUuid, true);
|
||||||
@@ -113,10 +116,13 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||||||
let curve = createCurveBetweenTwoPoints(new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]), restPosition
|
let curve = createCurveBetweenTwoPoints(new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]), restPosition
|
||||||
);
|
);
|
||||||
if (curve) {
|
if (curve) {
|
||||||
|
setTimeout(() => {
|
||||||
|
logStatus(robot.modelUuid, "waiting to drop box");
|
||||||
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
||||||
|
}, 1500)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logStatus(robot.modelUuid, "Starting from end to rest")
|
logStatus(robot.modelUuid, "Moving armBot from end point to rest position.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,28 +140,28 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||||||
|
|
||||||
const HandleCallback = () => {
|
const HandleCallback = () => {
|
||||||
if (robot.isActive && robot.state == "running" && currentPhase == "init-to-rest") {
|
if (robot.isActive && robot.state == "running" && currentPhase == "init-to-rest") {
|
||||||
console.log("Callback triggered: rest");
|
logStatus(robot.modelUuid, "Callback triggered: rest");
|
||||||
setArmBotActive(robot.modelUuid, false)
|
setArmBotActive(robot.modelUuid, false)
|
||||||
setArmBotState(robot.modelUuid, "idle")
|
setArmBotState(robot.modelUuid, "idle")
|
||||||
setCurrentPhase("rest");
|
setCurrentPhase("rest");
|
||||||
setPath([])
|
setPath([])
|
||||||
}
|
}
|
||||||
else if (robot.isActive && robot.state == "running" && currentPhase == "rest-to-start") {
|
else if (robot.isActive && robot.state == "running" && currentPhase == "rest-to-start") {
|
||||||
console.log("Callback triggered: pick.");
|
logStatus(robot.modelUuid, "Callback triggered: pick.");
|
||||||
setArmBotActive(robot.modelUuid, false)
|
setArmBotActive(robot.modelUuid, false)
|
||||||
setArmBotState(robot.modelUuid, "idle")
|
setArmBotState(robot.modelUuid, "idle")
|
||||||
setCurrentPhase("picking");
|
setCurrentPhase("picking");
|
||||||
setPath([])
|
setPath([])
|
||||||
}
|
}
|
||||||
else if (robot.isActive && robot.state == "running" && currentPhase == "start-to-end") {
|
else if (robot.isActive && robot.state == "running" && currentPhase == "start-to-end") {
|
||||||
console.log("Callback triggered: drop.");
|
logStatus(robot.modelUuid, "Callback triggered: drop.");
|
||||||
setArmBotActive(robot.modelUuid, false)
|
setArmBotActive(robot.modelUuid, false)
|
||||||
setArmBotState(robot.modelUuid, "idle")
|
setArmBotState(robot.modelUuid, "idle")
|
||||||
setCurrentPhase("dropping");
|
setCurrentPhase("dropping");
|
||||||
setPath([])
|
setPath([])
|
||||||
}
|
}
|
||||||
else if (robot.isActive && robot.state == "running" && currentPhase == "end-to-rest") {
|
else if (robot.isActive && robot.state == "running" && currentPhase == "end-to-rest") {
|
||||||
console.log("Callback triggered: rest, cycle completed.");
|
logStatus(robot.modelUuid, "Callback triggered: rest, cycle completed.");
|
||||||
setArmBotActive(robot.modelUuid, false)
|
setArmBotActive(robot.modelUuid, false)
|
||||||
setArmBotState(robot.modelUuid, "idle")
|
setArmBotState(robot.modelUuid, "idle")
|
||||||
setCurrentPhase("rest");
|
setCurrentPhase("rest");
|
||||||
@@ -169,7 +175,6 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
<IKInstance modelUrl={armModel} setIkSolver={setIkSolver} ikSolver={ikSolver} robot={robot} groupRef={groupRef} processes={processes}
|
<IKInstance modelUrl={armModel} setIkSolver={setIkSolver} ikSolver={ikSolver} robot={robot} groupRef={groupRef} processes={processes}
|
||||||
setArmBotCurvePoints={setArmBotCurvePoints} />
|
setArmBotCurvePoints={setArmBotCurvePoints} />
|
||||||
<RoboticArmAnimator armUuid={robot?.modelUuid} HandleCallback={HandleCallback}
|
<RoboticArmAnimator armUuid={robot?.modelUuid} HandleCallback={HandleCallback}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type IKInstanceProps = {
|
|||||||
setArmBotCurvePoints: any
|
setArmBotCurvePoints: any
|
||||||
};
|
};
|
||||||
function IKInstance({ modelUrl, setIkSolver, ikSolver, robot, groupRef, processes, setArmBotCurvePoints }: IKInstanceProps) {
|
function IKInstance({ modelUrl, setIkSolver, ikSolver, robot, groupRef, processes, setArmBotCurvePoints }: IKInstanceProps) {
|
||||||
console.log('robot: ', robot.position, robot.rotation);
|
|
||||||
const { scene } = useThree();
|
const { scene } = useThree();
|
||||||
const gltf = useLoader(GLTFLoader, modelUrl, (loader) => {
|
const gltf = useLoader(GLTFLoader, modelUrl, (loader) => {
|
||||||
const draco = new DRACOLoader();
|
const draco = new DRACOLoader();
|
||||||
@@ -66,16 +66,16 @@ function IKInstance({ modelUrl, setIkSolver, ikSolver, robot, groupRef, processe
|
|||||||
setIkSolver(solver);
|
setIkSolver(solver);
|
||||||
|
|
||||||
const helper = new CCDIKHelper(OOI.Skinned_Mesh, iks, 0.05);
|
const helper = new CCDIKHelper(OOI.Skinned_Mesh, iks, 0.05);
|
||||||
if (solver) {
|
// if (solver) {
|
||||||
const bone = solver.mesh.skeleton.bones.find(
|
// const bone = solver.mesh.skeleton.bones.find(
|
||||||
(b: any) => b.name === targetBoneName
|
// (b: any) => b.name === targetBoneName
|
||||||
) ?? "";
|
// ) ?? "";
|
||||||
if (bone) {
|
// if (bone) {
|
||||||
const position = new THREE.Vector3();
|
// const position = new THREE.Vector3();
|
||||||
bone.getWorldPosition(position);
|
// bone.getWorldPosition(position);
|
||||||
console.log("world position", position.x, position.y, position.z); // this is the bone's world position
|
// console.log("world position", position.x, position.y, position.z); // this is the bone's world position
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
scene.add(helper)
|
scene.add(helper)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ function RoboticArm() {
|
|||||||
const { armBots, addArmBot, removeArmBot } = useArmBotStore();
|
const { armBots, addArmBot, removeArmBot } = useArmBotStore();
|
||||||
const { floorItems } = useFloorItems();
|
const { floorItems } = useFloorItems();
|
||||||
|
|
||||||
|
|
||||||
const armBotStatusSample: RoboticArmEventSchema[] = [
|
const armBotStatusSample: RoboticArmEventSchema[] = [
|
||||||
{
|
{
|
||||||
state: "idle",
|
state: "idle",
|
||||||
modelUuid: "armbot-xyz-001",
|
modelUuid: "armbot-xyz-001",
|
||||||
modelName: "ArmBot-X200",
|
modelName: "ArmBot-X200",
|
||||||
position: [0, 0, 0],
|
position: [0.20849215906958463, 0, 0.32079278127773675],
|
||||||
rotation: [-3.141592653589793, 0.3861702258311774, -3.141592653589793],
|
rotation: [-1.3768690876192207e-15, 1.4883085074751308, 1.5407776675834467e-15],
|
||||||
type: "roboticArm",
|
type: "roboticArm",
|
||||||
speed: 1.5,
|
speed: 1.5,
|
||||||
point: {
|
point: {
|
||||||
|
|||||||
Reference in New Issue
Block a user