View Single Post
  #13   Spotlight this post!  
Unread 04-10-2013, 18:18
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: RobotBuilder/Java help

Quote:
Originally Posted by TenaciousDrones View Post
I think this should work
...
What do you guys think?
The code you have should behave like Jon Stratis' description above. After reading your question, it seems to me like you were looking for code that would let you move the camera with the joystick and have it stay put until you reset it. Here's an example that would give you more 'Arcade Drive' like movement of the camera:

Code:
public void moveCamera(Joystick joy) {
    final double kSensitivity = 0.1;  // Controls servo response time

    //
    // Add a portion of the joystick position to the current servo position to
    // give the servo an "Arcade Drive"-like response. Y axis value is negated 
    // since the joystick considers forward movement along the Y axis negative.
    //
    double newPan = pan.get() + (joy.getX() * kSensitivity);
    double newTilt = tilt.get() + (-(joy.getY()) * kSensitivity);

    //
    // Make sure the new positions are in the proper range of 0.0 to 1.0.
    // The Servo#set method should check this as well, so this section may
    // not be necessary.
    //
    if (newPan > 1.0) newPan = 1.0;
    else if (newPan < 0.0) newPan = 0.0;
    if (newTilt > 1.0) newTilt = 1.0;
    else if (newTilt < 0.0) newTilt = 0.0;

    //
    // Update the servo positions
    //
    pan.set(newPan);
    tilt.set(newTilt);
}

public void resetCameraPosition() {
    pan.set(0.5);
    tilt.set(0.5);
}
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote