Go to Post Students... be sure to drill air holes in the crate though. Maybe toss in some cheetos for the programmers. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 11-10-2016, 07:05 PM
koreamaniac101's Avatar
koreamaniac101 koreamaniac101 is offline
Founder and Team Leader
AKA: Soohan Kim
FRC #5938 (Razor Steel Robotics 4-H Club)
Team Role: Leadership
 
Join Date: Feb 2015
Rookie Year: 2016
Location: Dover, Delaware
Posts: 20
koreamaniac101 is an unknown quantity at this point
Camera Error in Driver Station

So for the past year, during Stronghold, our driver station was plagued with constant errors coming from the camera that look identical to this:

Code:
ERROR  1  Error when getting image from the camera: invalid image at pos 80871 (0)  java.lang.Thread.run(Thread.java:745)
Our robot's code is below:

Code:
package org.usfirst.frc.team5938.robot;


import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;

/**
 * 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 Robot extends IterativeRobot {
	RobotDrive myRobot;
	int autoLoopCounter;
	Joystick xLeftStick;  							// set to ID 1 in DriverStation
    Joystick xRightStick; 							// set to ID 2 in DriverStation
    Joystick Logitech;
    CameraServer Camera;
    SpeedController intake1;						// the motor to directly control with a joystick
    SpeedController intake2;
    SpeedController sprocket;
    SpeedController flicker;

    
    public Robot() {
        myRobot = new RobotDrive(0, 1);
        myRobot.setExpiration(0.1);
        xLeftStick = new Joystick(1);
        xRightStick = new Joystick(1);
        Logitech = new Joystick(0);
        
        
        Camera = CameraServer.getInstance();
        Camera.setQuality(35);						// set the quality of the camera
        Camera.startAutomaticCapture("cam2");			// the camera name (ex "cam0") can be found through the roborio web interface
        
        
        intake2 = new VictorSP(2);					// initialize the second intake motor as a VictorSP on channel 2
        intake1 = new VictorSP(3);					// initialize the first intake motor as a VictorSP on channel 3
        sprocket = new VictorSP(4);					// initialize the Sprocket on channel 4
        flicker = new VictorSP(5);
    }
	
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
    }
    
    /**
     * This function is run once each time the robot enters autonomous mode
     */
    public void autonomousInit() {
    	autoLoopCounter = 0;
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
    	
    	
    	if(autoLoopCounter < 100) 					//Check if we've completed 100 loops (approximately 2 seconds)
		{
			myRobot.drive(-0.65, 0.00); 				// drive forwards half speed
			autoLoopCounter++;
			} else {
			myRobot.drive(0.0, 0.0); 				// stop robot
			}
			
		
    }
    
    /**
     * This function is called once each time the robot enters tele-operated mode
     */
    public void teleopInit(){

    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
        myRobot.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {
        	
        	myRobot.tankDrive(xLeftStick.getRawAxis(5) * 0.7, xRightStick.getRawAxis(1) * 0.7);
        	//The right joystick actually controls the left side of the robot
        	//The right side of the robot seems to be accidently built slightly tighter, so I compensated by slowing the left side a bit
        	
        	
        	
        	if (Logitech.getPOV() == 0) {
        		intake1.set(-0.75);
        		intake2.set(0.75);
        	} else if (Logitech.getPOV() != 180) {
        		intake1.set(0);
        		intake2.set(0);
        	}
        	
        	
        	if (Logitech.getPOV() == 180) {
        		intake1.set(0.75);
        		intake2.set(-0.75);
        		flicker.set(0.75);
        	} else if (Logitech.getPOV() != 0 && Logitech.getRawButton(11) == false) {
        		intake1.set(0);
        		intake2.set(0);
        		flicker.set(0);
        	}
        	
        	if (Logitech.getRawButton(2) == true) {
        		intake1.set(-0.75);
        		intake2.set(0.75);
        	} else if (Logitech.getPOV() != 180 && Logitech.getPOV() != 0) {
        		intake1.set(0);
        		intake2.set(0);
        	}
        	
        	if (Logitech.getRawButton(1) == true) {
        		sprocket.set(.08);
        	} else {
        		sprocket.set(Logitech.getY() * 0.45);
        	}
        	
        	if (Logitech.getRawButton(11) == true) {
        		flicker.set(-1);
        	} else {
        		flicker.set(0);
        	}

        	}
        	
        		
               Timer.delay(0.005);					// wait for a motor update time
                
        }
    
    
    /**
     * This function is called periodically during test mode
     */
    public void testPeriodic() {
    	
    	LiveWindow.run();
    }
    
} //10/20/16 6:43 PM Uploaded (Current Version)
__________________
2016 MAR Hatboro-Horsham District Event Rookie All-Star Award
2016 MAR Seneca District Event Rookie Inspiration Award
2016 MAR District Championships Rookie Inspiration Award
__________________
2016 MAR Hatboro-Horsham District Event Rookie All-Star Award
2016 MAR Seneca District Event Rookie Inspiration Award
2016 MAR District Championships Rookie Inspiration Award
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:38 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi