I have seen that drivetopoint is basically just calling a turntoangle and moveDistance with the two parameters but while trying to use it I was having some trouble. Which parameters in driveToPoint(x_ft,y_ft) give you the turn angle and which one the distance and is there a way to calculate the distance with the two parameters so that if I gave it two arguments, I’d be able to calculate the distance and turn angle before I run the code?
If you know your current position, and the new position, use the distance formula or Pythagorean theorem to find distance. If you know the angle before, it is just some symple trig to get the turn to angle part
@Z3us1029 Welcome to the forums.
Thanks for the response, I just have one other question,
Would an example like
turn the robot 45 degrees then drive forward 6 feet? or would that be something I would need to test myself when I get the chance?
Those function use the built in odometry so what the robot does would depend on where the robot thought it was. Assuming your position tracking is accurate, this can lead to more reliable autons.
Certainly from a readability standpoint I find it easier to understand autons that reference coordinates rather than turn-and-move statements
No. Just from looking at that statement, we don’t know what it will do. The current position of the robot is also important. For example, if your robot is at (0, 5, π÷2), and you say to drive to (1, 6), the robot will turn right 45°, then move 2•√2 distance
However, if you are at (1, 5, π÷2) and say to go to (1,6), it would turn right on 90°, and then move one unit
I guess I need a better understanding of driveToPoint then