View Single Post
  #22   Spotlight this post!  
Unread 05-02-2015, 09:19
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,738
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Limit Swtich Help

Quote:
Originally Posted by curtis0gj View Post
So could I do something like
Code:
axis = Xbox.getRawAxis(someaxis); // Do I need float or double?

if(axis == 1) {
     victor1.set(1);
     victor2.set(1);
}
Sorry if thats way off Im still a bit confused.
Your getting there! It can be hard to learn this stuff remotely without someone experienced there to help.

Your code is actually really close. Joystick axis values are returned as doubles, but that's a good question! There is often a lot of confusion between float and double, as they appear to be basically the same. In situations like thiszits useful to look at the javadoc For the object your using. A quick search turned up a copy here: http://team2168.org/javadoc/ go there and click on "Joystick" in the class listing on the left. You can then scroll through all of the methods in the joystick class, find the one you're using, get a short description of it, and see its return type. Pretty handy!

With the code you posted, the elevator will go up only if you have the joystick pushed full forward so the return value is 1. Pushing it halfway, so you get 0.5, wouldn't move it. Additionally, if you aren't pushing perfectly straight, you won't get a return value of 1! Take a piece of graph paper, draw a set of axis, and then draw a circle with a radius of 1, centered on the origin. Everything inside that circle is a value that can be returned by the joystick. If you push the joystick forward, you could get 0 for the x axis and 1 for the y axis... Or you could get something just a little less than 1 for the y axis and a little greater or less than 0 for the x axis, if you aren't perfectly straight.

So the only problem with your code is that it demands perfection from the driver to work. It would be much better to do something like "axis > 0.5" (pick an appropriate number) so you have a range on the joystick where pushing it forward makes it move. That way your driver doesn't have to be perfect!
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote