Autonomous Help

I’m a bit new to coding so I’m shooting my shot on this forum for some help. I’m working on autonomous programming, and I was hoping someone can help me come up with a program. This is what I want to do; our robot has two claws that intake cubes and I wanna come up with a program that’ll run those claws for certain amount of time.

I have something a bit like this:
void Intake(){
LeftClaw.spin(directionType::rev,80,percentUnits::pct);
RightClaw.spin(directionType::rev,80,percentUnits::pct);
LeftClaw.setTimeout(int32_t(750), timeUnits::msec);
RightClaw.setTimeout(int32_t(750), timeUnits::msec);
task::sleep(uint32_t(500));
}

But my problem is that “intake” is stuck on one specific time, while what I want is to be able to change how long I want to run it to where I can say “Intake(50)”, 50 being 50 seconds

Thank you for taking the time read all this, it was kinda long, but I hope someone can help me out :slight_smile:

When you declare intake make it

void intake(int setTime){

And then in your wait statement call that variable

thread::sleep(setTime);

Also sleep is in miliseconds so if you want you can make a new variable that equals setTime times 1000

5 Likes

you’re the best <3333333333

3 Likes