Motor Recording and Playback Program for V5 in Robot Mesh Studio

Hello everyone! I wrote this little program a while ago and shared it with some folks on Discord. Here it is for everyone on the VEX forum to see, too.

The code in question

What is it?

This program can record what motors are told to do, play back those recordings, and save/load them to/from an SD card.

Can I copy this?

Not for use in VRC (or VIQC), no. Using code written by an adult such as this is not within the intent of rule G2 in VRC/VIQC. As it was written by an adult, this code is not legal for VRC/VIQC competition use. It is only provided as a learning tool to show how the SD card could be used. If you do still want to write something like this to use in competition, don’t use my version, as it’s not only against the rules but also not very useful: you can’t hand-edit a recording to do minor tweaks, it has some catastrophic interactions with competition template control, and it makes no allowances for running different autonomous routines.

How is it used?

Each motor that we’re interested in recording gets set up as a special velocityRecordedMotor, which extends vex::motor. From there, you can just use the spin method on the new velocityRecordedMotor object like you would on a vex::motor. When you set up a velocityRecordedMotor, you also specify a filename for that particular motor to use as its logfile on the SD card.

How does it work?

The magic happens in how vex::motor::spin has been overridden, and the additional things that have been added as part of velocityRecordedMotor. The additional elements affect how the new spin method works. If playback is turned on, calling spin will ignore any arguments and instead send the appropriate saved command to the motor. If instead recording is turned on, calling spin will save the command and move the motor. (If neither playback nor recording is active, it will behave like a regular driver control program.)


Pure utter briliance.


This is fantastic! Maybe not super effective in competition, but an awesome leap in V5 programming. :smiley:

1 Like

This is so insanely smart, especially towards folks learning how to program a V5 Brain.


Wowza I will definitely be looking at this over the summer since I’ve been trying to do the same thing in pros.

You might have just gained an rms user


Did someone say skills auton?


This is, in fact, the reason I started on the project, yep. We’ve got an offering for super-beginners called Controller Express, which is just a way to map joysticks and buttons to some predefined actions for motors. I started work on this to look at the feasibility of adding recording functionality to our API, primarily to make Controller Express capable of doing something for autonomous. We don’t expect competition teams to have much use for it, but it would be useful for a class that was going through robot construction and wasn’t ready to dive all the way into programming yet.


I wish that RECF would ban this type of “coding”.

Could I ask why? It’s very hard to make this kind of thing really super-reliable for autonomous and there is a lot to be learned by working through it.

IMO, the goal is to learn/understand programming. Being given code with instructions how to use it to record movements, completely circumvents it.

Is it reliable? Maybe not for the top 10% of teams, but why not make even the beginner teams write code - no matter how simple?

And we’d rather see students attempting something with writing their own instructions for their robots, even if it isn’t terribly impressive. There are way too many students whose first thought upon hearing “programming a robot” is immediate dismissal of the notion that it’s something that they’re capable of, and we would like to reduce that number. Tools with substantial training wheels are the answer that we are throwing our lot in with.

I don’t know about you, but I still remember the drive it required to teach myself programming when I was first learning. If I’d come across C and Java first instead of QBASIC, I probably would not have persevered in teaching myself those more complicated languages. Similarly, the goal of this project (as well as Controller Express and Blockly in general) was to provide a shallow end to the autonomous coding “pool” for those that would otherwise be intimidated by jumping into the deep end of it.

And if you want to use this for controlling things other than just two drive motors operated by joysticks, it is going to require extensions, revision, or rewriting it with a different paradigm. For example, a simple two-button operated lifting arm wouldn’t work well with this, as the usual if...else if...else motor.stop(hold); doesn’t work. This doesn’t override or record the stop method. It would actually be possible to use this to stop and hold a motor, but it would require you to actually understand what’s going on and read some documentation on how vex::motor::spin works by default. In other words, this could have been much more fully featured than I made it.


Part of teaching people is showing them examples of how to do things. Past simple examples like tank drive students are left completely without resources. The difficulty of course is that the examples have to do something worth doing or no one will care. So the reasonable solution left to us, is come up with problems that are interesting to students and show how to solve them in the simplest case. That way if a student wants to use that solution, they have to rewrite it for their robot. In this case while the idea of recording motion is an interest problem, there isn’t really a solution that lives up to the idea. This means in almost all cases it will used as an example of how to do complex programming and not step by step instructions for getting out of writing autonomous.

1 Like

John - I appreciate the thoughts, but just recording something driving isn’t something. It’s not programming. The intent is to learn programming.

Replay/Rewind has been around and I cringe when teams use it. For ITZ, there were teams that were in the elimination rounds that had recorded programs that went and got a cone, put it on a goal, and delivered it. Then they were paired with a team in the elimination rounds that wanted them to change it because the autons would collide. I was standing right there when they looked at their partner and told them that they can’t - they don’t know how - that they’d have to rerecord it.

ITZ was awful for beginning teams. There was no easy auton. However, last year (TP) and this year there are very easy auton points to get. You just need to move forward. Not much drive is needed for that - especially with sample programs galore. Programming is part of the challenge - to avoid that is a miss IMO.


No, the intent is to get kids interested in engineering and science, and to encourage them to consider further education and employment in STEM fields. “Learning to program” is one method to achieve the goal, but it is not the goal.

1 Like

Absolutley. However, I’d think the intent of the autonomous period and programming skills challenge is to … well … program. I could be wrong though.

It actually kind of is. “A computer program is a collection of instructions that performs a specific task when executed by a computer.” It’s programming through an atypical method, but it’s still encoding instructions for a robot.

Is it significantly lower barriers to entry than other methods of programming? Of course. That’s kind of the whole idea. Programming doesn’t have to be hard to be programming. Programming is coming up with an algorithm or instructions to solve a task. The form of those instructions is rather besides the point compared to the core skill competency.

As for your point about inflexibility of the recording program you saw in ITZ, that’s rather neatly sidestepped here by the ability to load information from an SD card on V5. That’s part of what I wanted to show off with this program, as previously on the Cortex you’d have to encode a recording directly into your program, which was a time-intensive process and didn’t allow much flexibility unless you wrote multiples into your program. Even without adding anything to the program, all this takes to run a different recording is swapping a micro SD card at the very minimum. Or just running another copy of the program downloaded to another slot that looks for a different set of recording files. And that kind of resource-file dependent programming is applicable beyond just a recording and playback program, too: reading instructions from a resource file and changing program behavior based on what’s discovered is a very, very common thing in the world of software.

1 Like

Weak. Again, I could be wrong, but I do not believe that is what is intended for something like the Programming Skills Challenge - having teams drive their robot, record how they drive it, and play it back.

1 Like

There is no inherent virtue in choosing to do your work on a lower level of abstraction. Writing binary is no more real programming than writing in assembly, C, C++, JavaScript, Blockly, etc. What adds sophistication to a program is not what it’s written in or how it’s written, but what it does. Most programs that you’ll see kids write do nothing more than execute a predetermined series of commands with no branching. That they recorded that predetermined series of commands by typing it instead of driving it adds no additional virtue to the process.

What separates complex programming from simple programming is mostly decision making. A program written with drag-and-drop Blockly that makes use of a vision sensor is a more sophisticated specimen of problem solving than one that blindly executes instructions written in C++.

So yes, teaching your robot a list of instructions by driving the list of instructions is an incredibly basic skill set. I’ve never said it isn’t. But it also isn’t any different than typing in the same set of commands by hand. It’s just easier. Programming doesn’t have to be hard to be programming.


Conversely, what would you think about a “Programming Skills Challenge” run being executed during the “Driver Skills Challenge”? Less drastically, at what point would “button macros” during Driver Skills transition it to “Programming Skills”?


Some teams already do this. In cases where programming skills is more consistent than a human driver while still scoring as quickly.