Can I transfer data from autonomous to driver control?

I am wondering if data transfers from autonomous to driver controls, like for example if I needed to know how far I traveled in autonomous so I can use it in the driver control program, is it possible? Or does it just pick up new values when it turns to driver control.

program do what you told it to do. but the question is why you want to do so.

1 Like

Any data can easily be moved between them by making global variables.

4 Likes

Because I am my teams programmer and I have nothing to do so I am experimenting with different things.

So if I create a variable and set it to something during autonomous that data will be there in the driver program?

As @tabor473 mentioned it needs to be in the Global scope of the program. That essentially means defined (declared) outside of any task or function.

//Declareing a variable in the global scope 
// that is available inside of any function.
// Could be a number, an array, or object.
int Distance = 10;  // << --- new variable

void pre_auton(void) {
  vexcodeInit();
}

void autonomous(void) {
  Distance = 20;  // <--- Being set here
}

void usercontrol(void) {
  while (1) {
    if(Distance == 20){  // << --- evaluated here.
      // pseudo code...
    }
    wait(20, msec); 
  }
}

int main() {
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);
  pre_auton();
  while (true) {
    wait(100, msec);
  }
}
1 Like