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;
inFile.open("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);
vex::task::sleep(10);
}
inFile.close();
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?