I agree with you, two functions sounds a better approach.
As Mike Said, it is difficult to determine if it has turned or moved 100 meter. However, It may be possible to use digital compass for this as I heard that it is used to measure the rotation of objects like motors.
the other challenge might be the obstacle. for example, if it turned 45 degrees and moved 10 meters and sees a wall, still need to travel 90 meters after passing the wall. so it looks for a way to pass the wall. any recommendations in this point?
However, It may be possible to use digital compass for this as I heard that it is used to measure the rotation of objects like motors.
Not unless the magnetic field of the motor interferes in some repeatable way with the compass.
A compass can give an indication of direction, but not distance.
For that you need an odometer or a location-finding mechanism like GPS.
I agree with you, two functions sounds a better approach.
As Mike Said, it is difficult to determine if it has turned or moved 100 meter. However, It may be possible to use digital compass for this as I heard that it is used to measure the rotation of objects like motors.
the other challenge might be the obstacle. for example, if it turned 45 degrees and moved 10 meters and sees a wall, still need to travel 90 meters after passing the wall. so it looks for a way to pass the wall. any recommendations in this point?
Kind regards
Look up "rotary encoders" and "Gray codes", as this is what is typically used to figure out distance and rotation. Well, you will have to figure out the obstacle avoidance and wall-following stuff. But you are nowhere unless you know how many turns a wheel has taken, or in what direction a steering mechanism has turned you.
GPS may not work well indoors, but differentiial GPS is capable of very much better than 5metre accuracy.
(when you wrote earlier of tens of metres, I assumed outdoors)
This approach is what I'd call dead reckoning - you turn the wheels the right amount and assume the 'bot has turned/moved the corresponding amount. This doesn't account for any slip, or inaccuracy in measuring/calculating the amount the wheel has moved. It is preferable to measure the orientation and position directly as this enables you to compensate for any errors or inaccuracy in the movement. But getting an accurate measurement of orientation and position is hard on a small scale.
Some markers (e.g. beacons, RFID tags, sensors, camera etc) would also help to find the relative position in the field. Especially easy to set up if the action happens indoors.
If you want your robot to work indoors on flat and hard surface you can use mouse sensor to calculate position and heading of robot in relation to starting point.
My robot demonstrates this approach in those videos: