acmerobotics / road-runner

Wheeled mobile robot motion planning library designed for FTC
MIT License
209 stars 75 forks source link

Ramsete Follower not working due to wrong angle error calculation #63

Closed AJahueyM closed 3 years ago

AJahueyM commented 3 years ago

64

We have been using your library for our robot! We have really liked it. We are using a tank chassis and found out an error with the Ramsete Follower, it only appeared when we started from 0,0 and went into some target with negative Y coordinate.

Making a custom Ramsete follower that does the following when caluclating the error solved the issue:

    var angleError = targetPose.heading - currentPose.heading

    if(angleError.absoluteValue > PI){
        angleError -= 2 * PI * angleError.sign
    }

    val error = Pose2d(targetPose.x - currentPose.x, targetPose.y - currentPose.y, angleError)

I looked into the implementation of the minus operation for the Pose2d and saw that it simply substracts one angle from the other. Maybe implementing something like we showed could fix it?