![]() |
Java x axis on joystick
Hello my team is a rookie team 5407. We are trying to get the Joysticks X value to use to control the winch much like the drive system but for a winch any help would be great. We are programing in Java.
|
Re: Java x axis on joystick
Quote:
Code:
motor.set(joystick.getX());Remember when posting code to place a [/code] after the code and a [code] before to code to make it easier to read in a forum. |
Re: Java x axis on joystick
Which programming model are you using (Sample, Iterative, etc)?
What model of joystick are you using? What motor controller are you using (Talon SR, Talon SRX, Jaguar...)? Essentially, you need to declare a motor controller and a joystick axis, and do a motor.set(joystick.getX()) several times a second. Here's a recent snapshot of our current "elevator" at github. It's built on the IterativeRobot template. |
Re: Java x axis on joystick
We are using a command based program.
|
Re: Java x axis on joystick
Quote:
|
Re: Java x axis on joystick
Thanks for all you help we figured it out finally.
|
Re: Java x axis on joystick
Quote:
What is the purpose of a PID subsystem? I have never understood why PIDSubsystems are used -- couldn't this have been accomplished using just a regular subsystem? What are the advantages to using a PIDSubsystem and when should it be used? |
Re: Java x axis on joystick
Quote:
PID allows you to set a target speed or position (or any other measurable quantity), and the code automatically seeks to attain and maintain that value. The key requirement of PID (or any other feedback technique) is that you are regularly measuring the output state of the system. This year on our lift, we're using a 10-turn potentiometer as a sensor. The current mechanical setup is the electrified tape measure similar to the one shown in this post. One of our mentors doesn't trust return springs in cheap tape measures, so we may switch to something that engages a 22-tooth idle sprocket with our lift chain. Tuning the PID to minimize settle time, overshoot, oscillation, and droop is at least as much art as science, but we're going to take that plunge again this year. We have also used PID loops in the past (and will again this year) to automatically aim our game piece manipulators. For Rebound Rumble, Ultimate Ascent and Aerial Assist, this meant driving the robot so that we were properly positioned to score when we threw the game piece. For Recycle Rush, our goal is to align on the totes (and RCs) so consistently that they form a neat, stable, stack. For these applications the sensor has been, or at least included, a camera. The desired "output" in this case is the size and location of a vision target as reported by some openCV scripts. |
Re: Java x axis on joystick
Quote:
Would it make sense to setup your Drive Train subsystem itself as a PIDSubsystem using encoders? |
Re: Java x axis on joystick
Quote:
We like to keep our subsystems as simple as possible and do the bulk of our work in the commands. This is one of the reasons we prefer the command route. |
Re: Java x axis on joystick
Quote:
|
Re: Java x axis on joystick
Quote:
One class you can take a look at is our DriveAtSpeed class. |
Re: Java x axis on joystick
Quote:
|
Re: Java x axis on joystick
Quote:
Something like Code:
public class NordicSpeedController extends PIDSubsystem implements SpeedController {This allows us to call driveTrain.mecanumDrive which in turn calls m_robotDrive.mecanumDrive_Cartesian() and we can request that we drive 0.1 (10 % of full speed). To move the robot, the PID can apply 1.0 power for a few ms and as the wheels start turning our rate increases until the robot can move, then the PID keeps increasing/decreasing motor power to maintain 10% speed. Without PID, 0.1 power would likely not even overcome friction. You can then create PIDCommands to act on the drive train as a whole for DriveToDistance or RotateToAngle or DriveAlongAngle and it will call tankDrive or mecanumDrive in the usePIDOutput() function and read the distance off an appropriate encoder or the angle off the gyro to make adjustments to the rotation or forward speed. |
| All times are GMT -5. The time now is 10:53. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi