Right now The code makes our robot spin in a circle.
//Functions here//
void Turnright() {
left.spin(forward);
rightgroup.stop();
}
Void MOVEFORWARD() {
leftgroup.spin(forward);
rightgroup.spin(forward);
wait(1,sec);
Turnright();
}
Void autonomous(void) {
MOVEFORWARD();
wait(1,sec)
}
The robot is using tank drive
The motor config is
leftgroup (motor group)
rightgroup (motor group)
BIGARMgroup (Motor group)
Clawmotor (motor)
To start, in the turn function you only say left.spin. I’m not sure if that’s intentional but based on you motor groups I would change it to leftgroup.spin.
Second, there is nothing that tells you robot to stop spinning in the turn function. As of now, what it should do is drive forward for 1 second then spin right forever. You need to say after some condition, stop turning
Just getting a better idea of the problem here, is it going straight for 1 second then spinning, like its told to, or is it immediately spinning in circles?
1 Like
As you have written it, it should drive forward 1 second then turn right until autonomous ends.
Tip, if you put three ` before and after code, it makes it code format
and easier to read.
Welcome to the forum.
1 Like
From what it seems, you have no stopping for your left side motors in this function:
void Turnright()
You would want to add this:
left.spinFor(direction,amount,unit);
Your code should look something like this:
//Functions here//
void Turnright() {
rightgroup.stop();
//note that you should also move right group above left. At least,
//that's my theory, I don't mess with this too much.
left.spinFor(forward,20,inches);
}
Alternatively, you can do this: Add this to the code that follows the use of the function, if you want it to run for a specific amount of time:
wait(time,unit);
left.stop();
Your code should look something like this:
Void MOVEFORWARD() {
leftgroup.spin(forward);
rightgroup.spin(forward);
wait(1,sec);
Turnright();
wait(1,sec);
left.stop();
}
Hope this helps!
-your local protogen (FreakingFurry) :3
p.s. - if I missed anything, or it doesn’t work, please let me know! I’m down to helping out.
1 Like
goes forward and then spinning
Then I believe your issue is that you are not telling the robot to stop turning, making it spin infinitely.
2 Likes