I feel dumb asking this question, however, I am new to coding and my autonomous is not working. I have a competition coming up very soon and not much time to test so this is urgent. The problem with my autonomous is that the program reads it line by line which instead of having multiple actions done simultaneously, it instead does each command individually. So, for instance, to move the actual robot, the front right motor spins to the degrees I have it set at, then the back right motor, then the left front motor and so on and so forth. How do I get the autonomous to run multiple commands simultaneously? (I want to be able to spin my intake and collect a ball while the robot is moving, then turn and shoot the ball, etc.)
This is an example of my code:
void autonomous (void){
Intake.rotateFor(3,timeUnits::sec,100,velocityUnits::pct);
LeftDriveFront.rotateFor(1000,rotationUnits::deg,50,velocityUnits::pct);
LeftDriveBack.rotateFor(1000,rotationUnits::deg,50,velocityUnits::pct);
RightDriveFront.rotateFor(1000,rotationUnits::deg,50,velocityUnits::pct);
RightDriveBack.rotateFor(1000,rotationUnits::deg,50,velocityUnits::pct);
task::sleep(1000);
}
I actually wished that VCS would not have so many functions in their API but instead on work on simple things - like say CTRL-S to save your project… Not asking for versioning, but simple common sense implementation of develop GUI.
Honestly, I feel you. IDK if anyone else encounters this issue either but when you use THEIR competition template, it doesn’t even compile the code. Like it’s very iffy, one minute it compiles, the next minute even after I didn’t touch the code, it doesn’t compile and it gives an error on their line of text then I save and restart the application and it works perfectly…
I was going to do this but haven’t gotten around to testing it on the field. One more question, lets say I wanted to condense the code and make each movement a procedure. (when I call the procedure it runs the set of commands). So, lets say I get the exact degrees needed for my robot to get from one tile to the next and instead of rewriting it over and over again, I simply call the procedure instead. How would I set it up? In robotC it would be something like:
Except of course the motors didn’t have built in encoders. But instead of having to call each motor, I would simply call Drivetrain(127) and it would move the entire robot forward. How would I do something similar to that but with exact measurements?
Our teams do something like:
driveRotateFor( double count) {
LeftDriveFront.rotateFor(count,rotationUnits::deg,50,velocityUnits::pct, false);
LeftDriveBack.rotateFor(count,rotationUnits::deg,50,velocityUnits::pct, false);
RightDriveFront.rotateFor(count,rotationUnits::deg,50,velocityUnits::pct, false);
RightDriveBack.rotateFor(count,rotationUnits::deg,50,velocityUnits::pct);
// put delay here to let robot settle
}
then they have another abstraction for converting distances to rotations, ditto for turns degrees to rotation.
Makes it easier for teams to write a plan then implement It, test it on field - measure offsets.
You can instantiate the intake the same way you do for any motor and you can create a helper function to simplify your code. What coding platform are you using?
(Also, this thread is so old. I’ve come such a long way in just 9 short months, wow.)