- 6
- At the moment where it keeps cutting off, I just put down a riser and backing out, but that’s all. I can’t think how that would push the motors to the limit. Only 3 motors are moving, maybe sometimes 4 because of the H-Drive.
- I am doing 1-minute rounds, and then resetting the robot and field and going again. Every time, I restart the program at the setup for every round.
- Here is my code:
#pragma config(Motor, motor1, arm, tmotorVexIQ, PIDControl, encoder)
#pragma config(Motor, motor3, claw, tmotorVexIQ, PIDControl, encoder)
#pragma config(Motor, motor4, lowerClaw, tmotorVexIQ, PIDControl, encoder)
#pragma config(Motor, motor10, rDrive, tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor, motor11, lDrive, tmotorVexIQ, PIDControl, encoder)
#pragma config(Motor, motor12, hDrive, tmotorVexIQ, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
int armmove = 0;
int clearedLClawPos = 200;
bool lowclawpos = false;
bool clawpos = false;
bool armstarting = false;
bool prevlowclaw = false;
task claws()
{
while(true)
{
if(getMotorEncoder(arm)>=clearedLClawPos)
{
if(prevlowclaw==true)
{
setMotorTarget(lowerClaw,-190,127);
}
if(prevlowclaw==false)
{
setMotorTarget(lowerClaw,-340,127);
}
}
if(getMotorEncoder(lowerClaw)<=-340)
{
lowclawpos = false;
}
if(getMotorEncoder(lowerClaw)>=-190)
{
lowclawpos = true;
}
if(getMotorEncoder(claw)<=38)
{
clawpos = false;
}
if(getMotorEncoder(claw)>=290)
{
clawpos = true;
}
if(armstarting==true)
{
if(getMotorEncoder(arm)<=clearedLClawPos)
{
setMotorTarget(lowerClaw,-190,100);
}
}
if(getMotorEncoder(arm)>clearedLClawPos)
{
if(vexRT(BtnEDown)==1)
{
if(lowclawpos==false)
{
prevlowclaw = true;
setMotorTarget(lowerClaw,-190,127);
}
if(lowclawpos==true)
{
prevlowclaw = false;
setMotorTarget(lowerClaw,-340,127);
}
sleep(250);
}
}
if(vexRT(BtnEUp)==1)
{
if(clawpos==false)
{
setMotorTarget(claw,290,100);
}
if(clawpos==true)
{
setMotorTarget(claw,38,100);
}
sleep(250);
}
}
}
task arms()
{
while(true)
{
while(armmove==1)
{
if(getMotorEncoder(arm)<142)
{
setMotor(arm,100);
}
else
{
if(getMotorEncoder(arm)>148)
{
setMotor(arm,-50);
}
else
{
armmove = 0;
}
}
}
while(armmove==2)
{
if(getMotorEncoder(arm)<376)
{
setMotor(arm,100);
}
else
{
if(getMotorEncoder(arm)>382)
{
setMotor(arm,-100);
}
else
{
armmove = 0;
}
}
}
while(armmove==3)
{
if(getMotorEncoder(arm)<-5)
{
setMotor(arm,100);
}
else
{
if(getMotorEncoder(arm)>5)
{
setMotor(arm,-50);
}
else
{
armmove = 0;
}
}
}
while(armmove==4)
{
if(getMotorEncoder(arm)<475)
{
setMotor(arm,100);
}
else
{
if(getMotorEncoder(arm)>485)
{
setMotor(arm,-100);
}
else
{
armmove = 0;
}
}
}
}
}
task main()
{
startTask(claws);
startTask(arms);
while(true)
{
setMotor(lDrive,(vexRT(ChA) + vexRT(ChC))*1.27);
setMotor(rDrive,(vexRT(ChA) - vexRT(ChC))*1.27);
setMotor(hDrive,vexRT(ChB) * 1.27);
if(getMotorEncoder(arm)>200)
{
armstarting = true;
}
if(vexRT(BtnFUp)==1)
{
armmove = 2;
}
if(vexRT(BtnFDown)==1)
{
armmove = 1;
}
if(vexRT(BtnRUp)==1)
{
if(getMotorEncoder(arm)<500)
{
setMotor(arm,127);
}
}
else
{
if(vexRT(BtnRDown)==1)
{
if(getMotorEncoder(arm)>0)
{
setMotor(arm,-127);
}
}
else
{
if(armmove == 0)
{
setMotor(arm,0);
}
}
}
}
}```