VEX V5 PROS Basic Tank Drive Program

Hi everyone,

I recently got PROS and I’m trying to make a simple tank drive program in C++. This should be the easiest thing ever, but for some reason, my code does absolutely nothing. I’m trying to avoid using Okapilib right now and want to do it using basic functions. This is what I have so far:


void opcontrol() {
	pros::Controller master (pros::E_CONTROLLER_MASTER);
	pros::Motor frontLeft (2);
	pros::Motor backLeft (1);
	pros::Motor frontRight (20);
	pros::Motor backRight (19);
	while (true) {
	     frontLeft.move(master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y) );
	     backLeft.move(master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y) );
	     frontRight.move(master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y) );
	     backRight.move(master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y) );
             pros::delay(20);
	}
}

This code just does absolutely nothing. I’d appreciate some assistance.

Did you do PROS Build Project before uploading?

Also save before you build. The quick action (lightning bolt symbol) will both build and upload. If that doesn’t work instead of


pros::E_CONTROLLER_ANALOG_LEFT_Y

try just


ANALOG_LEFT_Y

. For some reason I remember that working for me.

Thank you both. It turns out that I wasn’t building before downloading. I had assumed that it would automatically build before uploading but I guess not.
It still doesn’t work correctly whatsoever, bu at least it does something.

@The Electrobotz Because there is no manual way to reverse the v5 motors you need to do it in the program either by adding a “true” to the end of the motor declaration, or by adding/removing negative signs

This example creates a motor object that controls port 2 of the brain and it is reversed


pros::Motor front_Left(2, true);

How were you uploading? Was it with Prosv5 upload? If it was I suggest Prosv5 mut instead.

I’ve been uploading using the buttons at the top of Atom.

I’ve been struggling with this all day, and it still won’t even drive. I’ve tried using the lightning bolt to download, which didn’t work. I then tried to first Build Project and then upload, but that also didn’t work. It seems that whatever was originally downloaded is what gets stuck on the Brain. I made a new project and this was the code that came with the project:


void opcontrol() {
	pros::Controller master(pros::E_CONTROLLER_MASTER);
	pros::Motor left_mtr(1);
	pros::Motor right_mtr(2);
	while (true) {
		pros::lcd::print(0, "%d %d %d", (pros::lcd::read_buttons() & LCD_BTN_LEFT) >> 2,
		                 (pros::lcd::read_buttons() & LCD_BTN_CENTER) >> 1,
		                 (pros::lcd::read_buttons() & LCD_BTN_RIGHT) >> 0);
		int left = master.get_analog(ANALOG_LEFT_Y);
		int right = master.get_analog(ANALOG_RIGHT_Y);

		left_mtr = left;
		right_mtr = right;
		pros::delay(20);
	}

I downloaded this code just to try and debug, and it worked. The motors in ports 1 and 2 worked. I then modified it slightly by just taking out the


left_mtr = left;

line expecting the motor in port1 to stop spinning. It continued to work, however. Does anyone have any advice?

Personally, I never liked Atom, let alone the PROS integration for Atom. There are far better options, including Visual Studio, Visual Studio Code, CLion, and even arguably Notepad++.

All of my listed editors readily support external build systems and shell commands. As a result, all of them can invoke PROS CLI commands just as well as Atom can, if not better.

As a result of setting up the editor yourself in this manner, you can be certain about what action you invoke, rather than guessing as in the PROS Editor.

Try running


prosv5 make clean

followed by the usual


prosv5 mu

.

Ok so I’m now using VS Code (I like this editor much better than Atom as well). I ran those, but again, nothing changed. The terminal did say everything was successful, however.

Run


prosv5 v5 rm-all

to remove all user programs from the V5 and then re-upload your program. I can’t imagine what state your V5 is in that this would solve any issues, but this will remove all V5 user programs and so when you upload next, you will definitely have the latest build of your project.

Also, are you saving your files?

I was actually able to get it working a few hours ago. My friend downloaded PROS and made a project with code that was almost identical to what we tried. This worked, so my guess is that there was some error with my installation of PROS. I will try to examine further and post if I figure out why mine wasn’t working for anyone in the future.