Go to Post neato. - ebarker [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 28-01-2016, 09:43
CjDace CjDace is offline
Registered User
FRC #4284
 
Join Date: Jan 2016
Location: Cincinnati, Ohio
Posts: 10
CjDace is an unknown quantity at this point
Noob question for teleop

Hey, it appears our teleop code, after deploying it to the roboRio, likes to kick out after running through it once.
Code:
public void teleopPeriodic() {
	    	
	 
	    		myDrive.mecanumDrive_Cartesian(moveStick.getRawAxis(1), moveStick.getRawAxis(1), moveStick.getRawAxis(1), gyro.getAngle());
	    		Timer.delay(0.01);
	    
	   }
, and won't recognize the controller
Code:
RobotDrive myDrive, catcherDrive;
	    	Joystick moveStick;
	    	Gyro gyro;
	    	
	    
	    public void robotInit() {
	    	Talon TalLF = new Talon(0);
	    	Talon TalLR = new Talon(1);
	    	Talon TalRF = new Talon(2);
	    	Talon TalRR = new Talon(3);
	    	Talon TalCatcher = new Talon(4);
	    	Talon TalCatcher1 = new Talon(5);
	    	myDrive =  new RobotDrive(TalLF,TalLR,TalRF,TalRR);
	    	moveStick = new Joystick(1);
	    	catcherDrive = new RobotDrive(TalCatcher, TalCatcher1);
	
	    }
This is what we have for the teleOp. Any form of response would be greatly appreciated.
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2016, 09:48
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Noob question for teleop

The variable "gyro" is declared and used but never instantiated. This means that "gyro" is null when you call .getAngle on it in Teleop which crashes your code.

2 things to do to fix it:
1. Either remove "gyro" if you don't have a gyro or instantiate using a line like gyro= new AnalogGyro(1) if you do.
2. Set your Driver Station messages window to "+Prints" using the little gear above the messages. You would have seen the stack trace from the code crashing there if you had it set this way which would have told you that it was a Null Pointer exception and the line number.
Reply With Quote
  #3   Spotlight this post!  
Unread 28-01-2016, 09:57
VrewDaive VrewDaive is offline
Registered User
FRC #4284
 
Join Date: Sep 2015
Location: Cincinnati
Posts: 21
VrewDaive is an unknown quantity at this point
Re: Noob question for teleop

we are getting error under AnalogGyro when we use the line to instantiate it. Do we need a gyro in the mecanum cartesian or is it optional? could we just take it out of the
Code:
myDrive.mecanumDrive_Cartesian(moveStick.getRawAxis(1), moveStick.getRawAxis(1), moveStick.getRawAxis(1), gyro.getAngle());
	    		Timer.delay(0.01);
??
Reply With Quote
  #4   Spotlight this post!  
Unread 28-01-2016, 10:45
ghead ghead is offline
Registered User
FRC #3103
 
Join Date: Aug 2013
Location: US
Posts: 13
ghead is an unknown quantity at this point
Re: Noob question for teleop

For mecanum without a gyro I think you want to take a look at

Code:
RobotDrive::MecanumDrive_Polar(float magnitude, float direction, float rotation)
Reply With Quote
  #5   Spotlight this post!  
Unread 28-01-2016, 17:16
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 234
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Noob question for teleop

Quote:
Originally Posted by ghead View Post
For mecanum without a gyro I think you want to take a look at

Code:
RobotDrive::MecanumDrive_Polar(float magnitude, float direction, float rotation)
Not true. You can use mecanum_Cartesian without a gyro if you set the gyro_angle to 0
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #6   Spotlight this post!  
Unread 28-01-2016, 22:57
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 87
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Noob question for teleop

Quote:
Originally Posted by CjDace View Post
Hey, it appears our teleop code, after deploying it to the roboRio, likes to kick out after running through it once.
Code:
public void teleopPeriodic() {
	    	
	 
	    		myDrive.mecanumDrive_Cartesian(moveStick.getRawAxis(1), moveStick.getRawAxis(1), moveStick.getRawAxis(1), gyro.getAngle());
	    		Timer.delay(0.01);
}
A couple of other things...

First, you don't want to use the same raw axis in each position of that method call. The first three parameters to the mecanumDrive_Cartesian() method represent:
1. A strafe value (typically an x-axis on a joystick)
2. A forward-backwards value (typically the y-axis from the same joystick that you used for the strafe value)
3. A rotation value (if you are driving with a single joystick, this would be the z-axis or the "twist" axis)

If you are using an XBox controller (or some other console), then you would typically use the left joystick's x- and y-axis for the strafe and forward-backwards and the right joystick's x-axis for the rotation value (think of playing a first person shooter like Halo). You can figure out which axis numbers you want if you plug the controller into your driver's station laptop and then use the USB/controller tab in the DriverStation. Click on the joystick/controller that you want to use and watch the display as you use it. The parameter that you send to the getRawAxis() method will correspond to the numbers on the DriverStation.

Second, you also don't want to delay the teleop code with a call to Timer.delay(). If you were using the SampleRobot template (and you don't want to), then you would put delays like that in your teleop code. With the IterativeRobot template, the teleopPeriodic() method will get called for you ever 20ms (roughly). You don't need to put delays in this code. If you delay the code too much, you will cause weird behavior. DO NOT PUT DELAYS in teleopPeriodic() or autonomousPeriodic().

Third, I would stick with the cartesian method (unless you want to convert everything to polar...which isn't too complicated, but unnecessary). What problems are you having with the gyro? Code like this "should" work if you have an analog gyro (a gyro that is plugged in as an analog input on the roboRIO):
gyro = new AnalogGyro( 1 );
This assumes that the gyro is plugged in to analog input 1 (which is the second analog port). You CAN NOT have code like this:
gyro = new Gyro( 1 );
Gyro is an interface and can't be constructed. You must use a class that implements the interface like AnalogGyro.
What have you tried for the gyro and what error message(s) did you get?

Edit: corrected port number to be a port with an analog accumulator. Thanks to RufflesRidge for the correction and the information!!
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)

Last edited by mmaunu : 29-01-2016 at 15:40. Reason: Made the port number a good one for gyros. Thanks to RufflesRidge for the correction.
Reply With Quote
  #7   Spotlight this post!  
Unread 29-01-2016, 08:07
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Noob question for teleop

Quote:
Originally Posted by mmaunu View Post
This assumes that the gyro is plugged in to analog input 2 (which is the third port).
The Analog Accumulators required for the gyro are only on ports 0 and 1.
Reply With Quote
  #8   Spotlight this post!  
Unread 29-01-2016, 09:33
CjDace CjDace is offline
Registered User
FRC #4284
 
Join Date: Jan 2016
Location: Cincinnati, Ohio
Posts: 10
CjDace is an unknown quantity at this point
Re: Noob question for teleop

Is the analog input in the roboRio directly next to the Ethernet port? there are ones farther down that are titled analog but our gyro/accelerator only fits in the one next to the Ethernet port. Is this correct? Thanks for the reply, our team is brand new every year so its hard to keep knowledgeable people around for long
Reply With Quote
  #9   Spotlight this post!  
Unread 29-01-2016, 11:23
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 234
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Noob question for teleop

Quote:
Originally Posted by CjDace View Post
Is the analog input in the roboRio directly next to the Ethernet port? there are ones farther down that are titled analog but our gyro/accelerator only fits in the one next to the Ethernet port. Is this correct? Thanks for the reply, our team is brand new every year so its hard to keep knowledgeable people around for long
So the one next to the ethernet is SPI. What gyro are you using?
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #10   Spotlight this post!  
Unread 29-01-2016, 13:57
CjDace CjDace is offline
Registered User
FRC #4284
 
Join Date: Jan 2016
Location: Cincinnati, Ohio
Posts: 10
CjDace is an unknown quantity at this point
Re: Noob question for teleop

This is the gyro we are using as of now.
http://firstchoicebyandymark.com/fc16-000
Reply With Quote
  #11   Spotlight this post!  
Unread 29-01-2016, 15:34
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 87
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Noob question for teleop

Quote:
Originally Posted by CjDace View Post
This is the gyro we are using as of now.
http://firstchoicebyandymark.com/fc16-000
For that gyro, you are connected to the correct port (the onboard SPI port). To construct a gyro object in code, you will want to use the Java class that was built specifically for this gyro:
http://first.wpi.edu/FRC/roborio/rel...S450_Gyro.html

You should be able to use the default (no parameter) constructor.
gyro = new ADXRS450_Gyro();

Now, in your drive code's call to the mecanum_Cartesian() method, you should be able to use gyro.getAngle().

Keep asking if it ain't working.
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
Reply With Quote
  #12   Spotlight this post!  
Unread 29-01-2016, 15:58
CjDace CjDace is offline
Registered User
FRC #4284
 
Join Date: Jan 2016
Location: Cincinnati, Ohio
Posts: 10
CjDace is an unknown quantity at this point
Re: Noob question for teleop

Thank you so much our team and I greatly appreciate your help and will ask for help in the future.
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 10:19.

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