How best to build a function that precisely turns my robot to a specific heading relative to the original 0? #2084
Answered
by
dlech
TheWanderingShadow
asked this question in
Q&A
-
|
Currently I use: def yaw_angle_turn(angle):
if angle > hub.imu.heading():
while hub.imu.heading() < angle:
drive_base.drive(50,90)
else:
while hub.imu.heading() > angle:
drive_base.drive(50,-90)
drive_base.stop()but sometimes it skips past my target angle. |
Beta Was this translation helpful? Give feedback.
Answered by
dlech
Feb 22, 2025
Replies: 1 comment 2 replies
-
|
You can use use_gyro to automatically use the gyro in drive base operation. Then you can use turn to turn in place or curve to drive along a curve to a specific angle. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
hub.imu.heading()to find the current heading and subtract that from the desired heading to get the angle you need to turn.