← General Discussion
대나무 가을@bambooinautumn· 703 views

robodk new drive creation

Movement and Issues

The linker movement is fine.. but if you do the same movement twice, it moves again and the third error remains

It seems like there is no position comparison statement for the movement on the board

I'm still working on fixing it to catch the error. I don't really know.

// 이전 위치 저장용 (글로벌 변수로 선언)

float lastX, lastY, lastZ, lastRz, lastRy, lastRx;

// tolerance 설정

const float coordTolerance = 0.01;

bool isSamePosition(float x, float y, float z, float rz, float ry, float rx) {

return (fabs(x - lastX) < coordTolerance &&

fabs(y - lastY) < coordTolerance &&

fabs(z - lastZ) < coordTolerance &&

fabs(rz - lastRz) < coordTolerance &&

fabs(ry - lastRy) < coordTolerance &&

fabs(rx - lastRx) < coordTolerance);

}

=================

if (isSamePosition(x, y, z, rz, ry, rx)) {

Serial.println("Same position - skipping move.");

return; // 현재 위치와 같으면 이동 생략

}

// 이동 실행 후 현재 위치 저장

lastX = x; lastY = y; lastZ = z;

lastRz = rz; lastRy = ry; lastRx = rx;

Comment

No comments yet.

Photos