Motor having trouble moving C++

In short, there are instances where some motors are having trouble going to the goal position and it’s stuck in the while loop. For example motor 3 is at 386 but it needs to get to 387 but it gets stuck in the loop and stays at 386. I have the minimum threshold value set to 0 so it should be able to move there, even in the while statement where I have goal_position - current_position > 0, regardless of what number I change that to it’s get stuck trying to move towards the end. I have been able to mitigate this by having a break statement if all motors have been at the same position for more than x counts but it looks like it’s not that reliable nor efficient enough since the overall movement has been jerky

I’m using the sync write example as the basic of the code but expanded for 7 motors.


Due to the characteristics of PID controller, there could be some error between the Goal Position and the Present Position especially when there is a load at the output horn.
In order to reduce the marginal error, you could adjust the PID position gains, but still there could be a couple ticks of margin depending on the hardware configuration.
Thank you.