![]() |
Joystick 2/Program issue
Hello! My team is having quite a bit of problems with our 2nd joystick. We are using joystick 1 for driving and joystick 2 for our launcher. Our 2nd joystick doesn't seem to work at all. The driver station recognizes it, but we are unable to do anything with it. I hope it's just a simple code mistake. Could anyone help us out? Any help is greatly appreciated! Here is the code:
Code:
/*----------------------------------------------------------------------------*/ /* Copyright (c) FIRST 2008. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*-------------------------------------------------------------------*/ package edu.wpi.first.wpilibj.templates; |
Re: Joystick 2/Program issue
Have you tried using robotbuilder? I know our newer programmers had a lot of success using it. It helps you to avoid programming in a way that wpi doesn't support.
I was first skeptical of generating code that way, but I have since come around, and am now a big fan. I would also recommend trying to only use one drive, and only have one timer delay. You only need one timer delay per iteration. |
Re: Joystick 2/Program issue
What is the purpose of M1 and M2 (connected to victor 5 and victor 6) ?
Are they two motors connected to the same gearbox ? If that's the case, then arcade drive would run one of the motors forward and the other backwards - unless if you have one of the motor outputs from one of the victors wired in reverse, the motors will be running against each other in the gear box... You can also check the output led on victors 5 and 6 also - changes in the led color and flash rate can help debug the motor drive system... http://wpilib.screenstepslive.com/s/...tem-components |
Re: Joystick 2/Program issue
We have not tried robotbuilder, but I appreciate the suggestion and will explore it. Thanks!
M1 and M2 are motors connected to the Victor motor controls 5 and 6. The problem is that when we use Joystick 2 to move the motors, nothing happens. We have it wired properly because the lights are are solid orange on the Victor controllers. Could it be an issue with the USB port number? Or anything with the code? |
Re: Joystick 2/Program issue
More importantly:
1. Are the 2 motors mounted into the same gearbox, or do they sit outside and mounted independent from each other ? 2. When you move joystick 2, do the victors' leds turn off or go to solid green or solid red or do anything besides solid orange ? Quote:
|
Re: Joystick 2/Program issue
1.) The motors are mounted independent of each other.
2.) The Victors stayed orange the whole time. We switched the ports on the Victor controllers to 1 and 4 to see if it would work on Joystick 1 and it worked fine. |
Re: Joystick 2/Program issue
Does Joystick 2 work if you use Joystick Explorer?
I agree with SousVide, you probably do not want to use Arcade Drive for a shooter. This isn't causing your problem, but will once you start getting joystick 2 data. You should set both Victors individually. |
Re: Joystick 2/Program issue
try this,
with the DriverStation in Teleop and Enabled... drive a bit with Joystick one. Now unplug Joystick one from the laptop, does the DriverStation's Joystick light remain lit ? Also, have you checked the joystick assignments in the DriverStation itself ? |
Re: Joystick 2/Program issue
Looks like joystick 2 is working again! Played around with the code and the dashboard, and it looks like things are working. Thanks for the help everyone!
As for not using arcade drive for the shooter, what would you recommend? |
Re: Joystick 2/Program issue
Quote:
Better yet, you could use some object orientation magic to create a class that defines the behavior you want to see in your launcher. You can see team 53's implementation of this here. For the future, it will help you tremendously to gain a solid working knowledge of Java and other programming languages. You'll have a much better understanding of your own code and the wpilib libraries if you learn object oriented programming. |
Re: Joystick 2/Program issue
I'm taking AP CS online, so I do now a little bit of OOP, but nothing nearly as advanced as what you posted.
For the victor.set(double speed) method, what is the purpose? Is it to set a consistent speed when the joystick is pushed forward? Thanks for the help! I really appreciate it. Our team has no mentors, so the entire build session has been very stressful. |
Re: Joystick 2/Program issue
I like to think of the set(power) methods on the SpeedController classes (like Victor, Talon and Jaguar) as the way to control how much power the speed controller lets through.
The power value can range from -1.0 (full reverse) to +1.0 (full foward). For example: Code:
victor.set(1.0); // Run motor "forwards" at full power
Hope that helps. |
Re: Joystick 2/Program issue
I kinda understand what you're saying. So the set method allows for a constant speed to be received to the motors? How would the program drive with the set method? Would I still use arcade drive? or would I use something else?
Thanks for help! |
Re: Joystick 2/Program issue
For your shooter, I would not use the RobotDrive class but recommend that your read values from your joysticks and then apply the current values to your shooter motors. Here's an example of a slight refactoring of some of your code:
Code:
public void operatorControl() {
|
Re: Joystick 2/Program issue
I really appreciate your time and effort, thank you very much. I still have a few more questions.
What do the axis numbers represent? Are they button numbers? I thought that there are only 2 axes on the joystick. We do want the motors running at the same power, so we would only need one axis. Also for the code you posted, how would we shoot in autonomous? Lastly, where would we set the Victor power? And if we set them once, would they be set for the same in both autonomous and teleoperated? Thank you once again! |
| All times are GMT -5. The time now is 13:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi