Last active
December 18, 2015 10:09
-
-
Save mattneary/5766051 to your computer and use it in GitHub Desktop.
Robotics Institute Team Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S1, touchSensor, sensorTouch) // | |
// | |
#include "./Headers/JoystickDriver.c" // | |
// Do Not Add Or | |
float speed = 1.0; // Modify Code Above | |
#include "./Headers/Control Header.c" // | |
// | |
#define THRESHOLD 0 // | |
//////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name: | |
* The Red Eagles | |
* Student Names: | |
* Patrick Sellers (P-rock) | |
* Seth Sacket | |
* James Packard | |
*/ | |
/* Add code to the return statements below to create a user control */ | |
int leftMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY + (leftJoyX); | |
} | |
int rightMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY - (leftJoyX); | |
} | |
///////////////////////////////////////////////////////////////////////////////// | |
task main(){ // | |
// | |
while(true) { // | |
getJoystickSettings(joystick); // | |
// | |
int leftX = joystick.joy1_x1*100/127, leftY = joystick.joy1_y1*100/127; // | |
int rightX = joystick.joy1_x2*100/127, rightY = joystick.joy1_y2*100/127; // Do Not Add or | |
// Modify Code Below | |
motor[leftMotor] = leftMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
motor[rightMotor] = rightMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
// | |
int touch = SensorValue[touchSensor]; // | |
speed = penalizedSpeed(touch == 1); // | |
} // | |
} // | |
/////////////////////////////////////////////////////////////////////////// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S4, colorSensor, sensorCOLORFULL) // Do Not Add or | |
// Modify Code Above | |
#include "./Headers/Autonomous Header.c" // | |
///////////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name: | |
* Medusa | |
* Student Names: | |
*Ethan Foltz | |
*Will Erkman | |
*Ben Wilson | |
*/ | |
/* Code your functions here */ | |
task main(){ | |
int turnTime = 350; | |
int color = ROBOgetColor(); | |
ROBOforward(50); | |
while((color != REDCOLOR) && (color != GREENCOLOR) && (color != BLUECOLOR)){ | |
color = ROBOgetColor(); | |
nxtDisplayCenteredTextLine(3,"color: %d",color); | |
} | |
//ROBOleft(50); | |
if(color == REDCOLOR){ | |
ROBOleft(50); | |
wait1Msec(turnTime); | |
} | |
if(color == GREENCOLOR){ | |
//forward | |
} | |
if(color == BLUECOLOR){ | |
ROBOright(50); | |
wait1Msec(turnTime); | |
} | |
ROBOforward(50); | |
wait1Msec(1000); | |
color = 1; | |
wait1Msec(turnTime); | |
while(color != REDCOLOR && color != GREENCOLOR && color != BLUECOLOR){ | |
ROBOforward(50); | |
wait1Msec(100); | |
//ROBOstop(); | |
color = ROBOgetColor(); | |
} | |
ROBOstop(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S1, touchSensor, sensorTouch) // | |
// | |
#include "./Headers/JoystickDriver.c" // | |
// Do Not Add Or | |
float speed = 1.0; // Modify Code Above | |
#include "./Headers/Control Header.c" // | |
// | |
#define THRESHOLD 0 // | |
//////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name: | |
*Medusa | |
* Student Names: | |
*Ethan Foltz | |
*Will Erkman | |
*Ben Wilson | |
*/ | |
/* Add code to the return statements below to create a user control */ | |
int leftMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY+rightJoyX; | |
} | |
int rightMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY-rightJoyX; | |
} | |
///////////////////////////////////////////////////////////////////////////////// | |
task main(){ // | |
// | |
while(true) { // | |
getJoystickSettings(joystick); // | |
// | |
int leftX = joystick.joy1_x1*100/127, leftY = joystick.joy1_y1*100/127; // | |
int rightX = joystick.joy1_x2*100/127, rightY = joystick.joy1_y2*100/127; // Do Not Add or | |
// Modify Code Below | |
motor[leftMotor] = leftMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
motor[rightMotor] = rightMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
// | |
int touch = SensorValue[touchSensor]; // | |
speed = penalizedSpeed(touch == 1); // | |
} // | |
} // | |
/////////////////////////////////////////////////////////////////////////// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S4, colorSensor, sensorCOLORFULL) // Do Not Add or | |
// Modify Code Above | |
#include "./Headers/Autonomous Header.c" // | |
///////////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Team 5 The Mercyless Eggrolls | |
* | |
* Ian | |
* Nick | |
* Henry | |
* | |
* Drew | |
*/ | |
task main(){ | |
int turnLength = 1025; | |
int color = ROBOgetColor(); | |
while (color != REDCOLOR && color!=BLUECOLOR && color !=GREENCOLOR){ | |
ROBOforward(50); | |
color = ROBOgetColor(); | |
nxtDisplayCenteredTextLine(3,"color:%d",color); | |
} | |
nxtDisplayCenteredTextLine(3,"color:%d",color); | |
if (color==REDCOLOR){ //red | |
ROBOleft(100); | |
wait1Msec(turnLength); | |
ROBOforward(100); | |
wait1Msec(3400); | |
ROBOstop(); | |
} | |
if(color==GREENCOLOR){ // green | |
ROBOforward(100); | |
wait1Msec(3400); | |
ROBOstop(); | |
} | |
if(color==BLUECOLOR){ //blue | |
ROBOright(50); | |
wait1Msec(turnLength); | |
ROBOforward(100); | |
wait1Msec(3400); | |
ROBOstop(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S1, touchSensor, sensorTouch) // | |
// | |
#include "./Headers/JoystickDriver.c" // | |
// Do Not Add Or | |
float speed = 1.0; // Modify Code Above | |
#include "./Headers/Control Header.c" // | |
// | |
#define THRESHOLD 0 // | |
//////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Team 5 MeRcYlESS EgG rOlLs | |
*Nick | |
*Ian | |
*Henry | |
* | |
*Drew | |
*/ | |
/* Add code to the return statements below to create a user control */ | |
//Dual Separated | |
int leftMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY + rightJoyX; | |
} | |
int rightMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY - rightJoyX; | |
} | |
///////////////////////////////////////////////////////////////////////////////// | |
task main(){ // | |
// | |
while(true) { // | |
getJoystickSettings(joystick); // | |
// | |
int leftX = joystick.joy1_x1*100/127, leftY = joystick.joy1_y1*100/127; // | |
int rightX = joystick.joy1_x2*100/127, rightY = joystick.joy1_y2*100/127; // Do Not Add or | |
// Modify Code Below | |
motor[leftMotor] = leftMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
motor[rightMotor] = rightMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
// | |
int touch = SensorValue[touchSensor]; // | |
speed = penalizedSpeed(touch == 1); // | |
} // | |
} // | |
/////////////////////////////////////////////////////////////////////////// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S4, colorSensor, sensorCOLORFULL) // Do Not Add or | |
// Modify Code Above | |
#include "./Headers/Autonomous Header.c" // | |
///////////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name:the pink B.K unicorns | |
* | |
* Student Names:jacob sydney JOHN | |
* | |
* | |
*/ | |
/* Code your functions here */ | |
task main(){ | |
/* Call your functions here */ | |
//Getting to Color! | |
int pink_BK_unicorns; | |
ROBOforward(80); | |
wait10Msec(450); | |
ROBOstop(); | |
//Determining Color! | |
do{ | |
pink_BK_unicorns = ROBOgetColor(); | |
nxtDisplayCenteredTextLine(3,"%d", pink_BK_unicorns);//"pink burger king unicorns rock!)"; | |
wait10Msec(250); | |
}while(pink_BK_unicorns==0); | |
wait1Msec(1003); | |
ROBObackward(10); | |
wait10Msec(100); | |
//Turning because of the Color! | |
if(pink_BK_unicorns==REDCOLOR){// "red")){ | |
ROBOleft(100); | |
wait10Msec(200); | |
ROBOforward(45); | |
} | |
else if(pink_BK_unicorns==BLUECOLOR){// "blue")){ | |
ROBOright(100); | |
wait10Msec(200); | |
ROBOforward(45); | |
} | |
else{ //(pink_BK_unicorns== GREENCOLOR "green")) | |
ROBOforward(45); | |
} | |
nxtDisplayCenteredTextLine(3,"pink burger king unicorns rock!)"; | |
wait10Msec(650); | |
ROBOstop(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S1, touchSensor, sensorTouch) // | |
// | |
#include "./Headers/JoystickDriver.c" // | |
// Do Not Add Or | |
float speed = 1.0; // Modify Code Above | |
#include "./Headers/Control Header.c" // | |
// | |
#define THRESHOLD 0 // | |
//////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name: | |
pink B.K unicorns | |
* | |
* Student Names: jacob sydney John | |
* | |
* | |
*/ | |
/* Add code to the return statements below to create a user control */ | |
int leftMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY + rightJoyX; | |
} | |
int rightMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY - rightJoyX; | |
} | |
///////////////////////////////////////////////////////////////////////////////// | |
task main(){ // | |
// | |
while(true) { // | |
getJoystickSettings(joystick); // | |
// | |
int leftX = joystick.joy1_x1*100/127, leftY = joystick.joy1_y1*100/127; // | |
int rightX = joystick.joy1_x2*100/127, rightY = joystick.joy1_y2*100/127; // Do Not Add or | |
// Modify Code Below | |
motor[leftMotor] = leftMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
motor[rightMotor] = rightMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
// | |
int touch = SensorValue[touchSensor]; // | |
speed = penalizedSpeed(touch == 1); // | |
} // | |
} // | |
/////////////////////////////////////////////////////////////////////////// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S4, colorSensor, sensorCOLORFULL) // Do Not Add or | |
// Modify Code Above | |
#include "./Headers/Autonomous Header.c" // | |
///////////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name: RoboSwag | |
* | |
* Student Names: John Kulha, Luke Hinsman, Hayden Covert | |
* | |
* | |
*/ | |
void moveTowardPad() { | |
TColors read = ROBOgetColor(); | |
while( read != REDCOLOR && read != GREENCOLOR && read != BLUECOLOR ) { | |
motor[leftMotor] = 50; | |
motor[rightMotor] = 50; | |
read = (TColors)ROBOgetColor(); | |
} | |
} | |
void stop() { | |
motor[leftMotor] = 0; | |
motor[rightMotor] = 0; | |
} | |
void turnLeft() { | |
motor[leftMotor] = 100; | |
motor[rightMotor] = -100; | |
wait1Msec(200); | |
} | |
void turnRight() { | |
motor[leftMotor] = -100; | |
motor[rightMotor] = 100; | |
wait1Msec(200); | |
} | |
void delegate(int step) { | |
nxtDisplayCenteredTextLine(3, step==1?"step 1":(step==2?"step 2":"step 3")); | |
if( step == 1 ) { | |
moveTowardPad(); | |
stop(); | |
delegate(2); | |
} else if( step == 2 ) { | |
stop(); | |
TColors read = ROBOgetColor(); | |
if( read == REDCOLOR ) { | |
turnLeft(); | |
} else if( read == BLUECOLOR ) { | |
turnRight(); | |
} | |
delegate(3); | |
} else { | |
motor[leftMotor] = 100; | |
motor[rightMotor] = 100; | |
wait1Msec(1500); | |
moveTowardPad(); | |
stop(); | |
} | |
} | |
task main(){ | |
delegate(1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S1, touchSensor, sensorTouch) // | |
// | |
#include "./Headers/JoystickDriver.c" // | |
// Do Not Add Or | |
float speed = 1.0; // Modify Code Above | |
#include "./Headers/Control Header.c" // | |
// | |
#define THRESHOLD 0 // | |
//////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name: RoboSwag | |
* | |
* Student Names: John Kulha, Luke Hinsman, Hayden Covert | |
* | |
* | |
*/ | |
/* Add code to the return statements below to create a user control */ | |
int leftMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY + rightJoyX; | |
} | |
int rightMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY - rightJoyX; | |
} | |
///////////////////////////////////////////////////////////////////////////////// | |
task main(){ // | |
// | |
while(true) { // | |
getJoystickSettings(joystick); // | |
// | |
int leftX = joystick.joy1_x1*100/127, leftY = joystick.joy1_y1*100/127; // | |
int rightX = joystick.joy1_x2*100/127, rightY = joystick.joy1_y2*100/127; // Do Not Add or | |
// Modify Code Below | |
motor[leftMotor] = leftMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
motor[rightMotor] = rightMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
// | |
int touch = SensorValue[touchSensor]; // | |
speed = penalizedSpeed(touch == 1); // | |
} // | |
} // | |
/////////////////////////////////////////////////////////////////////////// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S4, colorSensor, sensorCOLORFULL) // Do Not Add or | |
// Modify Code Above | |
#include "./Headers/Autonomous Header.c" // | |
///////////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name:Shuffle Bots | |
* Student Names: | |
* Ian | |
* Josh | |
* Shreya | |
*/ | |
int scanningForColors(){ | |
ROBOforward(50); | |
wait1Msec(1500); | |
while(ROBOgetColor() != REDCOLOR && ROBOgetColor() != GREENCOLOR && ROBOgetColor() != BLUECOLOR){ | |
ROBOforward(50); | |
wait1Msec(100); | |
} | |
wait1Msec(800); | |
ROBOstop(); | |
return ROBOgetColor(); | |
} | |
void turn(int color){ | |
if(color == REDCOLOR){ | |
ROBOright(50); | |
wait1Msec(350); | |
} else if(color == BLUECOLOR){ | |
ROBOleft(50); | |
wait1Msec(350); | |
} | |
ROBOstop(); | |
} | |
task main(){ | |
turn(scanningForColors()); | |
scanningForColors(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder) // | |
#pragma config(Sensor, S1, touchSensor, sensorTouch) // | |
// | |
#include "./Headers/JoystickDriver.c" // | |
// Do Not Add Or | |
float speed = 1.0; // Modify Code Above | |
#include "./Headers/Control Header.c" // | |
// | |
#define THRESHOLD 0 // | |
//////////////////////////////////////////////////////////////////////////////// | |
/* | |
* Group Name Shuffle Bots | |
* | |
* Student Names: | |
* JOSH | |
* Shreya | |
* IAN | |
*/ | |
/* Add code to the return statements below to create a user control */ | |
//Dual Separated | |
int leftMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY + rightJoyX; | |
} | |
int rightMotorPower(float leftJoyY, float rightJoyY, float leftJoyX, float rightJoyX) { | |
return leftJoyY - rightJoyX; | |
} | |
///////////////////////////////////////////////////////////////////////////////// | |
task main(){ // | |
// | |
while(true) { // | |
getJoystickSettings(joystick); // | |
// | |
int leftX = joystick.joy1_x1*100/127, leftY = joystick.joy1_y1*100/127; // | |
int rightX = joystick.joy1_x2*100/127, rightY = joystick.joy1_y2*100/127; // Do Not Add or | |
// Modify Code Below | |
motor[leftMotor] = leftMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
motor[rightMotor] = rightMotorPower(leftY, rightY, leftX, rightX) * speed; // | |
// | |
int touch = SensorValue[touchSensor]; // | |
speed = penalizedSpeed(touch == 1); // | |
} // | |
} // | |
/////////////////////////////////////////////////////////////////////////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment