Controller printing obscure large number

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(){
  //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);

I use a class to print my code. Here is my class definition:

class scrinput{
      double line1, line2, line3;
      std::string text1, text2, text3;

      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.print(string1.c_str(), line1);
        Controller1.Screen.print(string2.c_str(), line2);
        Controller1.Screen.print(string3.c_str(), line3);


None of your class members actually get initialized.

1 Like

Would it be something like this?

scrinput(double, double, double,  std::string, std::string, std::string);
  scrinput(): line1(0.0), line2(0.0), line3(0.0), text1(""), text2(""), text3(""){};

I just looked up initialization online and coded it.

Edit: I will post the code that worked for me just in case anyone else has the same problem
I changed the constructor for my class to this:

scrinput(double a, double b, double c, std::string A, std::string B, std::string C): line1(a), line2(b), line3(c), text1(A), text2(B), text3(C){};