text
stringlengths 0
715
|
---|
task myTask2 = task(opticalModeLoop);
|
}
|
void pre_auton(void) {
|
init();
|
Inertial1.calibrate();
|
Inertial2.calibrate();
|
}
|
void usercontrol(void) {
|
auton = false;
|
flywheelTargetRPM = 1800;
|
gain = defaultGain;
|
tripleShooting = false;
|
while (1) {
|
driveCode();
|
//testing with encoders
|
/*
|
Controller1.Screen.clearScreen();
|
Controller1.Screen.setCursor(1, 1);
|
Controller1.Screen.print(RightEncoder.position(degrees));
|
Controller1.Screen.newLine();
|
Controller1.Screen.print(LeftEncoder.position(degrees));
|
Controller1.Screen.newLine();
|
Controller1.Screen.print(BackEncoder.position(degrees));
|
*/
|
//copied from jpearman
|
// Draw an area representing the vision sensor field of view
|
if (drawMode == 2) {
|
Brain.Screen.clearScreen( vex::color::black );
|
Brain.Screen.setPenColor( vex::color::green );
|
Brain.Screen.drawRectangle( screen_origin_x-1, screen_origin_y-1, screen_width+2, screen_height+2 );
|
// request any objects with signature 1
|
int numberObjects = VisionSensor.takeSnapshot(VisionSensor__RED_GOAL);
|
Brain.Screen.setPenColor( vex::color::white );
|
Brain.Screen.setFont( mono20 );
|
Brain.Screen.setCursor( 2, 2 );
|
Brain.Screen.print( "Sig 1 %2d", (int)numberObjects );
|
// draw any objects found
|
drawObjects( VisionSensor, vex::color::red, true );
|
numberObjects = VisionSensor.takeSnapshot(VisionSensor__BLUE_GOAL);
|
// draw any objects found
|
drawObjects( VisionSensor, vex::color::blue, false );
|
wait(180, msec);
|
}
|
wait(20, msec);
|
}
|
}
|
int main() {
|
// Initializing Robot Configuration. DO NOT REMOVE!
|
vexcodeInit();
|
// Set up callbacks for autonomous and driver control periods.
|
Competition.autonomous(autonomousProgram);
|
Competition.drivercontrol(usercontrol);
|
// Run the pre-autonomous function, basically initialize
|
pre_auton();
|
// Prevent main from exiting with an infinite loop.
|
while (true) {
|
checkOverheating();
|
//printController(Optical.hue());
|
wait(20, msec);
|
}
|
}
|
Full Over Under Code
|
//necessary stuff
|
#include "vex.h"
|
#include <iostream>
|
#include <cmath>
|
#include <vector>
|
#include <cstdlib>
|
using namespace vex;
|
competition Competition;
|
//global variables
|
bool auton = false; //whether or not the robot is being controlled autonomously
|
float driveSpeed = 1.0f; //driving (forward and backward) speed of the robot
|
float turnSpeed = .6f; //turning speed of the robot
|
int drawMode = 3; //what to draw on the brain screen? 0: flywheel 1: PID 2: vision sensor 3: status update 4: odom
|
int tempDrawMode = 0; //store the previous draw mode temporarily
|
int overHeatingTimer = 0; //keeps track of how often to display an overheating warning
|
int autonType = 2; //the type of autonomous to use
|
float driveDistance = 0; //drive distance for drive PID
|
float speedPID = 1; // the speed to run the motors at in PID loops, range is 0-1
|
bool kickerOn = false; //true or false, whether or not the kicker is on right now
|
bool intakeOn = false; //true or false, whether or not the kicker is on right now
|
bool wingsActive = false; //true or false, whether or not the wings are active
|
bool elevationActive = false; //true or false, whether or not the elevation mechanism is active
|
bool scraperActive = false; //true or false, whether or not the scraper is active
|
bool exitPID = false; //true or false, whether or not to exit a PID loop
|
bool curveDrive = true; //true or false, whether or not the curve drive is active
|
task autonTask; //stores the autonomous task
|
//helper functions
|
void printController(float i) {
|
//prints a number to the controller console (very handy for debugging)
|
Controller1.Screen.clearLine(3);
|
Controller1.Screen.setCursor(3, 1);
|
Controller1.Screen.print(i);
|
}
|
void printControllerSetup() {
|
//sets up the controller to be printed on
|
Controller1.Screen.clearLine(3);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.