[Tutorial] How to Code a VEX Autonomous in Less than 5 Minutes

Nope. I created it the night before. On my laptop. The code just edits the file, not creates it.

One last question, then you’re good to go:


What happens if there is already text in the file at the start of the program, and why?

Already something in the file at10 sec in?

20 Days?

1 Like

Ri20d

Ok, you’ve got me there! I should’ve paid more attention!

I’m glad you asked. If you haven’t watched full video five times yet, like I did, I recommend you do - the answer is right there at 7:20 and 10:10.

The first time it opens the file with “w” command to wipe it clean. Then in the loop it opens the file with “a” append command and adds more lines to what’s already there.

5 Likes

Answer the other two questions.

*The code could create the file, but it’s not ATM

You said to answer one last question, which I did.

Beside, I don’t understand what you mean by “at10 sec in” and “20 Days”.

If you mean what happens if you run the program for 10 seconds and then inserted microsd, then it will keep adding new lines without wiping the file clean. That happens only if you inserted card before starting your program. It wipes it clean only once at the beginning of your program.

What happens if you run program for 20 days with card inserted?

150 characters every 10 milliseconds times 60 seconds times 60 minutes times 24 hours times 20 days

That is 25,920,000,000 bytes!

You better have 32Gb sd card and super duper gaming laptop to copy & paste so much Rerun Stuffz.

5 Likes

That’s the point with the 20 days. To test common sense. You passed. Feel free to use it. Me and someone else might make a PROS template for it.

2 Likes

LOL

Common sense, @technik3k, and @lacsap say to stay away from your code until you get your rerun file down to sane size.

1 Like

It is a sane size. It’s small enough to manage, that’s enough right? Put it in a new file and forget about it.

actually, brute force is an acceptable first start. I did more looking vs my “know it all” attitude and the approach is honest and straightforward. It also represents what most go for with time based solutions - then they realize EPs are spraying fields with goop designed to slow robots down… and don;'t forget robots who get smashed up a bit and have no parallel drive structure.

Look, I was wrong about my early critique. We should not make it “here is a play loop so you do not code” but this is a nice way to show what happens when you record motion and try to make it an autonomous. It might not be pretty to look at, but it is a start as others have said. By exposing the code it hopefully encourages new teams to think “I get this” and, hopefully, “there is a better way”.

The tutorial is honest and a good teaching tool.

Thank you @TaranMayer for providing the catalyst for a great discussion!

7 Likes

Also here, unlike with Cortex which would use power output, my rerun records actual velocity. Not voltage, not velocity set to, but the ACTUAL velocity the motors are moving at. So in theory, I could push the bot around and it would record the movement.

4 Likes

That is not the biggest reason (pun intended) to be cautious about this approach.

As @lacsap pointed out, the more important reasons are variability of the fields on which you test and compete due to anti-static application, field setup tolerances, robots starting to fall apart after collisions, etc… which time based reruns may not handle well.

That is a very simple yet effective way of improving accuracy without starting to make code more complicated. Special handling of the claw motor was also a nice touch.

Simple reliable time based autonomous could work better than the poorly configured PID based code. However, well written code that relies on the feedback from various sensors to do odometry and PID control, will undoubtedly work better in all circumstances.

The best part of @TaranMayer’s tutorial is that it demystifies “rerun” capability and shows how little you need to get started. It is also shows how you can streamline your workflow to the point when you can come to the untested field and walk away with working autonomous in less than 5 minutes of the field time.

Another “best” part, is how ridiculously large and inefficient is the auto-generated code. I hope that every team that tries it, will start researching ways of improving on it, thus the benefits of active learning.

You did very well answering tough questions and explaining how this method works. It looks like @TaranMayer’s tutorial did great job at helping you and everyone else learn something new today.

And finally, to be pedantic, V5 only supports SD Cards with FAT32 file systems tested up to 16Gb and with 4Gb max file size, so no 20 day runs. Sorry to ruin your expectations. :slight_smile:

4 Likes

I’ve been using 64GB SD card in my brain no problem.
Though I have not tried writing anything nearly that large :wink:

1 Like

Just want to point out that teams have been using replay/rerun programs for as long as I can remember. I can’t find the one I posted perhaps 6 or 7 years ago, but here is an example from one of our former competitors who did quite well :slight_smile:

9 Likes

I am about to test a method that should reduce file size by a large amount


Do you have any constructive criticism of the video? That’s always helpful.

1 Like
		flSpeed = lf.get_actual_velocity();
		blSpeed = lb.get_actual_velocity();
		frSpeed = rf.get_actual_velocity();
		brSpeed = rb.get_actual_velocity();
		armSpeed = arm.get_actual_velocity();
		clawSpeed = claw.get_target_velocity();

		flenc = lf.get_position();
		blenc = lb.get_position();
		frenc = rf.get_position();
		brenc = rb.get_position();
		armenc = arm.get_position();
		clawenc = claw.get_position();

		FILE* usd_file_write = fopen("/usd/rerun.txt", "a");

		if (flSpeedold != flSpeed) {
			fprintf(usd_file_write, "lf.move_velocity(%i); \n", flSpeed);
			flSpeedold = flSpeed;
			mfl = true;
		}
		else {
			mfl = false;
		}
		if (blSpeedold != blSpeed) {
			fprintf(usd_file_write, "lb.move_velocity(%i); \n", blSpeed);
			blSpeedold = blSpeed;
			mbl = true;
		}
		else {
			mbl = false;
		}
		if (frSpeedold != frSpeed) {
			fprintf(usd_file_write, "rf.move_velocity(%i); \n", frSpeed);
			frSpeedold = frSpeed;
			mfr = true;
		}
		else {
			mfr = false;
		}
		if (brSpeedold != brSpeed) {
			fprintf(usd_file_write, "rb.move_velocity(%i); \n", brSpeed);
			brSpeedold = brSpeed;
			mbr = true;
		}
		else {
			mbr = false;
		}
		if (armSpeedold != armSpeed) {
			fprintf(usd_file_write, "arm.move_velocity(%i); \n", armSpeed);
			armSpeedold = armSpeed;
			marm = true;
		}
		else {
			marm = false;
		}
		if (clawSpeedold != clawSpeed) {
			fprintf(usd_file_write, "claw.move_velocity(%i); \n", clawSpeed);
			clawSpeedold = clawSpeed;
			mclaw = true;
		}
		else {
			mclaw = false;
		}

		timeNew = pros::millis();
		deltaTime = timeNew - timeOld;
		timeOld = pros::millis();

		fprintf(usd_file_write, "delay(%d); \n", deltaTime);

I’m using this now. Much longer but will output stuff like this instead:

A long text file
lf.move_velocity(0); 
lb.move_velocity(0); 
rf.move_velocity(0); 
rb.move_velocity(0); 
arm.move_velocity(0); 
claw.move_velocity(0); 
delay(165); 
delay(21); 
delay(18); 
delay(23); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(18); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(17); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(18); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(17); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(17); 
delay(17); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(16); 
rb.move_velocity(-2); 
delay(18); 
delay(16); 
rb.move_velocity(-6); 
delay(18); 
rb.move_velocity(-12); 
delay(18); 
rb.move_velocity(-14); 
delay(16); 
rf.move_velocity(-4); 
rb.move_velocity(-17); 
delay(18); 
rb.move_velocity(-20); 
delay(16); 
rb.move_velocity(-27); 
delay(18); 
rb.move_velocity(-30); 
delay(17); 
rf.move_velocity(-13); 
rb.move_velocity(-32); 
delay(17); 
rf.move_velocity(-15); 
rb.move_velocity(-34); 
delay(18); 
rf.move_velocity(-20); 
rb.move_velocity(-40); 
delay(17); 
rf.move_velocity(-22); 
rb.move_velocity(-44); 
delay(17); 
rf.move_velocity(-26); 
rb.move_velocity(-43); 
delay(18); 
lb.move_velocity(6); 
delay(16); 
rf.move_velocity(-29); 
rb.move_velocity(-47); 
delay(18); 
rf.move_velocity(-34); 
rb.move_velocity(-51); 
delay(16); 
rf.move_velocity(-36); 
rb.move_velocity(-53); 
delay(18); 
rf.move_velocity(-37); 
rb.move_velocity(-56); 
delay(16); 
rf.move_velocity(-41); 
rb.move_velocity(-55); 
delay(18); 
rb.move_velocity(-54); 
delay(16); 
rf.move_velocity(-42); 
rb.move_velocity(-55); 
delay(18); 
lb.move_velocity(0); 
rb.move_velocity(-58); 
delay(16); 
rf.move_velocity(-44); 
rb.move_velocity(-57); 
delay(18); 
rf.move_velocity(-45); 
rb.move_velocity(-56); 
delay(18); 
rf.move_velocity(-44); 
rb.move_velocity(-52); 
delay(17); 
rf.move_velocity(-42); 
delay(17); 
rf.move_velocity(-44); 
rb.move_velocity(-53); 
delay(17); 
rf.move_velocity(-43); 
rb.move_velocity(-52); 
delay(17); 
rf.move_velocity(-41); 
rb.move_velocity(-50); 
delay(17); 
rf.move_velocity(-37); 
rb.move_velocity(-47); 
delay(17); 
rf.move_velocity(-36); 
rb.move_velocity(-44); 
delay(17); 
rf.move_velocity(-32); 
delay(18); 
rf.move_velocity(-29); 
rb.move_velocity(-41); 
delay(17); 
rf.move_velocity(-28); 
rb.move_velocity(-39); 
delay(17); 
rf.move_velocity(-25); 
rb.move_velocity(-38); 
delay(17); 
rf.move_velocity(-23); 
rb.move_velocity(-36); 
delay(17); 
rf.move_velocity(-19); 
rb.move_velocity(-31); 
delay(17); 
rf.move_velocity(-17); 
rb.move_velocity(-30); 
delay(18); 
lb.move_velocity(-10); 
rf.move_velocity(-12); 
rb.move_velocity(-24); 
delay(17); 
rf.move_velocity(-8); 
rb.move_velocity(-22); 
delay(18); 
lb.move_velocity(-12); 
rb.move_velocity(-19); 
delay(17); 
lf.move_velocity(-2); 
lb.move_velocity(-23); 
rb.move_velocity(-17); 
delay(17); 
lf.move_velocity(-3); 
lb.move_velocity(-30); 
rf.move_velocity(-7); 
rb.move_velocity(-12); 
delay(17); 
lf.move_velocity(-8); 
lb.move_velocity(-24); 
rf.move_velocity(-6); 
rb.move_velocity(-9); 
delay(17); 
lf.move_velocity(-12); 
lb.move_velocity(-22); 
rb.move_velocity(-7); 
delay(17); 
lf.move_velocity(-16); 
lb.move_velocity(-20); 
rf.move_velocity(-4); 
rb.move_velocity(-2); 
delay(17); 
lf.move_velocity(-19); 
lb.move_velocity(-16); 
delay(18); 
lf.move_velocity(-24); 
lb.move_velocity(-15); 
rf.move_velocity(0); 
delay(17); 
lf.move_velocity(-27); 
lb.move_velocity(-18); 
rb.move_velocity(-1); 
delay(17); 
lf.move_velocity(-26); 
lb.move_velocity(-22); 
delay(17); 
lb.move_velocity(-26); 
rb.move_velocity(0); 
delay(17); 
lf.move_velocity(-25); 
delay(17); 
lf.move_velocity(-23); 
lb.move_velocity(-28); 
rb.move_velocity(9); 
delay(17); 
lf.move_velocity(-20); 
lb.move_velocity(-34); 
rb.move_velocity(25); 
delay(17); 
lf.move_velocity(-14); 
lb.move_velocity(-35); 
rb.move_velocity(33); 
delay(18); 
lf.move_velocity(-13); 
rb.move_velocity(32); 
delay(17); 
lf.move_velocity(-10); 
lb.move_velocity(-40); 
rb.move_velocity(29); 
delay(17); 
lf.move_velocity(-7); 
lb.move_velocity(-44); 
rb.move_velocity(31); 
delay(16); 
lb.move_velocity(-46); 
rb.move_velocity(33); 
delay(18); 
rb.move_velocity(37); 
delay(16); 
lf.move_velocity(-9); 
rb.move_velocity(36); 
delay(18); 
lf.move_velocity(-15); 
lb.move_velocity(-47); 
rb.move_velocity(34); 
delay(18); 
lf.move_velocity(-18); 
delay(17); 
lf.move_velocity(-24); 
lb.move_velocity(-49); 
rb.move_velocity(39); 
delay(17); 
lf.move_velocity(-31); 
lb.move_velocity(-51); 
rb.move_velocity(45); 
delay(16); 
lf.move_velocity(-33); 
delay(18); 
lf.move_velocity(-37); 
lb.move_velocity(-54); 
delay(17); 
lf.move_velocity(-42); 
lb.move_velocity(-56); 
rb.move_velocity(43); 
delay(17); 
lf.move_velocity(-48); 
lb.move_velocity(-58); 
rb.move_velocity(42); 
delay(18); 
lf.move_velocity(-50); 
lb.move_velocity(-57); 
delay(18); 
lb.move_velocity(-56); 
rb.move_velocity(47); 
delay(17); 
lf.move_velocity(-53); 
lb.move_velocity(-57); 
rb.move_velocity(49); 
delay(17); 
lf.move_velocity(-55); 
lb.move_velocity(-59); 
rb.move_velocity(50); 
delay(16); 
lb.move_velocity(-64); 
rb.move_velocity(53); 
delay(18); 
lb.move_velocity(-63); 
rb.move_velocity(55); 
delay(17); 
lf.move_velocity(-56); 
lb.move_velocity(-59); 
delay(17); 
lf.move_velocity(-60); 
rb.move_velocity(57); 
delay(18); 
lf.move_velocity(-59); 
lb.move_velocity(-62); 
rb.move_velocity(58); 
delay(17); 
lf.move_velocity(-54); 
lb.move_velocity(-65); 
rb.move_velocity(59); 
delay(17); 
lf.move_velocity(-57); 
lb.move_velocity(-64); 
rb.move_velocity(58); 
delay(16); 
lf.move_velocity(-62); 
lb.move_velocity(-58); 
rb.move_velocity(59); 
delay(18); 
lf.move_velocity(-63); 
lb.move_velocity(-60); 
rb.move_velocity(61); 
delay(17); 
lf.move_velocity(-65); 
lb.move_velocity(-64); 
delay(18); 
lb.move_velocity(-66); 
rb.move_velocity(62); 
delay(17); 
lf.move_velocity(-66); 
lb.move_velocity(-65); 
delay(17); 
lf.move_velocity(-61); 
lb.move_velocity(-64); 
rb.move_velocity(63); 
delay(17); 
lf.move_velocity(-64); 
rb.move_velocity(64); 
delay(16); 
lb.move_velocity(-65); 
rb.move_velocity(63); 
delay(18); 
rb.move_velocity(62); 
delay(17); 
lf.move_velocity(-66); 
lb.move_velocity(-64); 
rb.move_velocity(64); 
delay(17); 
lf.move_velocity(-67); 
lb.move_velocity(-66); 
rb.move_velocity(65); 
delay(18); 
lf.move_velocity(-70); 
lb.move_velocity(-71); 
rb.move_velocity(63); 
delay(17); 
lf.move_velocity(-68); 
lb.move_velocity(-69); 
rb.move_velocity(68); 
delay(17); 
lf.move_velocity(-70); 
lb.move_velocity(-70); 
rb.move_velocity(70); 
delay(17); 
lf.move_velocity(-68); 
rb.move_velocity(74); 
delay(17); 
lf.move_velocity(-69); 
lb.move_velocity(-74); 
rb.move_velocity(73); 
delay(18); 
lf.move_velocity(-73); 
lb.move_velocity(-76); 
rb.move_velocity(71); 
delay(17); 
lf.move_velocity(-72); 
lb.move_velocity(-77); 
delay(18); 
lf.move_velocity(-70); 
rb.move_velocity(72); 
delay(17); 
lf.move_velocity(-75); 
lb.move_velocity(-78); 
rb.move_velocity(75); 
delay(17); 
lf.move_velocity(-73); 
lb.move_velocity(-82); 
rb.move_velocity(82); 
delay(17); 
lf.move_velocity(-76); 
lb.move_velocity(-83); 
rb.move_velocity(80); 
delay(17); 
lf.move_velocity(-78); 
lb.move_velocity(-78); 
delay(17); 
lf.move_velocity(-79); 
lb.move_velocity(-82); 
delay(17); 
rb.move_velocity(81); 
delay(18); 
lb.move_velocity(-83); 
rb.move_velocity(82); 
delay(17); 
lf.move_velocity(-78); 
lb.move_velocity(-82); 
rb.move_velocity(81); 
delay(17); 
lf.move_velocity(-79); 
lb.move_velocity(-86); 
delay(17); 
lb.move_velocity(-85); 
rb.move_velocity(80); 
delay(16); 
lf.move_velocity(-81); 
lb.move_velocity(-86); 
rb.move_velocity(82); 
delay(18); 
lf.move_velocity(-80); 
lb.move_velocity(-88); 
rb.move_velocity(85); 
delay(17); 
lf.move_velocity(-85); 
lb.move_velocity(-84); 
rb.move_velocity(86); 
delay(17); 
lf.move_velocity(-84); 
lb.move_velocity(-85); 
rb.move_velocity(84); 
delay(18); 
lf.move_velocity(-86); 
lb.move_velocity(-86); 
rb.move_velocity(83); 
delay(16); 
lf.move_velocity(-78); 
rb.move_velocity(81); 
delay(18); 
lf.move_velocity(-83); 
delay(16); 
lf.move_velocity(-84); 
lb.move_velocity(-84); 
rb.move_velocity(84); 
delay(18); 
lf.move_velocity(-82); 
lb.move_velocity(-86); 
rb.move_velocity(83); 
delay(16); 
lf.move_velocity(-84); 
delay(18); 
lf.move_velocity(-85); 
rf.move_velocity(4); 
rb.move_velocity(82); 
delay(18); 
lf.move_velocity(-84); 
lb.move_velocity(-83); 
rb.move_velocity(81); 
delay(16); 
lf.move_velocity(-82); 
lb.move_velocity(-82); 
delay(18); 
lb.move_velocity(-84); 
rb.move_velocity(80); 
delay(17); 
lf.move_velocity(-83); 
delay(17); 
lf.move_velocity(-77); 
lb.move_velocity(-83); 
rb.move_velocity(79); 
delay(17); 
lf.move_velocity(-78); 
lb.move_velocity(-82); 
rb.move_velocity(77); 
delay(18); 
lf.move_velocity(-79); 
lb.move_velocity(-83); 
rb.move_velocity(79); 
delay(17); 
lf.move_velocity(-78); 
lb.move_velocity(-80); 
rf.move_velocity(0); 
rb.move_velocity(78); 
delay(18); 
lf.move_velocity(-80); 
lb.move_velocity(-81); 
rb.move_velocity(77); 
delay(16); 
lf.move_velocity(-72); 
lb.move_velocity(-80); 
rb.move_velocity(79); 
delay(18); 
lf.move_velocity(-77); 
lb.move_velocity(-77); 
rb.move_velocity(80); 
delay(16); 
lb.move_velocity(-79); 
rb.move_velocity(78); 
delay(18); 
lf.move_velocity(-76); 
lb.move_velocity(-78); 
delay(16); 
lb.move_velocity(-77); 
rb.move_velocity(82); 
delay(19); 
lf.move_velocity(-75); 
lb.move_velocity(-73); 
rb.move_velocity(78); 
delay(17); 
lf.move_velocity(-77); 
rb.move_velocity(77); 
delay(16); 
lb.move_velocity(-74); 
delay(18); 
lf.move_velocity(-75); 
lb.move_velocity(-75); 
rb.move_velocity(75); 
delay(16); 
lf.move_velocity(-73); 
rb.move_velocity(74); 
delay(18); 
lf.move_velocity(-70); 
lb.move_velocity(-76); 
rb.move_velocity(75); 
delay(16); 
lb.move_velocity(-70); 
rb.move_velocity(73); 
delay(18); 
lf.move_velocity(-67); 
rf.move_velocity(21); 
rb.move_velocity(71); 
delay(18); 
lf.move_velocity(-65); 
lb.move_velocity(-71); 
rf.move_velocity(6); 
rb.move_velocity(67); 
delay(17); 
lf.move_velocity(-68); 
rb.move_velocity(69); 
delay(17); 
lf.move_velocity(-67); 
lb.move_velocity(-69); 
rf.move_velocity(7); 
rb.move_velocity(68); 
delay(17); 
lf.move_velocity(-63); 
lb.move_velocity(-63); 
rf.move_velocity(5); 
rb.move_velocity(65); 
delay(17); 
lf.move_velocity(-64); 
lb.move_velocity(-62); 
rb.move_velocity(62); 
delay(17); 
lf.move_velocity(-63); 
lb.move_velocity(-60); 
delay(18); 
lf.move_velocity(-60); 
lb.move_velocity(-57); 
rf.move_velocity(6); 
rb.move_velocity(60); 
delay(17); 
lf.move_velocity(-57); 
lb.move_velocity(-55); 
rb.move_velocity(55); 
delay(17); 
lf.move_velocity(-56); 
lb.move_velocity(-54); 
rf.move_velocity(7); 
rb.move_velocity(53); 
delay(17); 
lf.move_velocity(-52); 
lb.move_velocity(-52); 
rf.move_velocity(10); 
rb.move_velocity(50); 
delay(17); 
lf.move_velocity(-50); 
lb.move_velocity(-49); 
rf.move_velocity(14); 
rb.move_velocity(46); 
delay(18); 
lf.move_velocity(-43); 
lb.move_velocity(-44); 
rf.move_velocity(16); 
rb.move_velocity(42); 
delay(18); 
lf.move_velocity(-40); 
lb.move_velocity(-43); 
rf.move_velocity(19); 
rb.move_velocity(40); 
delay(17); 
lf.move_velocity(-38); 
lb.move_velocity(-39); 
rf.move_velocity(20); 
rb.move_velocity(36); 
delay(17); 
lf.move_velocity(-34); 
lb.move_velocity(-36); 
rf.move_velocity(22); 
rb.move_velocity(32); 
delay(17); 
lf.move_velocity(-32); 
lb.move_velocity(-33); 
rf.move_velocity(21); 
rb.move_velocity(31); 
delay(18); 
lb.move_velocity(-31); 
rf.move_velocity(22); 
rb.move_velocity(29); 
delay(17); 
lf.move_velocity(-30); 
lb.move_velocity(-29); 
rb.move_velocity(27); 
delay(17); 
lf.move_velocity(-27); 
lb.move_velocity(-25); 
rf.move_velocity(23); 
rb.move_velocity(23); 
delay(17); 
lf.move_velocity(-25); 
lb.move_velocity(-23); 
rb.move_velocity(22); 
delay(17); 
lf.move_velocity(-22); 
lb.move_velocity(-20); 
rf.move_velocity(22); 
rb.move_velocity(19); 
delay(17); 
lf.move_velocity(-19); 
lb.move_velocity(-17); 
rf.move_velocity(19); 
rb.move_velocity(16); 
delay(18); 
lf.move_velocity(-15); 
lb.move_velocity(-15); 
rf.move_velocity(16); 
rb.move_velocity(15); 
delay(17); 
lf.move_velocity(-14); 
lb.move_velocity(-14); 
rf.move_velocity(14); 
delay(16); 
lf.move_velocity(-11); 
lb.move_velocity(-11); 
rf.move_velocity(11); 
rb.move_velocity(13); 
delay(18); 
lf.move_velocity(-7); 
lb.move_velocity(-9); 
rf.move_velocity(8); 
rb.move_velocity(11); 
delay(17); 
lf.move_velocity(-6); 
lb.move_velocity(-7); 
rf.move_velocity(7); 
rb.move_velocity(9); 
delay(17); 
lb.move_velocity(-6); 
rf.move_velocity(5); 
rb.move_velocity(7); 
delay(18); 
lf.move_velocity(-7); 
rf.move_velocity(4); 
delay(16); 
lb.move_velocity(-7); 
delay(18); 
lf.move_velocity(-5); 
delay(16); 
lb.move_velocity(-5); 
rb.move_velocity(8); 
delay(18); 
lf.move_velocity(-8); 
rf.move_velocity(3); 
delay(16); 
lb.move_velocity(-8); 
rb.move_velocity(7); 
delay(18); 
lf.move_velocity(0); 
delay(18); 
lb.move_velocity(0); 
rf.move_velocity(0); 
rb.move_velocity(78); 
delay(16); 
rb.move_velocity(0); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(17); 
delay(16); 
delay(17); 
delay(17); 
delay(17); 
lf.move_velocity(25); 
lb.move_velocity(4); 
rf.move_velocity(-5); 
rb.move_velocity(-13); 
delay(17); 
lf.move_velocity(46); 
lb.move_velocity(19); 
rf.move_velocity(-51); 
rb.move_velocity(-54); 
delay(17); 
lf.move_velocity(65); 
lb.move_velocity(73); 
rf.move_velocity(-67); 
rb.move_velocity(-55); 
delay(18); 
lf.move_velocity(122); 
lb.move_velocity(62); 
rf.move_velocity(-142); 
rb.move_velocity(-47); 
delay(17); 
lf.move_velocity(176); 
lb.move_velocity(48); 
rf.move_velocity(-183); 
rb.move_velocity(-54); 
delay(17); 
lf.move_velocity(188); 
lb.move_velocity(26); 
rf.move_velocity(-195); 
rb.move_velocity(-77); 
delay(17); 
lf.move_velocity(191); 
lb.move_velocity(69); 
rf.move_velocity(-210); 
rb.move_velocity(-84); 
delay(17); 
lf.move_velocity(183); 
lb.move_velocity(104); 
rf.move_velocity(-195); 
rb.move_velocity(-91); 
delay(18); 
lf.move_velocity(177); 
lb.move_velocity(111); 
rf.move_velocity(-200); 
rb.move_velocity(-122); 
delay(18); 
lf.move_velocity(185); 
lb.move_velocity(117); 
rf.move_velocity(-206); 
rb.move_velocity(-126); 
delay(17); 
lf.move_velocity(189); 
lb.move_velocity(131); 
rf.move_velocity(-211); 
rb.move_velocity(-135); 
delay(17); 
lf.move_velocity(190); 
lb.move_velocity(147); 
rf.move_velocity(-216); 
rb.move_velocity(-131); 
delay(18); 
lf.move_velocity(171); 
lb.move_velocity(118); 
rf.move_velocity(-197); 
rb.move_velocity(-105); 
delay(17); 
lf.move_velocity(130); 
lb.move_velocity(92); 
rf.move_velocity(-177); 
rb.move_velocity(-93); 
delay(17); 
lf.move_velocity(105); 
lb.move_velocity(87); 
rf.move_velocity(-150); 
delay(17); 
lf.move_velocity(92); 
lb.move_velocity(85); 
rf.move_velocity(-130); 
rb.move_velocity(-104); 
delay(17); 
lf.move_velocity(89); 
lb.move_velocity(102); 
rf.move_velocity(-120); 
rb.move_velocity(-126); 
delay(18); 
lf.move_velocity(81); 
lb.move_velocity(112); 
rf.move_velocity(-108); 
rb.move_velocity(-137); 
delay(17); 
lf.move_velocity(78); 
lb.move_velocity(129); 
rf.move_velocity(-96); 
rb.move_velocity(-138); 
delay(17); 
lf.move_velocity(75); 
lb.move_velocity(131); 
rf.move_velocity(-93); 
rb.move_velocity(-131); 
delay(17); 
lf.move_velocity(86); 
lb.move_velocity(127); 
rf.move_velocity(-86); 
rb.move_velocity(-132); 
delay(17); 
lf.move_velocity(110); 
lb.move_velocity(118); 
rf.move_velocity(-81); 
rb.move_velocity(-127); 
delay(23); 
lf.move_velocity(114); 
lb.move_velocity(109); 
rf.move_velocity(-76); 
rb.move_velocity(-120); 
delay(18); 
lb.move_velocity(104); 
rb.move_velocity(-112); 
delay(17); 
lf.move_velocity(112); 
lb.move_velocity(97); 
rf.move_velocity(-78); 
rb.move_velocity(-107); 
delay(17); 
lf.move_velocity(106); 
lb.move_velocity(92); 
rf.move_velocity(-82); 
rb.move_velocity(-103); 
delay(17); 
lf.move_velocity(100); 
lb.move_velocity(85); 
rf.move_velocity(-80); 
rb.move_velocity(-100); 
delay(18); 
lf.move_velocity(96); 
lb.move_velocity(79); 
rb.move_velocity(-94); 
delay(17); 
lf.move_velocity(90); 
lb.move_velocity(76); 
rf.move_velocity(-79); 
rb.move_velocity(-87); 
delay(17); 
lf.move_velocity(84); 
lb.move_velocity(77); 
rf.move_velocity(-78); 
delay(16); 
lf.move_velocity(81); 
lb.move_velocity(80); 
rf.move_velocity(-76); 
rb.move_velocity(-81); 
delay(18); 
lf.move_velocity(71); 
lb.move_velocity(87); 
rf.move_velocity(-78); 
rb.move_velocity(-76); 
delay(18); 
lf.move_velocity(77); 
lb.move_velocity(89); 
rf.move_velocity(-77); 
rb.move_velocity(-78); 
delay(16); 
lf.move_velocity(72); 
lb.move_velocity(77); 
rf.move_velocity(-74); 
rb.move_velocity(-72); 
delay(18); 
lf.move_velocity(64); 
lb.move_velocity(78); 
rf.move_velocity(-71); 
rb.move_velocity(-71); 
delay(17); 
lf.move_velocity(61); 
lb.move_velocity(72); 
rb.move_velocity(-73); 
delay(17); 
lb.move_velocity(67); 
rf.move_velocity(-69); 
rb.move_velocity(-74); 
delay(16); 
lb.move_velocity(62); 
rf.move_velocity(-65); 
rb.move_velocity(-70); 
delay(18); 
lf.move_velocity(64); 
lb.move_velocity(58); 
rf.move_velocity(-62); 
rb.move_velocity(-64); 
delay(18); 
lf.move_velocity(62); 
lb.move_velocity(55); 
rf.move_velocity(-63); 
rb.move_velocity(-62); 
delay(16); 
lf.move_velocity(63); 
rf.move_velocity(-59); 
rb.move_velocity(-60); 
delay(18); 
lf.move_velocity(60); 
lb.move_velocity(53); 
rf.move_velocity(-56); 
rb.move_velocity(-56); 
delay(17); 
lf.move_velocity(56); 
lb.move_velocity(50); 
rf.move_velocity(-53); 
rb.move_velocity(-51); 
delay(18); 
lf.move_velocity(53); 
rf.move_velocity(-51); 
rb.move_velocity(-50); 
delay(17); 
lf.move_velocity(50); 
lb.move_velocity(49); 
rf.move_velocity(-50); 
rb.move_velocity(-51); 
delay(17); 
lf.move_velocity(46); 
lb.move_velocity(47); 
rf.move_velocity(-46); 
rb.move_velocity(-49); 
delay(17); 
lf.move_velocity(44); 
lb.move_velocity(46); 
rf.move_velocity(-44); 
rb.move_velocity(-47); 
delay(17); 
lf.move_velocity(40); 
lb.move_velocity(44); 
rf.move_velocity(-39); 
rb.move_velocity(-43); 
delay(18); 
lf.move_velocity(37); 
lb.move_velocity(40); 
rf.move_velocity(-37); 
rb.move_velocity(-39); 
delay(17); 
lf.move_velocity(34); 
lb.move_velocity(38); 
rf.move_velocity(-34); 
rb.move_velocity(-36); 
delay(17); 
lf.move_velocity(33); 
rf.move_velocity(-33); 
rb.move_velocity(-34); 
delay(18); 
lb.move_velocity(36); 
rb.move_velocity(-32); 
delay(17); 
lf.move_velocity(30); 
lb.move_velocity(32); 
rf.move_velocity(-30); 
rb.move_velocity(-30); 
delay(17); 
lf.move_velocity(29); 
lb.move_velocity(29); 
rf.move_velocity(-27); 
rb.move_velocity(-27); 
delay(18); 
lf.move_velocity(28); 
lb.move_velocity(27); 
rf.move_velocity(-26); 
rb.move_velocity(-26); 
delay(17); 
lf.move_velocity(25); 
lb.move_velocity(23); 
rf.move_velocity(-23); 
rb.move_velocity(-24); 
delay(17); 
lf.move_velocity(21); 
lb.move_velocity(20); 
rf.move_velocity(-21); 
rb.move_velocity(-21); 
delay(17); 
lf.move_velocity(19); 
lb.move_velocity(18); 
rf.move_velocity(-20); 
rb.move_velocity(-19); 
delay(18); 
lf.move_velocity(17); 
lb.move_velocity(17); 
rf.move_velocity(-18); 
rb.move_velocity(-18); 
delay(17); 
lf.move_velocity(16); 
lb.move_velocity(16); 
rf.move_velocity(-16); 
rb.move_velocity(-15); 
delay(17); 
lf.move_velocity(14); 
lb.move_velocity(15); 
rf.move_velocity(-13); 
rb.move_velocity(-12); 
delay(17); 
lf.move_velocity(13); 
rf.move_velocity(-12); 
delay(17); 
lf.move_velocity(11); 
lb.move_velocity(13); 
rf.move_velocity(-10); 
rb.move_velocity(-10); 
delay(17); 
lf.move_velocity(9); 
lb.move_velocity(11); 
rf.move_velocity(-8); 
rb.move_velocity(-8); 
delay(17); 
lf.move_velocity(6); 
lb.move_velocity(8); 
rf.move_velocity(-6); 
rb.move_velocity(-6); 
delay(18); 
rb.move_velocity(-5); 
delay(16); 
rf.move_velocity(-7); 
delay(18); 
lf.move_velocity(5); 
delay(16); 
lb.move_velocity(6); 
delay(18); 
lf.move_velocity(4); 
rf.move_velocity(-6); 
delay(16); 
lb.move_velocity(10); 
rb.move_velocity(-4); 
delay(18); 
lf.move_velocity(3); 
lb.move_velocity(0); 
rf.move_velocity(-10); 
delay(18); 
rb.move_velocity(-5); 
delay(16); 
lf.move_velocity(0); 
rf.move_velocity(-14); 
delay(18); 
rf.move_velocity(0); 
rb.move_velocity(0); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(17); 
delay(17); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 
delay(18); 
delay(16); 

This is 10 seconds of movement.

1000 < 10000

I’m currently trying to combine the delay()'s when I can, to further reduce the file size. If anyone has any ideas for that please reply to this with said ideas. I have thought, but it seems to be a little finicky.

2 Likes

You could just only save the velocityUnits in the text file and run a loop that loads all of the data from the file on the sdcard, at least that’s what we did so we don’t need to bring out the dongle, load the sdcard, and fire up VEXcode after every recording session.

7 Likes

Heh, it’s been a while since I’ve been tagged on this forum. This was one of my more fun pieces of programming I did during my vex ‘career’. I also think we may have been the only team to use rerun at the world champs so far (although, I have been out of the loop for a couple of years now). Off memory we seeded first with it and won pretty much all of the auton bonuses - until we changed the drive motors for eliminations and everything fell apart!

Rerun has always tickled me a little bit so I love seeing people give it another go.

Some tips we found:

  • Some sort of control loop is a must
  • We tried a positional PID loop to start with (at x time, we should be at x encoder position), but found that error just built up on itself and got exponentially worse
  • The best solution we found was a velocity PID loop, where at a given point of time we knew the velocity the wheels should be at - you can then determine the motor power given a baseline of the controller value, and a PID loop
  • Because you have one big continuous control loop essentially, you can tune your constants as the autonomous runs based on the error from the last iteration - we found that the longer the auton ran for, the more accurate it go becuase of this (ie, the last 55s of a 1min auton skills was more repeatable than the first 5s).
  • The point above can help you quickly tune your loop before a match if you are allowed 5 seconds or so to run a forward/back/turn program and autotune to the current field/robot condition/battery levels

Also, this was all before V5 - I have only used V5 a little bit in the beta program so there may be fun features you can use now!

Jack

10 Likes

Thank you Jack. I am currently recording the velocities of the motors, in terms of what they’re actually doing, not what they want to be doing. I believe that this is similar to what you did. Is.it not?

		flSpeed = lf.get_actual_velocity();
		blSpeed = lb.get_actual_velocity();
		frSpeed = rf.get_actual_velocity();
		brSpeed = rb.get_actual_velocity();
		armSpeed = arm.get_actual_velocity();
		clawSpeed = claw.get_target_velocity();

		flenc = lf.get_position();
		blenc = lb.get_position();
		frenc = rf.get_position();
		brenc = rb.get_position();
		armenc = arm.get_position();
		clawenc = claw.get_position();



		if (flSpeedold != flSpeed) {

			flenco = flenc;
			mfl = true;
		}
		else {
			mfl = false;
		}
		if (blSpeedold != blSpeed) {

			blenco = blenc;
			mbl = true;
		}
		else {
			mbl = false;
		}
		if (frSpeedold != frSpeed) {

			frenco = frenc;
			mfr = true;
		}
		else {
			mfr = false;
		}
		if (brSpeedold != brSpeed) {

			brenco = brenc;
			mbr = true;
		}
		else {
			mbr = false;
		}
		if (armSpeedold != armSpeed) {

			armenco = armenc;
			marm = true;
		}
		else {
			marm = false;
		}
		if (clawSpeedold != clawSpeed) {

			mclaw = true;
		}
		else {
			mclaw = false;
		}

		if (mfl || mbl || mfr || mbr || mclaw || marm) {

			FILE* usd_file_write = fopen("/usd/rerun.txt", "a");

			fprintf(usd_file_write, "claw.move_velocity(%i); \n", clawSpeed);
			clawSpeedold = clawSpeed;

			fprintf(usd_file_write, "arm.move_velocity(%i); \n", armSpeed);
			armSpeedold = armSpeed;

			fprintf(usd_file_write, "rb.move_velocity(%i); \n", brSpeed);
			brSpeedold = brSpeed;

			fprintf(usd_file_write, "rf.move_velocity(%i); \n", frSpeed);
			frSpeedold = frSpeed;

			fprintf(usd_file_write, "lb.move_velocity(%i); \n", blSpeed);
			blSpeedold = blSpeed;

			fprintf(usd_file_write, "lf.move_velocity(%i); \n", flSpeed);
			flSpeedold = flSpeed;

			timeNew = pros::millis();
			deltaTime = timeNew - timeOld;
			timeOld = pros::millis();

			fprintf(usd_file_write, "delay(%d); \n", deltaTime);
		
			fclose(usd_file_write);
		}

This is much more complicated
But the output is much shorter.

4 Likes