View unanswered posts | View active topics It is currently Mon Jun 25, 2018 4:07 am






Reply to topic  [ 3 posts ] 
Dual FTC Controller Coding 
Author Message
Rookie

Joined: Wed Jan 07, 2015 5:08 pm
Posts: 5
Post Dual FTC Controller Coding
Please explain how to write RobotC code to use 2 controllers during competition.

We want to have both controllers to be clones.

We have a functional teleop program but we can only use one controller.

Please help a very rookie team.

Thanks
TLN


Sat Feb 07, 2015 12:08 am
Profile
Rookie

Joined: Wed Jan 07, 2015 5:08 pm
Posts: 5
Post Re: Dual FTC Controller Coding
Here is the basic code i've been working with:
I also attached the actual file



#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//


#include "JoystickDriver.c"

task main()
{
int threshold = 7; /* Int 'threshold' will allow us to ignore low */
/* readings that keep our robot in perpetual motion. */

while(true) // Infinite loop:
{
getJoystickSettings(joystick);

if(joystick.joy1_y1 < 7 && joystick.joy1_y1 > -7 && joystick.joy1_y2 < 7 && joystick.joy1_y2 > -7) //DEAD ZONE
{
motor[motorD] = 0; // ALL STOP
motor[motorE] = 0; // ALL STOP
}

if(abs(joystick.joy1_y2) > threshold) // If the right analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorD] = joystick.joy1_y2; // Motor D is assigned a power level equal to the right analog stick's Y-axis reading.
}
if(abs(joystick.joy1_y1) > threshold) // If the left analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorE] = joystick.joy1_y1; // Motor E is assigned a power level equal to the left analog stick's Y-axis reading.
}
}


//CONTROLLER #2

while(1==1) // Infinite loop:
{
getJoystickSettings(joystick);

if(joystick.joy2_y2 < 7 && joystick.joy2_y2 > -7 && joystick.joy2_y1 < 7 && joystick.joy2_y1 > -7)
{
motor[motorD] = 0; // ALL STOP
motor[motorE] = 0; // ALL STOP
}

if(abs(joystick.joy2_y2) > threshold) // If the right analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorD] = joystick.joy2_y2; // Motor D is assigned a power level equal to the right analog stick's Y-axis reading.
}

if(abs(joystick.joy2_y1) > threshold) // If the left analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorE] = joystick.joy2_y1; // Motor E is assigned a power level equal to the left analog stick's Y-axis reading.
}


}

}


Attachments:
NEED HELP.c [2.34 KiB]
Downloaded 350 times
Sat Feb 07, 2015 4:18 pm
Profile
Rookie

Joined: Mon Dec 15, 2014 9:48 pm
Posts: 16
Post Re: Dual FTC Controller Coding
From what I see if I am understanding this right, you guys have two infinite loops: while (true), and while (1==1) after the first one.

When you run this program the program "flow" will get stuck in this first one (while (true)) and it wont ever get to the second loop. So you wanna put both controls into the same loop. :)


Sat Feb 07, 2015 11:07 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.