Go to Post Naw, basketball isn't nearly as great a sport as FRC. They play for the money. We play for honor, dignity, and respect. - synth3tk [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-19-2017, 12:23 PM
Redstonecore Redstonecore is offline
Registered User
FRC #6135
 
Join Date: Mar 2017
Location: Toronto
Posts: 3
Redstonecore is an unknown quantity at this point
NAVX micro inconsistently reading data.

We are using NAVX-micro on our robot for straight driving and turning but we are having a problem where the majority of the time our navx is not reading data correctly just outputting constant values which we are reading through smartdashboard. Occasionally when we enable the robot the navx outputs data normally and that makes sense but this is the exception. We are using our navx through usb. While we are using USB the navx is also connected to the roborio through I2C. We are not however instantiating the navx through I2C. The navx is also not returning an error when we instantiate it. We have also calibrated the navx and like I said it occasionally returns correct values. The relevant code is here
Code:
package org.usfirst.frc.team6135.robot;
import com.kauailabs.navx.frc.AHRS;
import com.ctre.CANTalon;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.I2C;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.PIDController;
import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.PIDSource;
import edu.wpi.first.wpilibj.SPI;
import edu.wpi.first.wpilibj.SerialPort;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Drive implements PIDOutput {
	//Variables used
	private double rSpeed = 0.0;
	private double lSpeed = 0.0;
	private double xInput;
	private double yInput;
	private double zInput;
	private double xFinal;
	private double yFinal;
	private double scale = 1.0;
	private double speed = 1.0;
	private static boolean straight = true;//If true drive straight; if false rotate to correct angle
	
	//Constants
	private static final double kPS = 0.03;//Driving straight
    private static final double kIS = 0.00;
    private static final double kDS = 0.00;
	private static final double kToleranceDegreesS = 2.0f;
    
	private static final double kPR = 0.03;//Rotating to angle
    private static final double kIR = 0.00;
    private static final double kDR = 0.00;
	private static final double kToleranceDegreesR = 2.0f;
	
	private static final int yAxis = 1;
	private static final int yReverse = -1;
	private static final int xAxis = 0;
	private static final int xReverse = 1;
	private static final int zAxis = 2;

	private static final int exactDriveButton = 2;

	private static final boolean rReverse = true;
	private static final boolean lReverse = false;
	
	private static final double WHEEL_RADIUS=6;
	private static final double PULSECNT=48;
	//Objects
	private Joystick driveStick = null;
	private Victor leftDrive = null;
	private Victor rightDrive = null;
	private AHRS ahrs = null;
	public PIDController balance = null;
	//Constructors
	public Drive(Joystick j, int l, int r) {
		driveStick = j;
		leftDrive = new Victor(l);
		rightDrive = new Victor(r);
		leftDrive.set(0);
		rightDrive.set(0);
		leftDrive.setInverted(lReverse);
		rightDrive.setInverted(rReverse);
		try {
			ahrs = new AHRS(SerialPort.Port.kUSB1); 
        } catch (RuntimeException ex ) {
            DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
        }
		balance = new PIDController(kPS, kIS, kDS, ahrs, this);
		balance.setSetpoint(0.0f);
		balance.setInputRange(-180.0f,  180.0f);
		balance.setOutputRange(-1, 1);
        balance.setAbsoluteTolerance(kToleranceDegreesS);
        balance.setContinuous(true);
		balance.enable();
	}
//This is the code we are using to directly check whether the navx is returning data properly. It is run repeatedly during teleop.
public void printValues() {
		SmartDashboard.putNumber("Yaw", ahrs.getYaw());
		SmartDashboard.putNumber("Angle", ahrs.getAngle());
		SmartDashboard.putNumber("Scale", scale);
		SmartDashboard.putBoolean("PID", balance.isEnabled());
		SmartDashboard.putNumber("NAVX-1", ahrs.getAngleAdjustment());
		SmartDashboard.putNumber("NAVX-2", ahrs.getRate());
		SmartDashboard.putNumber("NAVX-3", ahrs.getAltitude());
		SmartDashboard.putNumber("NAVX-4", ahrs.getCompassHeading());
		SmartDashboard.putNumber("NAVX-5", ahrs.getDisplacementX());
		SmartDashboard.putNumber("NAVX-6", ahrs.getDisplacementY());
		SmartDashboard.putNumber("NAVX-7", ahrs.getDisplacementZ());
		SmartDashboard.putNumber("NAVX-8", ahrs.getPitch());
		SmartDashboard.putNumber("NAVX-9", ahrs.getRawGyroX());
		SmartDashboard.putNumber("NAVX-10", ahrs.getRawGyroY());
		SmartDashboard.putNumber("NAVX-11", ahrs.getRawGyroZ());
		SmartDashboard.putNumber("NAVX-12", ahrs.getRoll());
		SmartDashboard.putNumber("NAVX-13", ahrs.getVelocityX());
		
	}
And if it is relevant here is the entire class
Code:
package org.usfirst.frc.team6135.robot;
import com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.PIDController;
import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.SerialPort;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
/**
 This class handles the driving mechanism of the robot. It uses navX to adjust its position
 Creater: Adrian Carpenter 
 */
public class Drive implements PIDOutput {
	//Variables used
	private double rSpeed = 0.0;
	private double lSpeed = 0.0;
	private double xInput;
	private double yInput;
	private double zInput;
	private double xFinal;
	private double yFinal;
	private double scale = 1.0;
	private double speed = 1.0;
	private static boolean straight = true;//If true drive straight; if false rotate to correct angle
	
	//Constants
	private static final double kPS = 0.03;//Driving straight
    private static final double kIS = 0.00;
    private static final double kDS = 0.00;
	private static final double kToleranceDegreesS = 2.0f;
    
	private static final double kPR = 0.03;//Rotating to angle
    private static final double kIR = 0.00;
    private static final double kDR = 0.00;
	private static final double kToleranceDegreesR = 2.0f;
	
	private static final int yAxis = 1;
	private static final int yReverse = -1;
	private static final int xAxis = 0;
	private static final int xReverse = 1;
	private static final int zAxis = 2;

	private static final int exactDriveButton = 1;

	private static final boolean rReverse = true;
	private static final boolean lReverse = false;
	
	private static final double WHEEL_RADIUS=6;
	private static final double PULSECNT=48;
	//Objects
	private Joystick driveStick = null;
	private Victor leftDrive = null;
	private Victor rightDrive = null;
	private AHRS ahrs = null;
	//private CANTalon test = null;
	public PIDController balance = null;
	//Constructors
	public Drive(Joystick j, int l, int r) {
		driveStick = j;
		leftDrive = new Victor(l);
		rightDrive = new Victor(r);
		leftDrive.set(0);
		rightDrive.set(0);
		leftDrive.setInverted(lReverse);
		rightDrive.setInverted(rReverse);
		try {
			ahrs = new AHRS(SerialPort.Port.kUSB1);
			SmartDashboard.putString("NAVX", "Not RIP?");
        } catch (RuntimeException ex ) {
            DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
            SmartDashboard.putString("NAVX", "RIP");
        }
		balance = new PIDController(kPS, kIS, kDS, ahrs, this);
		balance.setSetpoint(0.0f);
		balance.setInputRange(-180.0f,  180.0f);
		balance.setOutputRange(-1, 1);
        balance.setAbsoluteTolerance(kToleranceDegreesS);
        balance.setContinuous(true);
		balance.enable();
		LiveWindow.addActuator("Drive", "PID", balance);
	}
	public void setRotate() {
		ahrs.reset();
		balance.setPID(kPR, kIR, kDR);
		balance.setAbsoluteTolerance(kToleranceDegreesR);
		straight = false;
	}

	public void setStraight() {
		ahrs.reset();
		balance.setPID(kPS, kIS, kDS);
		balance.setAbsoluteTolerance(kToleranceDegreesS);
		straight = true;
	}
	//Direct object access methods
	public void setMotors(double l, double r) {//sets motor speeds accounting for directions of motors
		if(l == r && yInput > 0) {
			leftDrive.set(l * scale);
			rightDrive.set(r / scale); //Dividing one speed while multiplying other to speed up slower motor while slowing down faster motor
		}
		else if(l == r && yInput < 0) {
			leftDrive.set(l / scale);
			rightDrive.set(r * scale);
		}
		else {
			leftDrive.set(l * speed);
			rightDrive.set(r * speed);
		}
	}
	public void setLeft(double d) {
		leftDrive.set(d);
	}
	public void setRight(double d) {
		rightDrive.set(d);
	}
	public void getSpeeds() {//converts input values to motor speeds
		if (yFinal > 0.0) {
	   		if (xFinal > 0.0) {
	       	    rSpeed = yFinal - xFinal;
	       	    lSpeed = Math.max(yFinal, xFinal);
	       	}
			else {
	       	    rSpeed = Math.max(yFinal, -xFinal);
	       	    lSpeed = yFinal + xFinal;
	       	}
	   	} 
		else {
	       	if (xFinal > 0.0) {
	       	    rSpeed = -Math.max(-yFinal, xFinal);
	       	    lSpeed = yFinal + xFinal;
	       	}
			else {
	       	    rSpeed = yFinal - xFinal;
	       	    lSpeed = -Math.max(-yFinal, -xFinal);
	       	}
	   	}
	}
	public void getValues(double x, double y, boolean sensitivity, boolean acc) {//takes input values and applies appropriate calculations to values to account for human error and/or joystick deficiencies
		xFinal = x;
		yFinal = y;
		
		if(sensitivity) {
			xFinal = sensitivityCalc(xFinal);
			yFinal = sensitivityCalc(yFinal);
		}	
		if(acc) {
			xFinal = accCalc(xFinal);
			yFinal = accCalc(yFinal);
		}
	}
	
	//Teleop Driving methods
	private static final double accBound = 0.7; //The speed after which the drive starts to accelerate over time
	private static final int accLoop = 15; //The number of loops for the bot to accelerate to max speed
	private int accLoopCount = 0;
	private double accCalc(double input) {//applies a delay for motors to reach full speed for larger joystick inputs
		if(input > accBound && accLoopCount < accLoop) {//positive inputs
	    		return accBound + (input - accBound) * (accLoopCount++ / (double) accLoop);
	    }
		else if(input < -accBound && accLoopCount < accLoop) {//negative inputs
	    		return -accBound + (input + accBound) * (accLoopCount++ / (double) accLoop);
	    }
	    else if(Math.abs(input) <= accBound) {
	    	accLoopCount = 0;
	    }
		return input;
	}
	private double sensitivityCalc(double input) {//Squares magnitude of input to reduce magnitude of smaller joystick inputs
		if (input >= 0.0) {
	        return (input * input);
	    }
		else {
	    	return -(input * input);
	    }
	}

	private void exactDrive() {//This method will essentially "round" the joystick inputs to purely in the x direction or purely in the y direction depending on which has greater magnitude 
		if(Math.abs(yInput) > Math.abs(xInput)) {
			xInput = 0;
		}
		else {
			yInput = 0;
		}
	}
	private static final boolean useSensitivityCalc = true;
	private static final boolean useAccelerateCalc = true;
	public void teleopDrive() {//Implements individual driving and input methods to allow driving in teleop
		xInput = xReverse * driveStick.getRawAxis(xAxis);
		yInput = yReverse * driveStick.getRawAxis(yAxis);
		zInput = driveStick.getRawAxis(zAxis);
		if(driveStick.getRawButton(exactDriveButton)) {
			exactDrive();
		}
		if(Math.abs(xInput) < 0.2) {
			xInput = 0;
			if(!balance.isEnabled()) {
				//balance.enable();
				ahrs.reset();
			}
		}
		else {
			if(balance.isEnabled()) {
				balance.disable();
			}
		}
		if(Math.abs(yInput) < 0.2) {
			yInput = 0;
			if(Math.abs(zInput) < 0.2) {
				zInput = 0;
			}
			else {
				xInput = zInput;
			}
		}
		getValues(xInput, yInput, useSensitivityCalc, useAccelerateCalc);
			
		getSpeeds();
			
		setMotors(lSpeed, rSpeed);
	}
	public void pidWrite(double output) {
		if(straight) {
			scale = Math.pow(2, output);
			speed = 1.0;
		}
		else {
			speed = output;
			scale = 1.0;
		}
    }
	public void reverse() {
		leftDrive.setInverted(!leftDrive.getInverted());
		rightDrive.setInverted(!rightDrive.getInverted());
		Victor temp1 = leftDrive;
		Victor temp2 = rightDrive;
		rightDrive = temp1;
		leftDrive = temp2;
	}
	//added accessMethod
	public void printValues() {
		SmartDashboard.putNumber("Yaw", ahrs.getYaw());
		SmartDashboard.putNumber("Angle", ahrs.getAngle());
		SmartDashboard.putNumber("Scale", scale);
		SmartDashboard.putBoolean("PID", balance.isEnabled());
		SmartDashboard.putNumber("Compass", ahrs.getCompassHeading());
	}
}
Reply With Quote
  #2   Spotlight this post!  
Unread 03-19-2017, 03:37 PM
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 431
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: NAVX micro inconsistently reading data.

Is the USB connected to the first or the second USB port from the top of the RoboRIO?

Also some teams see issues if also using USB lifecam. So you might try I2C: if so carefully check you wiring to make sure power, ground, SDA and SCL match.

- Scott
Reply With Quote
  #3   Spotlight this post!  
Unread 03-20-2017, 06:52 AM
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 99
JefferMC has a spectacular aura aboutJefferMC has a spectacular aura about
Re: NAVX micro inconsistently reading data.

I have seen issues with the navX over USB as well. Maybe once in every 20 reboots it appears to not communicate. A roborio reboot always fixes it. Haven't had a chance to dig into it in any way.
Reply With Quote
  #4   Spotlight this post!  
Unread 03-20-2017, 12:56 PM
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 431
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: NAVX micro inconsistently reading data.

Quote:
Originally Posted by JefferMC View Post
I have seen issues with the navX over USB as well. Maybe once in every 20 reboots it appears to not communicate. A roborio reboot always fixes it. Haven't had a chance to dig into it in any way.
We're trying to nail down the cases that cause this to occur; at this point we believe it's occuring when the LifeCam is used simultaneously w/the navX over USB.

Can you please let us know if you have any other USB device connected to the RoboRIO when you see the problem, and whether you are using C++, Java or LabVIEW?
Reply With Quote
  #5   Spotlight this post!  
Unread 03-20-2017, 02:27 PM
Redstonecore Redstonecore is offline
Registered User
FRC #6135
 
Join Date: Mar 2017
Location: Toronto
Posts: 3
Redstonecore is an unknown quantity at this point
Re: NAVX micro inconsistently reading data.

Quote:
Originally Posted by slibert View Post
We're trying to nail down the cases that cause this to occur; at this point we believe it's occuring when the LifeCam is used simultaneously w/the navX over USB.

Can you please let us know if you have any other USB device connected to the RoboRIO when you see the problem, and whether you are using C++, Java or LabVIEW?
We are also using lifecam and we are using Java. We previously were attempting to use I2C but we were never reading any data and using USB seemed to help somewhat.
Reply With Quote
  #6   Spotlight this post!  
Unread 03-20-2017, 03:29 PM
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 99
JefferMC has a spectacular aura aboutJefferMC has a spectacular aura about
Re: NAVX micro inconsistently reading data.

The other USB port is powering a Raspberry Pi 3, to which two Microsoft USB Lifecams are attached. Our program is written in C++.
Reply With Quote
  #7   Spotlight this post!  
Unread 03-20-2017, 05:06 PM
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 431
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: NAVX micro inconsistently reading data.

Quote:
Originally Posted by Redstonecore View Post
We are also using lifecam and we are using Java. We previously were attempting to use I2C but we were never reading any data and using USB seemed to help somewhat.
If using I2C, check the wiring carefully. The navX-Micro was originally made for FTC and the order of the Power/Ground/SCL/SDA pins is different than for the RoboRIO.
Reply With Quote
  #8   Spotlight this post!  
Unread 03-20-2017, 05:20 PM
Redstonecore Redstonecore is offline
Registered User
FRC #6135
 
Join Date: Mar 2017
Location: Toronto
Posts: 3
Redstonecore is an unknown quantity at this point
Re: NAVX micro inconsistently reading data.

Quote:
Originally Posted by slibert View Post
Is the USB connected to the first or the second USB port from the top of the RoboRIO?

Also some teams see issues if also using USB lifecam. So you might try I2C: if so carefully check you wiring to make sure power, ground, SDA and SCL match.

- Scott
The navx is connected to the first USB port from the top of the roborio.
Reply With Quote
  #9   Spotlight this post!  
Unread 03-22-2017, 01:24 AM
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 431
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Thumbs up Re: NAVX micro inconsistently reading data.

Quote:
Originally Posted by slibert View Post
If using I2C, check the wiring carefully. The navX-Micro was originally made for FTC and the order of the Power/Ground/SCL/SDA pins is different than for the RoboRIO.
NOTE: for I2C communication, the RoboRIO has two separate I2C ports:

"Onboard" (the "I2C" connector at the top-left of the RoboRIO, in the graphic below), and

"MXP" (on the MXP connector pins)



The navX online examples use "MXP", but if you are using navX-Micro you may be connecting the navX-Micro I2C connector to the RoboRIO "Onboard" I2C port. If the navX-Micro is connected to the RoboRIO "onboard" I2C port, your robot application must specify that the "onboard" port is being used.

**Java/C++**

Use the following to communicate via the RoboRIO Onboard I2C port:

[Java] ahrs = new AHRS(I2C.Port.kOnboard);

[C++] ahres = new AHRS(I2C:ort::kOnboard);

[Note if using C++ or Java: WPI library v. 2017.3.1 changed slightly the I2C communication, which impacts navX-Micro/MXP I2C communication. The latest navX RoboRIO libraries match the WPI library 2017.3.1 plugins for Java/C++. If the navX & WPI library versions don't match, there can be issues communicating over I2C with navX-Micro.]

**LabVIEW**

To configure navX Main.vi to use the Onboard I2C port, use this example:

Reply With Quote
  #10   Spotlight this post!  
Unread 03-22-2017, 04:10 PM
Anon10W1z Anon10W1z is offline
Registered User
FRC #3256 (WarriorBorgs)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2017
Location: San Jose
Posts: 80
Anon10W1z is on a distinguished road
Re: NAVX micro inconsistently reading data.

Quote:
Originally Posted by JefferMC View Post
The other USB port is powering a Raspberry Pi 3, to which two Microsoft USB Lifecams are attached. Our program is written in C++.
NEVER power the Pi 3 using the roboRIO USB ports. It provides 500 mA whilst the Pi 3 is rated for 2 amps.
Reply With Quote
  #11   Spotlight this post!  
Unread 03-22-2017, 04:35 PM
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 99
JefferMC has a spectacular aura aboutJefferMC has a spectacular aura about
Re: NAVX micro inconsistently reading data.

Actually, they're 0.9 A each, but your point is well taken, they're not 2.0 A.

(See http://www.ni.com/pdf/manuals/374661a.pdf for confirmation of 0.9 A)

However,

Quote:
Typically, the model B uses between 700-1000mA depending on what peripherals are connected; the model A can use as little as 500mA with no peripherals attached. The maximum power the Raspberry Pi can use is 1 Amp.
(Thats from https://www.raspberrypi.org/document...ower/README.md )

So... this brings us to a gray area. I happen to have a USB power meter and can verify what we're actually drawing to see if we're challenging the 0.9 A supply.
Reply With Quote
  #12   Spotlight this post!  
Unread 03-22-2017, 09:12 PM
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 431
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: NAVX micro inconsistently reading data.

Quote:
Originally Posted by JefferMC View Post
I have seen issues with the navX over USB as well. Maybe once in every 20 reboots it appears to not communicate. A roborio reboot always fixes it. Haven't had a chance to dig into it in any way.
Is the navX-Micro connected to the first or second RoboRIO USB port (looking down from the top of the RoboRIO)?
Reply With Quote
  #13   Spotlight this post!  
Unread 03-22-2017, 09:46 PM
Poseidon's Avatar
Poseidon Poseidon is offline
In-Between
AKA: Mitchel Stokes
no team (In-Between)
Team Role: College Student
 
Join Date: Aug 2013
Rookie Year: 2014
Location: Berkeley, CA
Posts: 653
Poseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant futurePoseidon has a brilliant future
Re: NAVX micro inconsistently reading data.

We've also had this issue, where sometimes after uploading code the navx doesn't read data. A roborio reboot fixes it. This happens around 5% of the time.
__________________



Reply With Quote
  #14   Spotlight this post!  
Unread 03-22-2017, 10:31 PM
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 431
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: NAVX micro inconsistently reading data.

We're collecting all the reported symptoms. What language are you using? Which roboRIO USB port are you connected to?

As far as the reboot required after download, what appears to be happening is the operating system code that reclaims resources (e.g., serial ports) is not working for the RoboRIO USB serial port. The thing that happens differently in my test is that happens more frequently than 5% of the time.

We're running tests w/both the Microsoft LifeCAM HD 3000 and the navX-Micro plugged in simultaneously to different RoboRIO USB ports. Lifecam is not a USB serial device, but navX-Micro is.

If the robot application is restarted (which abruptly terminates the robot application, much as would happen when a newly downloaded version of code is sent to the roborio), when the application starts the second time it can't open the USB serial port (but it can open the LifeCam).

However as you say, if the roborio is rebooted, this issue does not occur, since in this case the USB serial port had never been opened by a now-dead RoboRIO process.

- scott

Last edited by slibert : 03-22-2017 at 10:39 PM.
Reply With Quote
  #15   Spotlight this post!  
Unread 03-23-2017, 12:24 AM
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 431
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
Re: NAVX micro inconsistently reading data.

Redstonecore, JefferMC, Poseidon5817:

After reviewing all your inputs and considering the different failure rates we are seeing and when, I have found a workaround (which provides clues to what the underlying problem is) for Java (and likely C++) users of USB-connected navX-Micro.

First I was able to reproduce (about 5% of the time or so), when there is a Java program that uses the Microsoft HD LifeCam 3000 and also a USB-connected navX-Micro, that the navX-Micro library can't open the USB serial port when the robot application starts. On the Microsoft HD LifeCAM 3000, the test application uses CameraServer.getInstance().startAutomaticCapture() to start streaming from the camera to the dashboard.

After some time, I discovered that if navX-Micro communication is initialized first (by instantiating the AHRS class), then a 1 second delay is inserted, then the CameraServer is initialized - that the navX-Micro was always able to open the USB serial port. And this works whether the robot application is restarted or the robot application is rebooted. And this works whether the navX-Micro is connected to USB port 1 or 2. I've tested this with 80 successive reboots and 100 successive robot application restarts.

This suggests that somehow the opening of the Microsoft HD LifeCam 3000 stream can cause (if the timing is right) a USB serial port open request to fail every now and then. So the workaround is ensure the USB serial port open occurs and completes first.

So I'd like to request that each of you reivew your code and add the appropriate delay (1 second seems sufficient) after opening navX-Micro before opening the Microsoft HD LifeCam 3000 camera server stream. If we can get positive results around the board I can move on to the next step of working w/the folks at WPI and/or National Instruments to find and fix the root cause. We may be able to adjust the navX-MXP/Micro library to avoid having to add any delays if we can understand this better.

So thanks for your helplful data points and please let me know your results.

Many thanks,

- scott
Reply With Quote
Reply


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 07:04 AM.

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