# Drive straight with IMU but not distance

**URL:** <https://xrp.discourse.group/t/drive-straight-with-imu-but-not-distance/441>\
**Category:** Coding\
**Created:** [July 19, 2024, 2:10pm UTC](https://xrp.discourse.group/t/drive-straight-with-imu-but-not-distance/441 "2024-07-19T14:10:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkaMrBill](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@AkaMrBill](https://xrp.discourse.group/u/AkaMrBill)\
**Post date:** [July 19, 2024, 2:10pm UTC](https://xrp.discourse.group/t/drive-straight-with-imu-but-not-distance/441/1 "2024-07-19T14:10:47Z")

</div>

There doesn’t appear to be a drive exampple that uses the IMU to keep the robot driving straight without also giving a distance. Is there a function I am missing that will do this, or is it something we will need to create ourselves?

---

<div class="post-metadata">

**Author:** ![AkaMrBill](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@AkaMrBill](https://xrp.discourse.group/u/AkaMrBill)\
**Post date:** [July 26, 2024, 10:31pm UTC](https://xrp.discourse.group/t/drive-straight-with-imu-but-not-distance/441/2 "2024-07-26T22:31:48Z")

</div>

The simple answer is: Write your own. Just use imu.getYaw(), do little math and gain and you are off to the races.
