I have been experimenting with odometry. In order to test my system, I would like to see the different variables in the program (current position, stuff like that). I have tried printing my position variable’s x and y coordinates along with the direction variable to my controller, but the controller always shows a large number for all three variables. When I printed to the vexcode console with printf and didn’t move the robot, the variables were all 0 (as they should be). Here is my controller print function:
int controllerprint(){ while(1){ //Startup menu //prints position if(mode == 0){ text1 = "Pos"; line1 = pos.getx(); text2 = "Pos"; line2 = pos.gety(); text3 = "Orientation"; line3 = 100; } else if(mode == 1){ text1 = "distance to idpos"; line1 = getdistpos(pos, idealpos); text2 = "Angle to pos"; line2 = getangpoints(pos, idealpos)*pi/180; text3 = "curvature to pos"; line3 = (dir - line2)*180/line1/pi; } else if(mode == 2){ text1 = "Age of Earth (years)"; line1 = 2020+4100; text2 = "Program name"; line2 = APScycle; text3 = "Team Name: 323S"; line3 = systime; } scrinput screen = scrinput(line1, line2, line3,text1, text2, text3); screen.printscreen(); task::sleep(50); }
I use a class to print my code. Here is my class definition:
class scrinput{
private:
double line1, line2, line3;
std::string text1, text2, text3;
public:
//constructor
scrinput(double, double, double, std::string, std::string, std::string){};
void printscreen(){
std::string string1 = text1 + " %f";
std::string string2 = text2 + " %f";
std::string string3 = text3 + " %f";
Controller1.Screen.clearScreen();
Controller1.Screen.setCursor(1,1);
Controller1.Screen.print(string1.c_str(), line1);
Controller1.Screen.newLine();
Controller1.Screen.print(string2.c_str(), line2);
Controller1.Screen.newLine();
Controller1.Screen.print(string3.c_str(), line3);
Controller1.Screen.newLine();
}
};