![]() |
First Year with Java, Help Requested
This is our first year using Java, our team does not have any programming mentors so I have pretty much been hung out to dry. I've been banging my head against the wall because I can not get this code to work.
Here is our code: (Some things are commented out due to me trying to debug. Code:
/*----------------------------------------------------------------------------*/ |
Re: First Year with Java, Help Requested
If its your first year with Java. Maybe start by using arcadeDrive, and then once you get that running, upgrade to mecanum
also your polar code is wrong first param is magnitude, second direction, third rotation also you could try cartesian having your jags and drive mapped to the same ports may cause problems later |
Re: First Year with Java, Help Requested
I agree with lineskier on all points; it would be simpler to start with arcade drive, then upgrade to mecanum later. On the other hand I can imagine your team wants this to work soon, so here's my interpretation.
First of all, you don't need the while loop. It doesn't hurt, but the system already calls the operatorControl method in a loop - getting rid of it cleans things up. Secondly, I strongly recommend you use Cartesian drive. It's just much simpler, and I find it's more intuitive to drive (it's a lot like an FPS). Even if you don't plan on directly mapping controls in this way, it's way easier to conceptualize - x and y directions and rotation (just put 0 for the gyro until you understand it). The other thing is that for simplicity reasons, you should only use the drive method to control the drive system. None of this manual Jaguar control for the drive system - it could conflict with the drive method. (Don't worry about the arm control, that should be fine.) When I write semi-complex drive code, I like to set variables at the beginning as my drive values. So in this example, I'd set three variables as: xMagnitude, yMagnitude and rotation. Then I'd manipulate these values and after that call the drive method. By setting variables I can start with a controller input, then adjust them as I see fit. It also makes the code way simpler. One final thing that is probably a fundamental misconception is that you need to set values that you want to change (ie. rmagnitude) in the operatorControl method. Otherwise it sets the value to whatever the joystick was at when you start the robot and doesn't change. Values that won't change during the runtime can stay above the method (ie. RobotDrive) (There's a lot of complexities as to why, but that's not important now - let me know if you want more info later.) So, unless I missed something, here is working code for you: Code:
public void operatorControl() {EDIT: I just realized I didn't do anything about your compressor. Just start it in the autonomous or even the initializer (if you know what that is) and leave it. I don't see a reason to turn it off as the power of the robot should just turn it off. |
Re: First Year with Java, Help Requested
We are also in our first year and need help with programming. Our forward/backward and rotation works but strafing does not work.
Code:
|
Re: First Year with Java, Help Requested
Quote:
|
Re: First Year with Java, Help Requested
Quote:
|
Re: First Year with Java, Help Requested
Quote:
Code:
drive.mecanumDrive_Cartesian(driverStick.getX(), driverStick.getY()*-1, rotation, 0); |
Re: First Year with Java, Help Requested
Also when we strafe right the wheels spin like:
^ ^ \ / / \ v v and left: \ / v v ^ ^ / \ |
Re: First Year with Java, Help Requested
Quote:
Ours are always : 1 2 3 4 |
Re: First Year with Java, Help Requested
Quote:
1 2 3 4 but i will check them at the meeting tonight. |
| All times are GMT -5. The time now is 22:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi