So I’m having an issue with my lift cutting off all the functions I know there is a don’t wait function in blocks so if anyone can help me since vex text has been a major learning curve for me
That depends how you are spinning the motors. Most of the time (rotateTo,rotateFor,spinTo,spinFor) you can add ‘false’ as an additional last parameter which tells the program to not pause the execution of the rest of your code.
im using rotate-to but it doesn’t quit unless it reaches the destination and while its doing it you cant drive or do anything else
so then try adding ‘false’ as the last parameter.
I have already tried using the false statement but it just doesn’t run it at all
heres some of the code
if(Controller.ButtonR1.pressing()){
Lift.setVelocity(60, vex::velocityUnits::pct);
Lift.rotateTo(250,vex::rotationUnits::deg);
task::sleep(10);
Lift.setVelocity(50, vex::velocityUnits::pct);
Lift.rotateTo(300,vex::rotationUnits::deg);
task::sleep(10);
Lift.setVelocity(40, vex::velocityUnits::pct);
Lift.rotateTo(350,vex::rotationUnits::deg);
Lift.setVelocity(30, vex::velocityUnits::pct);
Lift.rotateTo(450,vex::rotationUnits::deg);
task::sleep(10);
Lift.setVelocity(20, vex::velocityUnits::pct);
Lift.rotateTo(500,vex::rotationUnits::deg);
Lift.setVelocity(10, vex::velocityUnits::pct);
Lift.rotateTo(550,vex::rotationUnits::deg);
Lift.stop(brake);
so in this code its trying to do different stages of motor power to slow the lift to stack the cubes
So when you try to replace Lift.rotateTo(300,vex::rotationUnits::deg);
with Lift.rotateTo(300,vex::rotationUnits::deg,false);
it doesn’t run at all? Keep in mind that by continuing to run your code the next rotateTo statement runs before the first is finished and overrides the original.
If you want to just push the button and it to rotate to each position after it is reached on top of driving you’ll have to use multitasking or multithreading.
yes it doesn’t run at all when were in driver control
I have been trying many other options in the meantime to see if we can make it to where our driver can make an accurate stack without manually doing it because it takes him at least 10 secounds
so as I mentioned it just seems to not run because the entire code segment is executed super fast and the motor’s last instruction is to brake. You’ll need to utilize multitasking/threading if you want to use your code as is and still drive. copy the code in your if statement and put it into a function. then, in your if statement call the function like this: thread(functionName).detach();
.
This tells the brain to continue executing the main function while simultaneously running the other.
This might help: One Thing Runs But Everything Else Stops
EDIT: note that using this method you do not need the ‘false’ param as if it is there the same issue occurs and the brain runs through your function at lightspeed and brakes almost immediately