Hi Everyone,
The program I am talking about in this thread is during Driver Control.
My team is programming in RobotC, and I was wondering if it is possible to program a button on the joystick to be pressed and an autonomous program to be run. Then while that is running, say lifting the arm up and down for 10 sec., still be able to control the drive base of the robot and drive it around as the autonomous program is running.
Thanks for any help.
Just put the action in one task and the drive code in another task, then start them both when driver control runs. For example:
task driveControl{
while (true){
motor[left]= vexRT[channel]
motor[right]=vexRT[channel]
}
}
task liftControl{
while (true){
if (vexRT[button1]){
//lift up
}
else if (vexRT[button2]){
//lift down
}
else if (vexRT[button3]){
//Auto lifting to wherever you need it to be
}
else{
//hold lift
}
}
}
task usercontrol{
startTask(driveControl);
startTask(liftControl);
}
This way, you run 2 threads at once, one which is the drive, one which is the lift. It’s a good idea to separate all mechanisms you’re controlling (the mobile goal lift, the drive, the arm, etc.) into different tasks in the case that you’re attempting to run something autonomously
Thanks for the help!
This is definitely possible, we’re planning on using separate tasks for our autostack and normal driver stack that are programmed so that our driver can kill the autostack and start driving at any time with just the press of a button.