View Single Post
  #1   Spotlight this post!  
Unread 03-04-2016, 10:15 PM
adamzg adamzg is offline
Mentor
AKA: Adam
FRC #3932 (Dirty Mechanics)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2008
Location: Boynton Beach, FL
Posts: 16
adamzg is an unknown quantity at this point
Exclamation WPILIB Camera Code Crashing JVM

Hi All,

We're coding in Java and started experiencing problems with the robot becoming disabled after a random interval. Checking the logs from the dashboard we saw that we were getting a message. Checking the message we found that the JVM was crashing when getting an image using the WPILib native libraries...

Code:
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Stack: [0xb68e1000,0xb6931000],  sp=0xb692f590,  free space=313k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libnivissvc.so.13+0x258f2c]  ProfilerPushLabeledTimer+0x53980

[error occurred during error reporting (printing native stack), id 0xb]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 361  com.ni.vision.NIVision._Priv_ReadJPEGString_C(JJI)V (0 bytes) @ 0xb4815038 [0xb4814fe0+0x58]
J 357 C1 edu.wpi.first.wpilibj.vision.AxisCamera.getImage(Lcom/ni/vision/NIVision$Image;)Z (47 bytes) @ 0xb4813b88 [0xb48138f0+0x298]
J 326 C1 org.usfirst.frc3932.Robot.runCamera()V (42 bytes) @ 0xb480bac8 [0xb480ba90+0x38]
J 324 C1 org.usfirst.frc3932.Robot.teleopPeriodic()V (15 bytes) @ 0xb480b3b0 [0xb480b180+0x230]
j  edu.wpi.first.wpilibj.IterativeRobot.startCompetition()V+240
j  edu.wpi.first.wpilibj.RobotBase.main([Ljava/lang/String;)V+322
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0xb67a7400 JavaThread "CameraServer Send Thread" [_thread_in_native, id=1733, stack(0xab632000,0xab682000)]
  0xad9e7800 JavaThread "Timer-1" [_thread_blocked, id=1591, stack(0xab970000,0xab9c0000)]
  0xad9e1c00 JavaThread "Thread-4" [_thread_blocked, id=1590, stack(0xab9c0000,0xaba10000)]
  0xabb0c400 JavaThread "Thread-3" [_thread_in_native, id=1589, stack(0xaba10000,0xaba60000)]
  0xabb0b000 JavaThread "Thread-2" [_thread_blocked, id=1588, stack(0xaba60000,0xabab0000)]
  0xabb0a000 JavaThread "Thread-1" [_thread_in_native, id=1587, stack(0xabab0000,0xabb00000)]
  0xad9f8800 JavaThread "Timer-0" [_thread_blocked, id=1586, stack(0xabc1f000,0xabc6f000)]
  0xad9f0800 JavaThread "NTListener" daemon [_thread_in_native, id=1585, stack(0xabc6f000,0xabcaf000)]
  0xad9bf800 JavaThread "FRCDriverStation" [_thread_in_native, id=1582, stack(0xabdc4000,0xabe14000)]
  0xb6799400 JavaThread "Service Thread" daemon [_thread_blocked, id=1570, stack(0xada9e000,0xadaee000)]
  0xb6796800 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=1569, stack(0xadaee000,0xadb6e000)]
  0xb6795000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1568, stack(0xadf0d000,0xadf5d000)]
  0xb6773000 JavaThread "Finalizer" daemon [_thread_blocked, id=1566, stack(0xadfb0000,0xae000000)]
  0xb6771800 JavaThread "Reference Handler" daemon [_thread_blocked, id=1565, stack(0xb4603000,0xb4653000)]
=>0xb6705800 JavaThread "main" [_thread_in_native, id=1548, stack(0xb68e1000,0xb6931000)]
...anyone else having a problem like this?

CPU is at around 75% before the crash, drops to about 50, then 50 15 within a second or 2 until the code gets reloaded. I've attached the log file. Anyone we can talk to since the problem is outside our code? It seems to happen after a random interval between 3 and 8 minutes while the robot is enabled, even if sitting idle.

This is a chunk of our Robot.java, pardon the duplicated code - it's a work in progress. Calling camera.getImage shouldn't crash the JVM on us. Eating the exception isn't a good idea either, including both to give the picture of what we actually have right now...
Code:
    public void robotInit() {
    RobotMap.init();
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        driveSystem = new DriveSystem();
        platform = new Platform();
        camera = new Camera();
        cannon = new Cannon();
        onBoardCompressor = new OnBoardCompressor();
        shooterWheels = new ShooterWheels();
        powerDistributionBoard = new PowerDistributionBoard();

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        // OI must be constructed after subsystems. If the OI creates Commands
        //(which it very likely will), subsystems are not guaranteed to be
        // constructed yet. Thus, their requires() statements may grab null
        // pointers. Bad news. Don't move it.
        oi = new OI();

        // instantiate the command used for the autonomous period
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS

        autonomousCommand = new DriveTenFeetAuto();

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
        
		image = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
		
		axis13 = initCamera("10.39.32.14");
		
		axis11 = initCamera("10.39.32.11");
		
		axis12 = initCamera("10.39.32.13");
		

		
		
		// Let's detect if that third camera's there
		try {
			axis13.getImage(image);
			// Hooray, it worked!
			thirdCamera = true;
		}
		catch (Exception e){
			// Third camera's not there
//			axis13 = null;
			thirdCamera = false;
		}
		
		SmartDashboard.putString("Camera 3", axis13+"");
		currentCamera = axis11;
		
		
		ahrs = new AHRS(SPI.Port.kMXP);
		
		rangefinder = new LIDAR(I2C.Port.kMXP);
		rangefinder.start();
		
		camera.lightOn();

    }

    public void teleopPeriodic() {
        Scheduler.getInstance().run();
        
        
//        checkCompressor();
        runCamera();
        writeLIDAR();
    }

    /**
     * This function is called periodically during operator control
     */
    
	
	private void runCamera(){
		try {
			currentCamera.getImage(image);
			CameraServer.getInstance().setImage(image);
		} catch (Exception e) {
			System.err.println("Failed to get image from camera");
			System.err.println(e.getStackTrace());
		}
	}

    public static boolean hasCameraThree() {
    	try {
    		axis13.getImage(image);
    		return true;
    	}
    	catch (Exception e){
    		return false;
    	}
    }
Any help appreciated!

Last edited by adamzg : 03-04-2016 at 10:19 PM. Reason: missed important block of code
Reply With Quote