Error reading from sdcard

I am having an issue of reading from a .txt file using ifstream.
rn.txt is filled with velocity data from another function that writes data to SDcard which I have confirmed to work properly.

  std::ifstream inFile;"rn.txt");
  int vel[5];
  for (int i = 0; i < 1500; i+= 1) 
      inFile >> vel[0];
      LeftFrontMotor.spin(vex::directionType::fwd, vel[0], vex::velocityUnits::pct);
      LeftRearMotor.spin(vex::directionType::fwd, vel[0], vex::velocityUnits::pct);
      inFile >> vel[1];
      RightFrontMotor.spin(vex::directionType::fwd, vel[1], vex::velocityUnits::pct);
      RightRearMotor.spin(vex::directionType::fwd, vel[1], vex::velocityUnits::pct);
      inFile >> vel[2];
      Lift.spin(vex::directionType::fwd, vel[2], vex::velocityUnits::pct);
      inFile >> vel[3];
      Tilt.spin(vex::directionType::fwd, vel[3], vex::velocityUnits::pct);
      inFile >> vel[4];
      LeftIntake.spin(vex::directionType::fwd, vel[4], vex::velocityUnits::pct);
      RightIntake.spin(vex::directionType::fwd, vel[4], vex::velocityUnits::pct);


Even though the program is supposed to playback the data loaded from the file, when I try to run this program one side of the robot moves slightly but not of the other motors move. Am I using the correct syntax?

Not sure on syntax, but I see that someone is trying a new rerun method. Very interesting.

1 Like

Yea, our old playback version has a limit of how much data it can load because of the small amount of free RAM in the Brain. It loaded all of the data, stored at uint_8, off of the SDcard at one time and then played back, but it could only load a bit over 6000 values at one time. That is fine for shorter records and playbacks but for a longer playback (skills 60s) we want more values to maintain accuracy. Rather than ~100ms increments per motor group we would like ~10ms increments.

User programs have access to 72MB of memory, that really should be enough. However, unless you start messing with the build scripts in VEXcode, you need to access most of that using global variables, it sounds like you were trying to use local memory, each thread has a very limited amount of stack available for local variables. Switch over to using dynamic memory or globals.


I ran the code posted above and it worked this time so I’m not sure if I ran it correctly the first time.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.