Go to Post there is no such thing as too many offseason competitions. - Berserker [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 05-06-2012, 00:39
Corran54 Corran54 is offline
Registered User
FRC #3310
 
Join Date: Mar 2011
Location: Rockwall Texas
Posts: 4
Corran54 is an unknown quantity at this point
Question Trouble with servo

Hi there,

I have been searching everywhere to find a way to program a servo using Java. While I have found many great sources, none have been helpful. I am using NetBeans as the IDE and the program is iterative. what I am trying to do is creat a command that will cause the servo to rotate from one of it's maximums to the other in order to release a spring loaded "stinger". I am new to Iterative programming and am wondering also if I need to create a subsystem before I can create the command.
I do however have the button mapping worked out, and I also know where and how to hook the servo up to the sidecar. It is only code that I need in order to make the servo move. I don't have a clue where to begin as this is my first time working with servo's in software, and any help at all would be greatly appreciated.

Thanks to all,
Andrew Brown
Team 3310
Reply With Quote
  #2   Spotlight this post!  
Unread 05-06-2012, 05:06
Jeremy Germita's Avatar
Jeremy Germita Jeremy Germita is offline
Co-Advisor/Lead Engineering Mentor
AKA: wood is good. plastic is fantastic.
FRC #5012 (Gryffingear) / (Antelope Valley FIRST Teams)
Team Role: Coach
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Lancaster, CA
Posts: 283
Jeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond repute
Re: Trouble with servo

Operating a servo from within the iterative template is as simple as just creating and object for the servo(and whatever controls it) and setting it's values.

Here's a sample for what you might be looking to do:
Code:
Servo stinger = new Servo(/*Servo port here*/);
Joystick controller = new Controller(/*controller port here*/);

public void teleopInit() {
  stinger.set(0);    //Sets to zero so the servo always starts teleop in the locked position
}

public void teleopPeriodic() {
  //teleop code here
  if(controller.getRawButton(/*controller button*/)) {
    stinger.set(1);  //Open position
  } else {
    stinger.set(0);  //Closed position
  }
}
__________________
Drive Coach Team 5012 Gryffingear / Antelope Valley FIRST teams / EWCP - (2013 - Current)
Student / Driver / Programmer / CAD - FRC Team 399: Eagle Robotics / FTC Team 72: GarageBots - (2009 - 2013)
Los Angeles Region FTC FTA/CSA/Head Ref
[FF] FIRST Pick
2014 FTC Los Angeles Regional Compass Award Winner.

2017 - San Diego Regional / Sacramento Regional / Las Vegas Regional
2016 - Los Angeles Regional Creativity + Winners (1197, 987, 5012) / Las Vegas Regional Team Spirit + SF (5012, 5851, 5049) / Galileo Subdivision
2015 - Inland Empire QF (597, 5012, 4413) / Las Vegas Imagery + Winners (148, 987, 5012) / Newton Subdivision and World Champions (118, 1678, 1671, 5012)
2014 - Inland Empire Rookie All Star + Highest Rookie Seed + SF (2339, 1967, 5012) / Las Vegas Rookie All Star / Galileo Division Imagery
Reply With Quote
  #3   Spotlight this post!  
Unread 05-06-2012, 10:08
Corran54 Corran54 is offline
Registered User
FRC #3310
 
Join Date: Mar 2011
Location: Rockwall Texas
Posts: 4
Corran54 is an unknown quantity at this point
Re: Trouble with servo

Thank you,
This has helped, however I do not understand where you are getting the
set(int) method, and apparently neither does the code.
The error is that It cannot find the symbol.
Also I am getting this error if you have any clues as to why, that would be helpful
method whenPressed in class edu.wpi.first.wpilibj.buttons.Button cannot be applied to given types;
required: edu.wpi.first.wpilibj.command.Command
found: edu.rhhs.frc.commands.ServoOpen
reason: actual argument edu.rhhs.frc.commands.ServoOpen cannot be converted to edu.wpi.first.wpilibj.command.Command by method invocation conversion
----

Thanks
Reply With Quote
  #4   Spotlight this post!  
Unread 05-06-2012, 19:20
Jeremy Germita's Avatar
Jeremy Germita Jeremy Germita is offline
Co-Advisor/Lead Engineering Mentor
AKA: wood is good. plastic is fantastic.
FRC #5012 (Gryffingear) / (Antelope Valley FIRST Teams)
Team Role: Coach
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Lancaster, CA
Posts: 283
Jeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond repute
Re: Trouble with servo

the Servo.set method takes a double input, so you could try to make it 1.0 and 0.0. Or you could use the setAngle with the inputs 0.0 and 180.0.

Are you sure you're using the iterative structure? It seems like you are trying to use the CommandBased structure
__________________
Drive Coach Team 5012 Gryffingear / Antelope Valley FIRST teams / EWCP - (2013 - Current)
Student / Driver / Programmer / CAD - FRC Team 399: Eagle Robotics / FTC Team 72: GarageBots - (2009 - 2013)
Los Angeles Region FTC FTA/CSA/Head Ref
[FF] FIRST Pick
2014 FTC Los Angeles Regional Compass Award Winner.

2017 - San Diego Regional / Sacramento Regional / Las Vegas Regional
2016 - Los Angeles Regional Creativity + Winners (1197, 987, 5012) / Las Vegas Regional Team Spirit + SF (5012, 5851, 5049) / Galileo Subdivision
2015 - Inland Empire QF (597, 5012, 4413) / Las Vegas Imagery + Winners (148, 987, 5012) / Newton Subdivision and World Champions (118, 1678, 1671, 5012)
2014 - Inland Empire Rookie All Star + Highest Rookie Seed + SF (2339, 1967, 5012) / Las Vegas Rookie All Star / Galileo Division Imagery
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 10:12.

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