How to code autonomous for high stakes?

I have no clue how to program an auton, and my other teammates either are busy or don’t know how to code in c++ at all. I seriously need help to be able to actually complete.

Use Vexcode V5 or Vexcode IQ, or the VSCode Extension for coding.
If you want block coding, you have to use vexcode.

They both have their advantages and disadvantages.

I know how to do basic code, but I was never taught how to make the robot do autonomous tasks. I can do basic code, but my teammates are mostly building the robot, and the one person on my team who does know how to code, he’s the manager, and he has to help build anyways. There are other people in my school who can do it, but again, they’re busy too. I also don’t really have the patience to watch a long YouTube video on it. Thanks for the suggestions though! :grin:

You can do autonomous using these:

For VexCode Blocks:
image

Python:
image

C++:

competition Competition;
void Autonomous(){
  // Autonomous Code
}
int main(){
  Competition.autonomous(Autonomous)
}
1 Like

I know how to set it up, I just don’t know what to put inside the loop. Do you just put the same things you would outside the loop?

You do code that is specifically for Autonomous. For example, you could put something like a bang-bang algorithm for beginners:

Or, if you are more advanced, an Odometry and PID.
So basically, you try to score as much points as possible in advance through Autonomous movements like the image above.

For this competition, I’m using the vexcode app with c language, but I have no idea how to code those things in that language.

I haven’t ever tried C with VEX (RobotC is no longer supported, and I don’t have any v1 IQ Brains to test), although I’ve heard about it several times.

If you are talking about C++ with vexcode, which you mentioned in your first post and the previous one, you can use the functions on the left side of the screen.
All functions you’ll ever need are there or in Vex API.

If you aren’t familiar with C++ either, VEX Blocks is still an option with most of the functionality you need.

I’m doing the V5 competition with the C++ language, although I have been told by my robotics teacher that it was in C. Maybe he didn’t know that it was C++? Id don’t really know that much. But how do you get to the Vex API? I really don’t have experience in robotics :sweat_smile: Thanks a ton for helping me BTW! :grin:

Hah, no worries :grinning:. C++ is a descendent of the C language, so I understand, but you might want to tell him that Vexcode uses C++ though.

The VEX API was meant to be a link, if you didn’t get it, it’s this: https://api.vex.com/
You could also search on Google for VEX API, it’s hopefully the first hit/result.

Thanks for all the help you’ve given me, I really appreciate it! Also I will tell him that it is in C++. Also, whenever I ask him for any help, he tells me, “I’m not allowed to help you or anyone else, so my excuse is not knowing how to do it.” It makes me laugh. Again, thank you for helping me out so much! :grin:

Has your original question been answered? I code C++, and I would like to think that I had a good auton the previous years. If you want, I can provide more guidance, or my code from the previous years to show you an example.

Sure, that would help a lot! The vex API page didn’t show anything about autonomous. :sweat: So this would be very helpful!

I haven’t seen your code, but I’ll guess you know how to initialize motors and sensors. Motors come with an API that you can use to make them move, or access variables. I’m also guessing you use V5 PRO, not PROS. For example, here’s a function you might have in your code:

void forward(float distance)
{
    FrontLeftMotor.move(forward, distance);
    FrontRightMotor.move(forward, distance);
    BackLeftMotor.move(forward, distance);
    BackRightMotor.move(forward, distance);
}

Or

void turnRight(float degrees)
{
    float distance = // Math to convert degrees to distance
                     // using gear ratios, cartridge types, etc.
    FrontLeftMotor.spinFor(forward, distance);
    FrontRightMotor.spinFor(reverse, distance);
    BackLeftMotor.spinFor(forward, distance);
    BackRightMotor.spinFor(reverse, distance);
}

You could use these functions in your auton like this

void autonomous()
{
    forward(12); // In inches for this example
    turnRight(90); // Degrees
    forward(24);
    intake.spin(127);
}

My code from last year used a PID inside of an Okapi wrapper, so posting it here might not help. If you want it though, I would be happy to provide it.

1 Like

It actually does. You need to look hard enough for it. :sweat_smile:

Go to V5, C++, then Competition through the navbar and sidebar.
Autonomous is located there.

Motor, Drivetrain, Pneumatic, Vision Sensors, Timers, Sensors, LEDs, and more have functions that are all listed in there. (There are much more, I’m too lazy to list them)

Great, but a SmartDrive Class will make things a bit more simple for beginners.
After initialization, you can just directly run

Smartdrive.drive(forward, 100, rpm)

Yes, that function is part of Vex API (this link directly links to it).


All VEX functions intended for student use are listed in the API.
Remember, there aren’t specific things like motor functions for Autonomous, they are directly called like Joeger_Bahar showed you.

2 Likes

Thanks, I had no clue how to get there :sweat_smile:

Thanks for that too! Also my code app says its in “V5 pro,” if that helps with helping me lol.

Another thing: I have an idea for what to do, I want to go forward a certain distance. How would I do that in auton mode? the website doesn’t really say anything about that… :sweat:

Think… What causes the robot to move forward? A Drivetrain (called SmartDrive in VEX), of course!

On the sidebar, “drivetrain” will show you the functions after you initialize it. All functions are under the “Class Methods” header.

After scrolling down a bit, I see this:

That means we can do this:

Drivetrain.driveFor(10, inches);

to move the drivetrain 10 inches forward.
(yes, you do need to run with Drivetrain, not Smartdrive)

1 Like