View Single Post
  #21   Spotlight this post!  
Unread 05-02-2015, 11:48
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Limit Swtich Help

Quote:
Originally Posted by Jon Stratis View Post
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!

Will this work?
Code:
double axis = Xbox.getRawAxis(*));

if(axis  > 0.5) {
     victor1.set(1);
     victor2.set(1);

}
Reply With Quote