Hi. I found a code on github, that uses odometry, and has an auto-aim ability. I am wondering how I can implement this into my own code. I already have a working odom, but I am struggling with the auto aim part. I took the part from the github code, but I want to understand it and make it work before I redo it, because I do not copy code for competitions. I will attach a photo that will have the code. All I am trying to figure out is if I make it work like any other function, with it working with pressed(), and I also am trying to figure out what aac is and what I have to do with it. Thank you for the help!
void AutoAim(){
double aac;
double YendOfField = 135;
double XendofField = X;
double Xgoal = 15;
double Ygoal = 119;
double lengthOfArc1;
double lengthOfArc2;
double lengthOfArc3;
double angleToGoal;
double robotToGoal;
lengthOfArc1 = 135 - Y; //a
lengthOfArc2 = sqrt((X - Xgoal)*(X - Xgoal)+(Y - Ygoal)*(Y - Ygoal)); //b
lengthOfArc3 = sqrt((Xgoal - XendofField)*(Xgoal - XendofField)+(Ygoal - YendOfField)*(Ygoal - YendOfField)); //c
angleToGoal = acos((lengthOfArc2)*(lengthOfArc2)+(lengthOfArc3)*(lengthOfArc3)-(lengthOfArc1)*(lengthOfArc1)/(2*lengthOfArc2)*(lengthOfArc3));
robotToGoal = angleToGoal - OdomHeading;
std::cout<<lengthOfArc1;
std::cout<<lengthOfArc2;
std::cout<<lengthOfArc3;
}