Go to Post mama always said better safe than sorry - Brandon Holley [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 28-01-2017, 09:39
Wintermanx24890's Avatar
Wintermanx24890 Wintermanx24890 is offline
Registered User
AKA: Jack Larson
FRC #5464
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Cambridge, MN
Posts: 5
Wintermanx24890 is an unknown quantity at this point
Exclamation Help with Programming a trigger!

Hi I'm a programmer on team 5464 and we need to know how to program a motor to a trigger on a joystick. We are fairly new to Java, so you may need to explain the steps. We do not know where to begin. We have a code to move a robot.







Thank you for your time
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2017, 09:51
wlogeais wlogeais is offline
Registered User
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2016
Rookie Year: 2011
Location: Minnesota
Posts: 18
wlogeais is an unknown quantity at this point
Re: Help with Programming a trigger!

Quote:
Originally Posted by Wintermanx24890 View Post
Hi I'm a programmer on team 5464 and we need to know how to program a motor to a trigger on a joystick. We are fairly new to Java, so you may need to explain the steps. We do not know where to begin. We have a code to move a robot.
Have you looked at any instructions or sample-code. One good place to start is within File --> New --> Other... --> Example Java Projects -->CommandBased Robot --> GearsBot.
Reply With Quote
  #3   Spotlight this post!  
Unread 28-01-2017, 10:54
YairZiv's Avatar
YairZiv YairZiv is offline
Registered User
FRC #5951 (Makers Assemble)
Team Role: Programmer
 
Join Date: Oct 2016
Rookie Year: 2016
Location: Tel Aviv, Israel
Posts: 41
YairZiv is an unknown quantity at this point
Re: Help with Programming a trigger!

Quote:
Originally Posted by Wintermanx24890 View Post
Hi I'm a programmer on team 5464 and we need to know how to program a motor to a trigger on a joystick. We are fairly new to Java, so you may need to explain the steps. We do not know where to begin. We have a code to move a robot.







Thank you for your time
Are you using iterative robot or command based?
Reply With Quote
  #4   Spotlight this post!  
Unread 28-01-2017, 11:06
Wintermanx24890's Avatar
Wintermanx24890 Wintermanx24890 is offline
Registered User
AKA: Jack Larson
FRC #5464
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Cambridge, MN
Posts: 5
Wintermanx24890 is an unknown quantity at this point
Re: Help with Programming a trigger!

I think it is command based in Eclipse. I could be wrong.
Reply With Quote
  #5   Spotlight this post!  
Unread 29-01-2017, 11:16
GKannel GKannel is offline
Registered User
FRC #4207 (PyroBotics)
Team Role: Mentor
 
Join Date: Jan 2017
Rookie Year: 2012
Location: Minnesota
Posts: 1
GKannel is an unknown quantity at this point
Re: Help with Programming a trigger!

Be aware that "trigger" may not always be a trigger in code. On a regular joystick you are probably going to use something like the following with shooter being some sort of motor controller such as CANTalon shooter = new CANTalon(10);

Code:
    if(stick.getTrigger()) {
          shooter.set(1.0);     // turn it on when pressed
    } else {                     
          shooter.set(0.0);   // turn it off when released
    }
We would have this inside the while loop of the operatorControl function (SampleRobot based project) but that will presumably vary with types of robot projects.

!!!However, if you are using something like a Playstation type controller (such as Logitech F310 with switch on back in X position), the two triggers may actually show as a pair of axis (each with values on a 0-1.0 scale) instead of as a trigger. On ours the left trigger is axis 2 and the right is axis 3 but you can use the USB section of the driver station to determine yours. This then looks more like the following.
Code:
if(stick.getRawAxis(3) > .5) {    
    motor.set(1.0);
} else {
   motor.set(0.0);
}
You could also have variable power from 0 to 1 if you just did
Code:
   motor.set(stick.getRawAxis(3));
It should be 0 when not pressed and range up to 1.0 when fully pressed.
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 13:16.

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