Go to Post Good judgement is the result of Experience. Experience is the result of Poor Judgement. - ChrisH [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-02-2016, 18:47
Lesafian Lesafian is offline
Registered User
AKA: Jeremy Styma
FRC #6077 (Wiking Kujon)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Posen, Michigan
Posts: 38
Lesafian is an unknown quantity at this point
Losing Communications Code Issue?

We're having a major issue with our robot. We're constantly losing communications. It seems to mainly happen after going over an obstacle, but it also can happen from just turning too sharp.

I was getting an error spammed, it was something like RobotDrive... Output not updated enough. I added drive.setSafetyEnabled(false); to the teleop code to get rid of that.

There are no other errors besides that.

I've re imaged the radio a few times, but I have not re imaged the roborio. The battery is also fully charged.

I'm wondering if it's a programming issue, here is my code. Going to a scrimmage tomorrow so a quick fix Is really needed.

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

import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Counter;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.vision.USBCamera;
	
public class Robot extends SampleRobot {

    // Declarations
	
	RobotDrive drive;
	
	CameraServer camserver;
	
	Compressor compressor;
	
    CameraServer server;
    USBCamera camera1; //camera2;
    
	DoubleSolenoid claw, pusher;
	
	DigitalInput limit1;
	Counter counter;
	
	Joystick xboxController;
	Joystick logitech3dpro;
	
	VictorSP drivemotor1;
	VictorSP drivemotor2;
	VictorSP drivemotor3;
	VictorSP drivemotor4;
	VictorSP slideMotor;
	VictorSP armMotor;

	// Autonomous Names
	final String defaultAuto = "Default Autonomous";
	final String customAuto = "Autonomous Choice 1";
	final String customAuto2 = "Autonomous Choice 2";
	final String customAuto3 = "Autonomous Choice 3";
	final String customAuto4 = "Autonomous Choice 4";
	final String customAuto5 = "Autonomous Choice 5";
	final String limitswitchpress = "Limit Switch Pressed";

	// Chooser
	SendableChooser chooser;

	public Robot() {
		//Change values later
		drivemotor1 = new VictorSP(0);
		drivemotor2 = new VictorSP(1);
		drivemotor3 = new VictorSP(2);
		drivemotor4 = new VictorSP(3);
		
		compressor = new Compressor(0);
		
        server = CameraServer.getInstance();
        camera1 = new USBCamera("cam0");
        //camera2 = new USBCamera("cam1");
        
		drive = new RobotDrive(drivemotor1, drivemotor2,
				drivemotor3, drivemotor4);
		drive.setExpiration(0.1);
		
		xboxController = new Joystick(0);
		logitech3dpro = new Joystick(1);
		
		armMotor = new VictorSP(5);
		slideMotor = new VictorSP(4);

		claw = new DoubleSolenoid(0, 1);
		pusher = new DoubleSolenoid(2, 3);
		
		limit1 = new DigitalInput(0);
		counter = new Counter(limit1);

		chooser = new SendableChooser();

	}

	public void robotInit() {
		compressor.setClosedLoopControl(true);
		compressor.start();
		chooser.addDefault("Default Autonomous", defaultAuto);
		chooser.addObject("Autonomous Choice 1", customAuto);
		chooser.addObject("Autonomous Choice 2", customAuto2);
		chooser.addObject("Autonomous Choice 3", customAuto3);
		chooser.addObject("Autonomous Choice 4", customAuto4);
		chooser.addObject("Autonomous Choice 5", customAuto5);
		SmartDashboard.putData("Autonomous Chooser", chooser);
	}

	public void autonomous() {
		drive.setSafetyEnabled(false);
		String autoSelected = (String) chooser.getSelected();
		System.out.println("Autonomous Mode selected: " + autoSelected);

		switch (autoSelected) {

		case customAuto5:		
			break;
		case customAuto4:		
			break;
		case customAuto3:
			break;
		case customAuto2:
			break;
		case customAuto:
			break;
		case defaultAuto:
		default:
			drive.drive(0.6, 0);
			Timer.delay(2.2);
			drive.drive(0, 0);
			break;
		}
		Scheduler.getInstance().run();
	}

	public void operatorControl() {
		drive.setSafetyEnabled(false);
		while (isOperatorControl() && isEnabled()) {
			
	        //Default Camera Selection
			camera1.setFPS(30);
	        server.setQuality(50);
	        server.startAutomaticCapture(camera1);
			
			// Move robot using left and right joystick
			
			//drive.tankDrive(xboxController.getRawAxis(1), xboxController.getRawAxis(5));
			drive.arcadeDrive(xboxController.getRawAxis(1), -xboxController.getRawAxis(0));

			//Xbox Controller
			
			//Arm Motor Test With Triggers
			if (Math.abs(xboxController.getRawAxis(3)) > .1) {
				
				armMotor.set(xboxController.getRawAxis(3));
				
			} else if (Math.abs(xboxController.getRawAxis(2)) > .1) {
				
				armMotor.set(-xboxController.getRawAxis(2));
				
			} else {
				
				armMotor.set(0);
				
			}
		
			// Move sliding mechanism forwards and backwards
			if (limit1.get() == true) {
				
				slideMotor.stopMotor();
				Timer.delay(0.25);
				slideMotor.set(-0.25);
				Timer.delay(0.5);
				
			} else if (limit1.get() == false) {
				
				if (Math.abs(xboxController.getRawAxis(5)) > .1) {
     
					slideMotor.set(-xboxController.getRawAxis(5));
		
				} else {
				
					slideMotor.set(0);
				}
			}
			
			
			//Logitech 3D PRO
			
			//Pusher Pneumatics System
			if (logitech3dpro.getRawButton(1)) {
				
				pusher.set(DoubleSolenoid.Value.kForward);
				claw.set(DoubleSolenoid.Value.kReverse);
				Timer.delay(1);
				pusher.set(DoubleSolenoid.Value.kReverse);
				
			}
			
			//Claw Pneumatics System
			if (logitech3dpro.getRawAxis(1) > .1) {
				
				claw.set(DoubleSolenoid.Value.kReverse);
				
			} else if (logitech3dpro.getRawAxis(1) < -.1) {
				
				claw.set(DoubleSolenoid.Value.kForward);
			}
			
			Timer.delay(0.005); //Wait for a motor update time
			
			//Camera Switcher
			/*if (logitech3dpro.getRawButton(3)) {
				
				camera2.setFPS(30);
				server.startAutomaticCapture(camera2);
				
			} else if (logitech3dpro.getRawButton(4)) {
				
				camera1.setFPS(30);
				server.startAutomaticCapture(camera1);
			*/
			}
		}
	public void test() {
	}
}

Last edited by Lesafian : 19-02-2016 at 18:52.
  #2   Spotlight this post!  
Unread 19-02-2016, 18:52
fsilberberg fsilberberg is offline
WPILib Developer
AKA: Fred Silberberg
FRC #0190
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Redmond
Posts: 148
fsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura about
Because it happens when subjecting force to your robot, I'd be more inclined to think it's a wiring issue. Try watching the status lights on your RIO/radio as you lose coms. Do you see it reboot? Can you jiggle the wires and cause a reboot?
  #3   Spotlight this post!  
Unread 19-02-2016, 19:00
Chris Mounts's Avatar
Chris Mounts Chris Mounts is offline
Registered User
FRC #1188 (Oaktown Crewz)
Team Role: Coach
 
Join Date: Apr 2013
Rookie Year: 2010
Location: Royal Oak, MI
Posts: 36
Chris Mounts is an unknown quantity at this point
Re: Losing Communications Code Issue?

Take a look at this thread: http://www.chiefdelphi.com/forums/sh...hreadid=143892

Lot's of possible reasons.
  #4   Spotlight this post!  
Unread 19-02-2016, 21:05
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Losing Communications Code Issue?

Do you really want to do the camera1/server initialization every time through the operatorControl() loop?

I'm pretty sure you do not want to put all those Timer.delay() calls in there. Every time you activate your pusher, or your slide limit is hit, you're going to stall the code and lose communication. If you need to do timed sequences like that, they need to go in a parallel task outside the loop, or you need to implement them as a state machine that checks the clock to know when to step to the next state.
Closed Thread


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 01:31.

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