refactor: Improve path computation logic and enhance error handling in VehicleInstance; add debug logs in UserAuth for API response
This commit is contained in:
parent
6c8eb7d2f3
commit
4d77aa6a99
|
@ -48,14 +48,24 @@ function VehicleInstance({ agvDetail }: Readonly<{ agvDetail: VehicleStatus }>)
|
||||||
|
|
||||||
const computePath = useCallback(
|
const computePath = useCallback(
|
||||||
(start: any, end: any) => {
|
(start: any, end: any) => {
|
||||||
|
console.log('end: ', end);
|
||||||
try {
|
try {
|
||||||
const navMeshQuery = new NavMeshQuery(navMesh);
|
const navMeshQuery = new NavMeshQuery(navMesh);
|
||||||
const { path: segmentPath } = navMeshQuery.computePath(start, end);
|
const { path: segmentPath } = navMeshQuery.computePath(start, end);
|
||||||
return (
|
if (
|
||||||
segmentPath?.map(({ x, y, z }) => [x, 0, z] as [number, number, number]) || []
|
segmentPath.length > 0 &&
|
||||||
);
|
Math.round(segmentPath[segmentPath.length - 1].x) == Math.round(end.x) &&
|
||||||
|
Math.round(segmentPath[segmentPath.length - 1].z) == Math.round(end.z)
|
||||||
|
) {
|
||||||
|
console.log('if ', segmentPath);
|
||||||
|
return segmentPath?.map(({ x, y, z }) => [x, 0, z] as [number, number, number]) || [];
|
||||||
|
} else {
|
||||||
|
console.log("There is no path here...Choose valid path")
|
||||||
|
const { path: segmentPaths } = navMeshQuery.computePath(start, start);
|
||||||
|
return segmentPaths.map(({ x, y, z }) => [x, 0, z] as [number, number, number]) || [];
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
echo.error("Failed to compute path");
|
console.error("Failed to compute path");
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -96,6 +106,10 @@ function VehicleInstance({ agvDetail }: Readonly<{ agvDetail: VehicleStatus }>)
|
||||||
new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2]),
|
new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2]),
|
||||||
agvDetail?.point?.action?.pickUpPoint?.position
|
agvDetail?.point?.action?.pickUpPoint?.position
|
||||||
);
|
);
|
||||||
|
// const toPickupPath = computePath(
|
||||||
|
// new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2]),
|
||||||
|
// new THREE.Vector3(agvDetail?.position[0], agvDetail?.position[1], agvDetail?.position[2])
|
||||||
|
// );
|
||||||
setPath(toPickupPath);
|
setPath(toPickupPath);
|
||||||
setCurrentPhase('stationed-pickup');
|
setCurrentPhase('stationed-pickup');
|
||||||
setVehicleState(agvDetail.modelUuid, 'running');
|
setVehicleState(agvDetail.modelUuid, 'running');
|
||||||
|
|
|
@ -45,6 +45,7 @@ const UserAuth: React.FC = () => {
|
||||||
const organization = email.split("@")[1].split(".")[0];
|
const organization = email.split("@")[1].split(".")[0];
|
||||||
try {
|
try {
|
||||||
const res = await signInApi(email, password, organization, fingerprint);
|
const res = await signInApi(email, password, organization, fingerprint);
|
||||||
|
console.log('res: ', res);
|
||||||
if (res.message.message === "login successfull") {
|
if (res.message.message === "login successfull") {
|
||||||
setError("");
|
setError("");
|
||||||
setOrganization(organization);
|
setOrganization(organization);
|
||||||
|
@ -59,14 +60,13 @@ const UserAuth: React.FC = () => {
|
||||||
try {
|
try {
|
||||||
const projects = await recentlyViewed(organization, res.message.userId);
|
const projects = await recentlyViewed(organization, res.message.userId);
|
||||||
|
|
||||||
if (Object.values(projects.RecentlyViewed).length > 0) {
|
if (res.message.isShare) {
|
||||||
const firstId = (Object.values(projects?.RecentlyViewed || {})[0] as any)?._id;
|
if (Object.values(projects.RecentlyViewed).length > 0) {
|
||||||
setLoadingProgress(1)
|
const firstId = (Object.values(projects?.RecentlyViewed || {})[0] as any)?._id;
|
||||||
navigate(`/${firstId}`)
|
setLoadingProgress(1)
|
||||||
} else {
|
navigate(`/${firstId}`)
|
||||||
if (res.message.isShare) {
|
} else {
|
||||||
setLoadingProgress(1);
|
setLoadingProgress(1);
|
||||||
// navigate("/Project");
|
|
||||||
navigate("/Dashboard");
|
navigate("/Dashboard");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue