vcs autonomous selector

i have been trying to get an autonomous selector working but have been unsuccessful. Would anyone be willing to share the part of a program that selects the autonomous in Robot C++?

You asked me by DM about an hour ago, this what I linked.
https://vexforum.com/t/walshbots-autonomous-feature-selector/51534/1

Did that not work ?

sorry i was unable to find that conversation , thank you

Is there a way so that when you select one of the buttons it runs a certain autonomous? and how would you change it to that?

The structure of the program is made such that you have one program and you can configure the features you want to enable, for example “Park” or “shoot preload”. As you autonomous goes down line by line, you can check to see if the variable is set, so for example if you selected Blue Alliance, you can decide to turn to the right instead of the left if you were on Red Alliance. The reason the program is set up this way is that the field is symmetric (apart from the Blue parking platform which is nearer to the Alliance Station than the Red)… There is just the starting tile parameter - are you on the tile nearer to the flags or the far starting tile?

Now if all you are doing is driving forward around two tiles and back one, you would be able to score the low flag near tile or push the cap near the far tile no matter the starting tile. Otherwise you will need to account for the difference in distance or direction depending on the alliance you are on.

If you are looking to put different programs on your brain, you can do that from VCS and have 8 different programs loaded. That might get unwieldy as your autonomous routines are more complex.

@lacsap Thank you i think i figured it out.

let us know how to improve the example.

@lascap I am trying to download my program but errors keep popping up how would I fix these? there are 2 attached I am trying to get “1” to work but it won’t.
Complex auton selector.vex (40.5 KB)
1.vex (59.5 KB)

the compilation error occurs because you removed all the multi motor drive functions from the code. For example,
driveTurnRightDegrees( 30 );
needs a corresponding function for it to work.

The code you need is in the other program you attached:


void driveTurnFor(float count)
{
    Leftfront.rotateFor(-1.0*count, rotationUnits::rev,false);
    Leftback.rotateFor(-1.0*count, rotationUnits::rev,false);
    Rightback.rotateFor(count, rotationUnits::rev,false);
    Rightfront.rotateFor(count, rotationUnits::rev);  // block until complete
    task::sleep(50);   
}

void driveTurnDegrees(float degrees)
{
    float rotdegree = 0.82/90;

    driveSetVelocity(40.0);    // turn more slowly to avoid overshoot

    driveTurnFor( degrees * rotdegree );
 
}

void driveTurnLeftDegrees(float degrees)    // counter clockwise - so negative degrees
{
    driveTurnDegrees( 1.0 * degrees);       
}

void driveTurnRightDegrees(float degrees)   // clockwise
{
    driveTurnDegrees(-1.0 * degrees);
}

@lacsap I did this and it still shows errors
2.vex (60.5 KB)

If you go to the line that raised the compile error, you will see that it is another function from our example that you removed when porting to your system:

    driveSetVelocity(40.0);    // turn more slowly to avoid overshoot

at line 167.

@lacsapI fixed this but there is still errors.
3.vex (61.5 KB)

You have unmatched {} in your code.

You will need to fix these for the code to compile… You have extra } { in the program at a couple of locations. I will not have time to code correct this today as I am setting up for an event tomorrow.

1 Like

@lacsap if I wait a couple of days could you correct this?

@lacsap I think i got it working, here it is.
Working Phoenix Auto Selector.vex (53 KB)

I can look again in a couple of days - snow storm will keep me at home.

There is a way of stream lining your code, so it has really only two major routines - near the flags and far from flags. Being on blue or red alliance impacts direction of turns and distance considerations when parking.

I am glad you have code that compiles.