timeout added
This commit is contained in:
parent
dc77d9ed43
commit
6bf53bf72c
|
@ -53,7 +53,7 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||
if (isPlaying) {
|
||||
//Moving armBot from initial point to rest position.
|
||||
if (!robot?.isActive && robot?.state == "idle" && currentPhase == "init") {
|
||||
|
||||
|
||||
setArmBotActive(robot.modelUuid, true)
|
||||
setArmBotState(robot.modelUuid, "running")
|
||||
setCurrentPhase("init-to-rest");
|
||||
|
@ -63,7 +63,7 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||
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.
|
||||
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) {
|
||||
setArmBotActive(robot.modelUuid, true);
|
||||
|
@ -99,10 +99,13 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||
new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2])
|
||||
);
|
||||
if (curve) {
|
||||
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
||||
setTimeout(() => {
|
||||
logStatus(robot.modelUuid, "waiting to pick box");
|
||||
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) {
|
||||
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
|
||||
);
|
||||
if (curve) {
|
||||
setPath(curve.points.map(point => [point.x, point.y, point.z]));
|
||||
setTimeout(() => {
|
||||
logStatus(robot.modelUuid, "waiting to drop box");
|
||||
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 = () => {
|
||||
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)
|
||||
setArmBotState(robot.modelUuid, "idle")
|
||||
setCurrentPhase("rest");
|
||||
setPath([])
|
||||
}
|
||||
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)
|
||||
setArmBotState(robot.modelUuid, "idle")
|
||||
setCurrentPhase("picking");
|
||||
setPath([])
|
||||
}
|
||||
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)
|
||||
setArmBotState(robot.modelUuid, "idle")
|
||||
setCurrentPhase("dropping");
|
||||
setPath([])
|
||||
}
|
||||
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)
|
||||
setArmBotState(robot.modelUuid, "idle")
|
||||
setCurrentPhase("rest");
|
||||
|
@ -164,12 +170,11 @@ function RoboticArmInstance({ robot }: { robot: ArmBotStatus }) {
|
|||
}
|
||||
}
|
||||
const logStatus = (id: string, status: string) => {
|
||||
console.log(id +","+ status);
|
||||
console.log(id + "," + status);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<IKInstance modelUrl={armModel} setIkSolver={setIkSolver} ikSolver={ikSolver} robot={robot} groupRef={groupRef} processes={processes}
|
||||
setArmBotCurvePoints={setArmBotCurvePoints} />
|
||||
<RoboticArmAnimator armUuid={robot?.modelUuid} HandleCallback={HandleCallback}
|
||||
|
|
|
@ -15,7 +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();
|
||||
|
@ -66,16 +66,16 @@ function IKInstance({ modelUrl, setIkSolver, ikSolver, robot, groupRef, processe
|
|||
setIkSolver(solver);
|
||||
|
||||
const helper = new CCDIKHelper(OOI.Skinned_Mesh, iks, 0.05);
|
||||
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
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
|
||||
|
||||
|
|
|
@ -6,14 +6,15 @@ import { useFloorItems } from "../../../store/store";
|
|||
function RoboticArm() {
|
||||
const { armBots, addArmBot, removeArmBot } = useArmBotStore();
|
||||
const { floorItems } = useFloorItems();
|
||||
|
||||
|
||||
const armBotStatusSample: RoboticArmEventSchema[] = [
|
||||
{
|
||||
state: "idle",
|
||||
modelUuid: "armbot-xyz-001",
|
||||
modelName: "ArmBot-X200",
|
||||
position: [0, 0, 0],
|
||||
rotation: [-3.141592653589793, 0.3861702258311774, -3.141592653589793],
|
||||
position: [0.20849215906958463, 0, 0.32079278127773675],
|
||||
rotation: [-1.3768690876192207e-15, 1.4883085074751308, 1.5407776675834467e-15],
|
||||
type: "roboticArm",
|
||||
speed: 1.5,
|
||||
point: {
|
||||
|
|
Loading…
Reference in New Issue