![]() |
Re: Joystick 2/Program issue
The axis numbers are different than the button numbers. The axis numbers refer to the analog inputs (things that can be moved or twisted to different positions) on the input device where as the button numbers refer to the digital buttons (things that can only be pressed on/off).
So, if you are using a gamepad as your controller. It will typically have two "sticks" on it that you can move up/down and left/right to many different positions. This corresponds to 4 axis values (left stick right/left axis, left stick up/down axis, right stick right/left axis and right stick up/down axis). If you are using a non-gamepad joystick. You will have one axis for the left/right direction, another for the up/down direction and possibly others for twisting motions or throttle dials. When you write your software, part of the challenge will be determining which axis you want to read in order to set your shooter speed. For example, axis 2 might be the up/down axis on a gamepad's left stick. However, if 2 is not the correct number, you may need to experiment and try other values (1, 2, 3, 4, or 5). For autonomous, you would need to set specific motor powers (you would not want to read them from the joystick/gamepad). It may also turn out that you don't need to vary the speed with a joystick while under operator control (in which case you would not need to use the joystick either). I'm still not entirely clear on what your use cases are. From your last message, it sounded like you were more interested in being able to turn the shooter motors (Victors) on and off for the entire autonomous and operator control periods. Here is an example of setting your shooter motors to a specific power level and leaving them set to that level during all of autonomous and all of teleop (and also turning them off at the end). This example assumes you don't need/want to vary the speed of the shooter motors using a joystick/gamepad: Code:
public void autonomous() { |
Re: Joystick 2/Program issue
For our use, in auto we would like to drive, stop driving, fire, and then stop completely.
For teleop, we would like to drive and have the ability to launch our launcher forward and reset it. I'm getting closer to understanding what's going on, but I am still uncertain with a few things. How would we declare the launcher in the constructor? How do we control it in the autonomous period? I know with the drive we can select the power and put on a delay. But with the shooter, how would we control when it fires, if the shooter is running the entire time? Lastly, in the telop period, if the power is set at .5 at all times, would our launcher only be able to go forward or backwards? How could we reset our launcher each time? Sorry for the plethora of questions, I just want to make sure that we have no issues. Thank you again! |
Re: Joystick 2/Program issue
oh. hope it's not flaky joystick cable or usb port...
Quote:
|
Re: Joystick 2/Program issue
Can you describe your shooting mechanism?
How are the two motors controlled by the Victors used (are they just spinning wheels that the ball drops into and shoots out of, or are they used to crank down a catapult, etc)? Are there any other sensors or mechanisms required to shoot the ball (you mentioned a laucher of some type but did not describe how the launcher is controlled)? |
Re: Joystick 2/Program issue
Our launcher uses the two Victor controllers to control two CIM motors. The motors are used to operate our belt system, which can lift the launcher and also return the launcher to rest position if put in reverse. Sorry for any confusion. If you need me to clear anything else up, let me know.
|
Re: Joystick 2/Program issue
That helps to know that the two Victors are used to operate a belt and that running them in one direction will lift the launcher and that running them in the other direction will cause them to lower the launcher.
However, I don't understand how you know when to stop? If you keep running the Victors to lift the launcher, how will you know when you are at the launch point? If the Victors run too long, will it damage your robot? From what I know so far, it sounds like your only option is to run your Victors at certain power levels for a specific time period and hope for the best. Here's an example which has a autonomous routine that drives for a bit, then raises your launcher for a period of time and then stops (I don't know what you need to do to actually fire). The operator control has been adjusted slightly so that it uses two buttons on the joystick so the operator should be able to raise or lower the launcher depending which button they hold down (when they release both buttons it should stop). There are several comments flagged with TODO indicating that there are values that will need to be determined/adjusted. Code:
package edu.wpi.first.wpilibj.templates;Let me mention again that it is typically desirable to add limit switches so you can tell when the launcher has reached a certain point and should not be raised or lowered any more. The is especially important if moving the lift too far could damage the robot. |
Re: Joystick 2/Program issue
Thank you so much! I truly appreciate all of your help. You have been a godsend. As for the stopping mechanism, I'm not sure how that's going to work. I think our build team is coming up with ideas on it, so hopefully we'll have something figured out. I, too, am worried about potential damages. We will be sure to keep that in mind. Once again, thank you! I can not express my gratitude. You have been a mentor to a team lacking any mentors. Thank you!
|
Re: Joystick 2/Program issue
No worries - I'm glad my input was useful.
I'm really impressed that a new team without any mentors could produce a robot. I am a mentor who joined an established team and I was pretty lost for the first season. Your team should be proud to have gotten through a build season on its own. Good luck and have fun at your regionals. |
Re: Joystick 2/Program issue
Just a heads up, in the autonomous example, I had an error in the code that was suppose to drive for three seconds. The original code would start driving, wait for 3 seconds, but fail to stop driving afterwards. This would have resulted in your robot to continue driving for the next 1.5 seconds as it raised its launcher (until stopAll() was reached).
I've corrected the example in the previous post. Here is the fragment of code that was corrected with the addition of myDrive.stopMotor() (it will stop driving before raising the launcher): Code:
// Example of driving at half power for 3 seconds (not sure if this |
| All times are GMT -5. The time now is 12:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi