Go to Post Just wear your safety glasses. They can be stylish, too! - Eugenia Gabrielov [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 10-01-2015, 14:05
aweso_meme aweso_meme is offline
Registered User
FRC #4687
 
Join Date: Feb 2014
Location: Minnesota
Posts: 20
aweso_meme is an unknown quantity at this point
Code Not Working

Hi,

The following code does not work on the new RoboRio. The original code WORKS on the old cRIO. All I did was update how Robot Drive Works as per the WPI Screen Steps Live Website. Information as to what does not work is as follows:

1) The program builds correctly.
2) The computer connects to the Robo Rio.
3) The joystick is detected.
4) When the joystick is moved, nothing happens.

Here is my code:

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


import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.*;



public class Robot extends SampleRobot 
{
	//Definitions
	Jaguar j1 = new Jaguar(1);
	Jaguar j2 = new Jaguar(2);
	Jaguar j3 = new Jaguar(3);
	Jaguar j4 = new Jaguar(4);
	Jaguar j5 = new Jaguar(5);
	Jaguar j6 = new Jaguar(6);
	Jaguar j7 = new Jaguar(7);
	Jaguar j8 = new Jaguar(8);
	RobotDrive driveA = new RobotDrive(j1,j2,j3,j4);
	RobotDrive driveB = new RobotDrive(j5,j6,j7,j8);
    
	Joystick drivestick = new Joystick(1);
	
    public void autonomous() 
    {
        
    }
    
    public void operatorControl() 
    {
    	//INSTANTIATION STATEMENTS
    	double joyX, joyY, joyZ;
    	
        if(isOperatorControl() && isEnabled())
        {
        	//Define the dead zone for driving
        	if(drivestick.getX() < 0.1 && drivestick.getX() > -0.1) joyX=0;
        	else joyX = drivestick.getX();
        	
        	if(drivestick.getY() < 0.1 && drivestick.getY() > -0.1) joyY=0;
        	else joyY = drivestick.getY();
        	
        	if(drivestick.getZ() < 0.1 && drivestick.getZ() > -0.1) joyZ=0;
        	else joyZ = drivestick.getZ();
        	
        	//Drive
        	driveA.mecanumDrive_Cartesian(joyX, joyY, joyZ, 0);
        	driveB.mecanumDrive_Cartesian(joyX, joyY, joyZ, 0);
        }
    }
    
    public void test() 
    {
    	
    }
    
    @Override
    public void disabled() 
    {
    
    }
    
}
Everything is hooked up correctly on the power distribution board and the other electronics issues. Does anyone see what is wrong?

Thanks all.

PS: Is there any way to run System.out.println() statements as there was in Netbeans? Can I just type System.out.println() and it will print to the eclipse console each time it is called?
  #2   Spotlight this post!  
Unread 10-01-2015, 14:08
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Code Not Working

Starting this year the "first" joystick is index 0, not 1. So you might need to move the joystick to slot '1' from slot '0' in the DS. Or just change the constructor param to '0' from '1'.
  #3   Spotlight this post!  
Unread 10-01-2015, 14:10
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Code Not Working

println ouput should land in the riolog window.

Look for "Riolog" at...
http://wpilib.screenstepslive.com/s/...console-output
  #4   Spotlight this post!  
Unread 10-01-2015, 14:26
aweso_meme aweso_meme is offline
Registered User
FRC #4687
 
Join Date: Feb 2014
Location: Minnesota
Posts: 20
aweso_meme is an unknown quantity at this point
Re: Code Not Working

I tried switching the joystick to new Joystick(0); and nothing happened again. Anything else that looks off?
  #5   Spotlight this post!  
Unread 10-01-2015, 14:36
Joey1939's Avatar
Joey1939 Joey1939 is offline
Registered User
AKA: Joey Holliday
FRC #1939 (Kuhnigits)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Kansas City, Missouri
Posts: 140
Joey1939 has a spectacular aura aboutJoey1939 has a spectacular aura aboutJoey1939 has a spectacular aura about
Re: Code Not Working

I am very confused why you have two RobotDrive instances, but I would recommend checking the lights on the Jaguars to verify they are receiving commands.

EDIT: I re-read it and found the error. operatorControl() is only called once. You should replace "if" with "while" to make it run constantly until telop is finished. Also add a Timer.delay(0.05) at the end to free up the cpu.

Last edited by Joey1939 : 10-01-2015 at 14:38.
  #6   Spotlight this post!  
Unread 10-01-2015, 15:03
aweso_meme aweso_meme is offline
Registered User
FRC #4687
 
Join Date: Feb 2014
Location: Minnesota
Posts: 20
aweso_meme is an unknown quantity at this point
Re: Code Not Working

Thanks Joey, that was it. I must have written it wrong when copying the code over.
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 02:38.

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