Go to Post The code is hopefully pretty self-documenting, but I haven't had time to comment it (kinda trying to build a robot at the moment). - RyanCahoon [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-09-2013, 17:12
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Coasting Problems

The following assume you are using the RobotDrive VIs in LabVIEW and the robotDrive object in Java.

LabVIEW, by default, squares the inputs joystick inputs. This makes a small input value even smaller and might account for what you are seeing. The Java library also squares the joystick inputs by default, but makes it easier to change to not squaring. Which are you using?

In the Java library, robot drive objects declare jaguars unless speed controller objects are passed to it. If you are using a different type of speed controller (eg Victor or Talon), you may see weird behavior like neutral offsets. In LabVIEW, it's more obvious how to change to the appropriate speed controller type.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-09-2013, 10:39
Matt_4505 Matt_4505 is offline
Registered User
FRC #4505
Team Role: Programmer
 
Join Date: Nov 2012
Rookie Year: 2012
Location: United States
Posts: 16
Matt_4505 is on a distinguished road
Re: Coasting Problems

I'm using the Java Library. My inputs are from the .getY() values of the joysticks. The motors are being controlled through: tankDrive(leftJoystickValue, rightJoystickValue). I have the values from the Joystick.getY() being fed to the dashboard to view them. They always seem to read between .1<->.3 when the joystick is released. Should I be using the route of the .getY() value to drive the robot?
Reply With Quote
  #3   Spotlight this post!  
Unread 17-09-2013, 12:10
BigJ BigJ is online now
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 947
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: Coasting Problems

Can you elaborate more by what you mean by this:

Quote:
for which I've set up some wiggle room with a pair of if statements.
To me that sounds like you're trying to set a deadzone, but I'm not sure.
Reply With Quote
  #4   Spotlight this post!  
Unread 17-09-2013, 12:43
Matt_4505 Matt_4505 is offline
Registered User
FRC #4505
Team Role: Programmer
 
Join Date: Nov 2012
Rookie Year: 2012
Location: United States
Posts: 16
Matt_4505 is on a distinguished road
Re: Coasting Problems

Quote:
Originally Posted by BigJ View Post
Can you elaborate more by what you mean by this:



To me that sounds like you're trying to set a deadzone, but I'm not sure.
Yep, that code is to set a deadzone, although since I have to keep increasing it's size, I'm losing a lot of mobility.

It might be an issue with zeroing the motor controllers, although, it works fine with Labview.

Heres the code:

public class DriveControl {
double leftJoystickValue = 0;
double rightJoystickValue = 0;

/**
* Controls the Joystick Read-in.
* Reads the joystick values and directs values to the motors.
*/
public void driveRobot() {

if(Math.abs(Hardware.leftJoystick.getY()) > .25){
leftJoystickValue = Hardware.leftJoystick.getY();
}
if(Math.abs(Hardware.rightJoystick.getY()) > .25){
rightJoystickValue = Hardware.rightJoystick.getY();
}

SmartDashboard.putNumber("leftJoystickValue", leftJoystickValue);
SmartDashboard.putNumber("righttJoystickValue", rightJoystickValue);

//decrease values by 3/4 for each trigger pressed
if (Hardware.leftJoystick.getRawButton(1)) {
leftJoystickValue = leftJoystickValue * (.75);
rightJoystickValue = leftJoystickValue * (.75);
}
SmartDashboard.putBoolean("leftJoystickTrigger Pressed", Hardware.leftJoystick.getRawButton(1));
//reduces values even more
if (Hardware.rightJoystick.getRawButton(1)) {
leftJoystickValue = leftJoystickValue * (.75);
rightJoystickValue = leftJoystickValue * (.75);
}
SmartDashboard.putBoolean("rigbhtJoystickTrigger Pressed", Hardware.rightJoystick.getRawButton(1)); //sends signal to bot with the adjusted drive values

Hardware.chassis.tankDrive(leftJoystickValue, rightJoystickValue);
}
Reply With Quote
  #5   Spotlight this post!  
Unread 17-09-2013, 12:54
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Coasting Problems

Quote:
Originally Posted by Matt_4505 View Post

Code:
public class DriveControl {
    double leftJoystickValue = 0;
    double rightJoystickValue = 0;
    
    /**
     * Controls the Joystick Read-in.
     * Reads the joystick values and directs values to the motors.
     */
    public void driveRobot() {

        if(Math.abs(Hardware.leftJoystick.getY()) > .25){
            leftJoystickValue = Hardware.leftJoystick.getY();
        }
        if(Math.abs(Hardware.rightJoystick.getY()) > .25){
            rightJoystickValue = Hardware.rightJoystick.getY();
        }
This code will make the speed controllers run at about 0.25 when the joystick ramps down.

Imagine the following scenario
Code:
joystick output
1        1
0.75     0.75
0.5      0.5
0.3      0.3
0.26     0.26
0.25     0.25
0.1      0.25
0.0      0.25
You need to explicitly set the value back to 0 when it is <= 0.25. The initialize to 0 at the top only occurs once.

Last edited by Joe Ross : 17-09-2013 at 16:14.
Reply With Quote
  #6   Spotlight this post!  
Unread 17-09-2013, 17:33
Matt_4505 Matt_4505 is offline
Registered User
FRC #4505
Team Role: Programmer
 
Join Date: Nov 2012
Rookie Year: 2012
Location: United States
Posts: 16
Matt_4505 is on a distinguished road
Re: Coasting Problems

Thank you for your help! I added to the code so the values are zeroed. I'm amazed that I missed that earlier.
Reply With Quote
  #7   Spotlight this post!  
Unread 17-09-2013, 21:04
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Coasting Problems

Just for future reference, my favourite deadzone code looks something like this:
Code:
float deadZ (float val) {
	return val > 0.6 || val < -0.6? val: 0;
}
Then you would simply say something like 'tankDrive(deadZ(leftStick), deadZ(rightStick));'
To me this is the most aesthetically pleasing. But to each his own :P One thing I noticed that would also make it look better (my apologies, I'm really picky about these things) would be to assign 'Hardware.leftJoystick.getRawButton(1)' to a boolean somewhere in the beginning of your code so that you don't have to type that mess every time you need to check it. You could also make a similar method to the one above that takes your boolean as an input as well as a joystick value and clean up the code even more (there's currently a lot of code involved in just getting it to drive). Just my $0.02 :P Take it with a grain of salt
Reply With Quote
  #8   Spotlight this post!  
Unread 17-09-2013, 23:12
Matt_4505 Matt_4505 is offline
Registered User
FRC #4505
Team Role: Programmer
 
Join Date: Nov 2012
Rookie Year: 2012
Location: United States
Posts: 16
Matt_4505 is on a distinguished road
Re: Coasting Problems

Thanks, I will definitely give those a try.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:33.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi