I am trying to show the distance traveled by 3pi on the LCD Screen. However, in set_motors, the specification is duty cycle. Is there a way to convert duty cycle to velocity so I can use the time to calculate the distance traveled.
Even in this case, I believe the result will be what the distance “should be” instead of what it actually is.
Is having additional sensors the only way to do this accurately?
We do not have a great solution for sensing traveled distance accurately with the 3pi. While it is possible to empirically derive the distance traveled for a given duty cycle and run time, you seem to understand the limitations of that approach. Over time, integration errors inherent with dead reckoning will accumulate and the robot will no longer have an accurate sense of its position. This forum post, where another 3pi owner added encoders for more accurate positioning might be interesting to you.