I am trying to move the robot with a compass. We use a compass to make the robot move in a straight line, it uses 2 wheels, and they are slightly different from each other. Therefore, we set the value from 0 to 359 in the direction, and then check the current direction, calculate the error and fix it. Like error = current_direction is the actual direction.
The problem is that if, for example, our init direction is 90 degrees, and our robot is 45, the error will be 45, and this will fix it. If it is 0, the error will be 90, and it will fix it. The problem is that if it moves a little more than 0, and, for example, to 359, the error will be -269, so instead of moving 90 in one direction, it will move -269 in the other.
I use the error sign to decide which wheel to move to fix the direction. any idea how to fix it?
robotics mindstorms compass-geolocation lego nxt
Dr sokoban
source share