|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Digital Module 1 not found. Please Help?
My name is marco from team 564 Longwood, i recently tried to upload last years code and i have been having a problem where digital module 1 was not present and we checked the robot itself and nothing has changed since last years working code. Here's last years code, im wondering if you can take a look at the code, please and thank you
![]() /*----------------------------------------------------------------------------*/ /* Copyright (c) FIRST 2008. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj.templates; //import edu.wpi.first.wpilibj.camera.AxisCamera; import edu.wpi.first.wpilibj.*; /** * The VM is configured to automatically run this class, and to call the * functions corresponding to each mode, as described in the IterativeRobot * documentation. If you change the name of this class or the package after * creating this project, you must also update the manifest file in the resource * directory. */ public class RobotTemplate extends IterativeRobot { /** * This function is run when the robot is first started up and should be * used for any initialization code. */ RobotDrive drive1; // Drive object RobotDrive drive2; // Drive object Joystick rightStick; // joystick Joystick leftStick; // joystick Joystick other; // joystick Jaguar arm; // manipulator jaguar Jaguar jag1; //driving jaguars Jaguar jag2; Jaguar jag3; Jaguar jag4; Servo twist; // pans camera left-right Servo tilt; // pans camera up and down Servo pin1; // servo for minibot release Servo pin2; // Solenoid clawfire; // claw 2 //Solenoid clawrelease; // claw 1 // Solenoid slidefire; // minibot slide 3 //Solenoid sliderelease;// minibot slide 4 //Compressor comp; // compressor DigitalInput right; // lightsensor DigitalInput middle; // lightsensor DigitalInput left; // lightsensor AnalogChannel pot; // potentiometer //AxisCamera cam; // camera Gyro gyro; // gyro Relay relay; DigitalInput pressureSwitch; int autoPeriodicLoops; int disabledPeriodicLoops; int telePeriodicLoops; static final int UNINITIALIZED_DRIVE = 0; static final int ARCADE_DRIVE = 1; static final int TANK_DRIVE = 2; int driveMode; int dsPacketsReceivedInCurrentSecond; int count; int count2; boolean check; public RobotTemplate() { System.out.println("Constructor Started"); drive1 = new RobotDrive(1,2); //left drive2 = new RobotDrive(3,4); //right rightStick = new Joystick(1); leftStick = new Joystick(2); other = new Joystick(3); jag1 = new Jaguar(1, 1); //driving jaguars jag2 = new Jaguar(1, 2); jag3 = new Jaguar(1, 3); jag4 = new Jaguar(1, 4); arm = new Jaguar(1, 5); //to set up for new robot, 5 for winch twist = new Servo(6); //plugged into 6 tilt = new Servo(7); //plugged into 7 pin1 = new Servo(8); //plugged into 8 pin2 = new Servo(9); // clawfire = new Solenoid(1); //plugged into 1,2 //clawrelease = new Solenoid(2); //plugged into 1,2 //slidefire = new Solenoid(4); //plugged into 3,4 //sliderelease = new Solenoid(3); //plugged into 3,4 //comp = new Compressor(1,1); //plugged into 1,8 right = new DigitalInput(3); middle = new DigitalInput(2); left = new DigitalInput(9); pot = new AnalogChannel(3); //slot 1 channel 3 gyro = new Gyro(2); //plugged into 2 relay = new Relay(1, Relay.Direction.kForward); pressureSwitch = new DigitalInput(1); dsPacketsReceivedInCurrentSecond = 0; autoPeriodicLoops = 0; disabledPeriodicLoops = 0; telePeriodicLoops = 0; driveMode = UNINITIALIZED_DRIVE; count = 0; count2 = 0; check = true; System.out.println("Constructor completed."); } public void robotInit() { relay.set(Relay.Value.kOn); //comp.start(); //starts compressor //camera stuff //cam = AxisCamera.getInstance(); //cam.writeResolution(AxisCamera.ResolutionT.k160x12 0); //cam.writeColorLevel(1); //cam.writeBrightness(0); // drive.setInvertedMotor(RobotDrive.MotorType.kFront Left, false); // drive.setInvertedMotor(RobotDrive.MotorType.kRearL eft, true); System.out.println("robotInit() completed."); } public void disabledInit() { disabledPeriodicLoops = 0; // Reset the loop counter for disabled mode startSec = (int)(Timer.getUsClock() / 1000000.0); printSec = startSec + 1; System.out.println("Robot disabled."); } public void autonomousInit() { autoPeriodicLoops = 0; // Reset the loop counter for autonomous mode System.out.println("Autonomous method running."); } public void teleopInit() { telePeriodicLoops = 0; // Reset the loop counter for teleop mode dsPacketsReceivedInCurrentSecond = 0; // Reset the number of dsPackets in current second driveMode = UNINITIALIZED_DRIVE; // Set drive mode to uninitialized System.out.println("Teleoperated method running."); } static int printSec; static int startSec; public void disabledPeriodic() { // feed the user watchdog at every period when disabled Watchdog.getInstance().feed(); // increment the number of disabled periodic loops completed disabledPeriodicLoops++; // while disabled, printout the duration of current disabled mode in seconds if ((Timer.getUsClock() / 1000000.0) > printSec) { System.out.println("Disabled seconds: " + (printSec - startSec)); printSec++; } } /** * This function is called periodically during autonomous */ public void autonomousPeriodic() { // feed the user watchdog at every period when in autonomous //adressing autonomous - this is what we added autoPeriodicLoops++; if(pressureSwitch.get()){ relay.set(Relay.Value.kOff); } //printing things for testing // System.out.println("Gyro Angle" + gyro.getAngle()); System.out.println("left " + left.get() + " middle " + middle.get() + " right " + right.get()); //autonomous code for straight if(count <= 140) { drive1.tankDrive(-0.48, -0.5); drive2.tankDrive(-0.48, -0.5); count++; } else if(pot.getValue() > 260) // 1 seconds { arm.set(-0.65); // raise arm drive1.tankDrive(-0.48, -0.5); drive2.tankDrive(-0.48, -0.5); } else if(pot.getValue() <= 260 && check){ arm.set(0.0); check = false; } else if(count <= 270) { drive1.tankDrive(-0.48, -0.5); drive2.tankDrive(-0.48, -0.5); if(count == 270) { if(count2 <= 75) { drive1.tankDrive(0, 0); drive2.tankDrive(0, 0); if(pot.getValue() < 275) { arm.set(.1); } else { arm.set(0.0); } } else { // clawrelease.set(true); // open claw // clawfire.set(false); } } count++; count2++; } else { drive1.tankDrive(0.5, 0.5); drive2.tankDrive(0.5, 0.5); } //optical sensors are working correctly //should work for line following //! is added to compensate for testing, will be removed for competition /* if(!left.get() && middle.get()){ //if left is true and middle is not then turn left drive1.tankDrive(0.5, -0.5); drive2.tankDrive(0.5, -0.5); } else if(!middle.get() && (left.get() && right.get())){ //if middle is true and nothing else is true drive1.tankDrive(0.5, 0.5); drive2.tankDrive(0.5, 0.5); } else if(!right.get() && middle.get()){ //if right is true and the middle is not true turn right drive1.tankDrive(-0.5, 0.5); drive2.tankDrive(-0.5, 0.5); } else if(!right.get() && !left.get()){ //if right and left are true, you have reached the fork in the road //to turn left, uncomment this if(gyro.getAngle() > -30){//brendon guestimates the angle to be 30 drive1.tankDrive(-0.5, 0.5); drive2.tankDrive(-0.5, 0.5); } //to turn right, uncomment this if(gyro.getAngle() < 30){ drive1.tankDrive(0.5, -0.5); drive2.tankDrive(0.5, -0.5); } } else{ //stop drive1.tankDrive(0.0, 0.0); drive2.tankDrive(0.0, 0.0); //here will be something with the arm and claw under the assumtion that there is no line where the peg is, we will need to check this if(pot.getValue()< 515){//arbitrary number is being used here since we dont know the actual # arm.set(-0.45); } else{ arm.set(0.0); clawrelease.set(true);//opens claw clawfire.set(false); //starts the compressor after shooting off the piston relay.set(Relay.Value.kOn); } //claw.set(false);//not sure how to deal with this because ... i guess that the piston will start out already fired... }*/ //hypothetically we could use the gyro here, for the fork and turning and even for keeping straight,so heres the scoring written that way //this is only a test to see if it will go straight /* if(gyro.getAngle() <= 15 && gyro.getAngle() >= -15){ drive.tankDrive(0.5, 0.5); } else if(gyro.getAngle() >= 15){ drive.tankDrive(-0.5, 0.5); } else if(gyro.getAngle() <= 15){ drive.tankDrive(0.5, -0.5); } else{ drive.tankDrive(0.0, 0.0); } */ //end of added things Watchdog.getInstance().feed(); autoPeriodicLoops++; } /** * This function is called periodically during operator control */ public void teleopPeriodic() { // feed the user watchdog at every period when in autonomous Watchdog.getInstance().feed(); // increment the number of teleop periodic loops completed telePeriodicLoops++; /* * Code placed in here will be called only when a new packet of information * has been received by the Driver Station. Any code which needs new information * from the DS should go in here */ dsPacketsReceivedInCurrentSecond++; // increment DS packets received if(pressureSwitch.get()){ relay.set(Relay.Value.kOff); } else{ relay.set(Relay.Value.kOn); } System.out.println("potentiometer values " + pot.getValue()); //System.out.println("gyro values " + gyro.getAngle()); System.out.println("left " + left.get() + " middle " + middle.get() + " right " + right.get()); // determine if tank or arcade mode, based upon position of "Z" wheel on kit joystick if (other.getRawButton(2)) // Logitech Attack3 has z-polarity reversed; up is negative {//changed to use the same button as last year to activiate arcade drive,must be held to keep activiated // use arcade drive // drive with arcade style (use other stick) drive1.arcadeDrive(other.getY(), other.getX()); drive2.arcadeDrive(other.getY(), other.getX()); //should give us control over the camera servos twist.set(rightStick.getX()); tilt.set(rightStick.getY()); if(other.getRawButton(8)){ arm.set(0.22);//arm down } else if(other.getRawButton(9)){ arm.set(-0.65);//arm up } else{ arm.set(0.0);//arm stop } //if button 6 is pushed, fire the claw if(other.getRawButton(6)) { // clawfire.set(true); // clawrelease.set(false); } //if button 7 is pushed release the tube if(other.getRawButton(7)){ // clawrelease.set(true); // clawfire.set(false); } //button 1 releases the pin holding the minibot in if(other.getRawButton(1)){ pin1.setAngle(45); pin2.setAngle(45); //button 11 fires the slide } if(other.getRawButton(11)) { // sliderelease.set(false); // slidefire.set(true); } if(other.getRawButton(10)){ // slidefire.set(false); // sliderelease.set(true); } if (driveMode != ARCADE_DRIVE) { // if newly entered arcade drive, print out a message System.out.println("Arcade Drive\n"); driveMode = ARCADE_DRIVE; } } else { // use tank drive drive1.tankDrive(rightStick.getY(), leftStick.getY()); drive2.tankDrive(rightStick.getY(), leftStick.getY()); //should give us control over the camera servos twist.set(other.getX()); tilt.set(other.getY()); //jag drive /* jag1.set(rightStick.getY()); jag3.set(rightStick.getY()); //leftside motors jag2.set(-leftStick.getY()); jag4.set(-leftStick.getY()); */ if(other.getRawButton(8)){ arm.set(0.22);//arm up } else if(other.getRawButton(9)){ arm.set(-0.65);//arm down /* if(pot.getValue() <= 700){ arm.set(-0.75); }*/ } else{ arm.set(0.0);//arm stop } //button 6 fires claw solenoid if(other.getRawButton(6)) { // clawrelease.set(false); // clawfire.set(true); } //button 7 releases claw solenoid if(other.getRawButton(7)) { //clawfire.set(false); //clawrelease.set(true); } //button 1 releases the pin holding the minibot in if(other.getRawButton(1)){ pin1.setAngle(45); pin2.setAngle(45); } if(other.getRawButton(11)) { // sliderelease.set(false); // slidefire.set(true); } if(other.getRawButton(10)){ // slidefire.set(false); // sliderelease.set(true); } if (driveMode != TANK_DRIVE) { // if newly entered tank drive, print out a message System.out.println("Tank Drive\n"); driveMode = TANK_DRIVE; } } } } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|