Go to Post My first instinct was inflatable clowns and 5 of them beating on the robots at all times, but then I thought, thats probably not right. - Dan Richardson [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 24-09-2013, 09:25
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
RobotBuilder/Java help

This year my team is planning on upgrading our camera by adding a pan and tilt mount that I'm going to mock up and build. At the same time I'm also writing a code for it, well at least trying to. I'm using RobotBuilder and I'm trying to set up a PIDsubsystem to allow us to center the camera. Is that possible? I want to use 2 potenimeters and 2 servos that i can set a point for that is centered on what we should line up with.
Reply With Quote
  #2   Spotlight this post!  
Unread 24-09-2013, 09:42
Jon Stratis's Avatar
Jon Stratis Jon Stratis is online now
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,784
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: RobotBuilder/Java help

With a servo, you can tell it a precise angle to turn to - you don't need the potentiometer.

So, lets say you have the horizontal servo set to 0.50. You look at the camera feed, and notice that the center of the target is a few pixels to the right of center. So, change the servo value to 0.51 and look at the new image. Now how many pixels off are you? Gather some data on this so you can make an equation or a small look-up table that tells you how far to turn based on how far off you are. The picture dimensions define a fixed area to work in, which makes this sort of thing a little easier. Once you have that, go to your ideal shooting location, get lined up, and look at what values you're setting your servo's to - that's what you want to try to hit for a good shot.

Personally, however, my team has found a simpler solution to be a bit easier to work with in the past. We mount the camera at a fixed angle, and then overlay a target on the image (this can be done as easily as taping some clear overhead paper to the computer monitor and drawing on it with sharpie). This way the drivers can look at the image and judge how well lined up they are!
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote
  #3   Spotlight this post!  
Unread 24-09-2013, 10:37
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: RobotBuilder/Java help

Am I able to set it up on smart dashboard?
Reply With Quote
  #4   Spotlight this post!  
Unread 24-09-2013, 11:20
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: RobotBuilder/Java help

Would I be able to control the camera with a joystick?
Reply With Quote
  #5   Spotlight this post!  
Unread 24-09-2013, 11:36
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 431
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: RobotBuilder/Java help

Quote:
Originally Posted by TenaciousDrones View Post
Would I be able to control the camera with a joystick?
If you write your code to support that, then yes. Instead of your joystick axis or button feeding the drivetrain motors, they would feed the servo motors. Same premise.

Quote:
Originally Posted by TenaciousDrones
Am I able to set it up on smart dashboard?
Not sure what you're asking. You can forward the video feed to the smart dashboard.

If you're adding the camera on to the robot to allow it to aim at a target. It may be easier to keep your camera fixed, and rotate the drivetrain. Just my two cents.
__________________
http://team2168.org
Reply With Quote
  #6   Spotlight this post!  
Unread 24-09-2013, 13:49
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: RobotBuilder/Java help

I just can't figure out what command to use for that though. Like what the equivelent of arcaeDrive would be.

Basically I want to be able to move then press the trigger to recenter it. It's not necesacially for shooting or anything. Its this idea that I had last year during the competion that might help us.
Reply With Quote
  #7   Spotlight this post!  
Unread 24-09-2013, 15:18
Jon Stratis's Avatar
Jon Stratis Jon Stratis is online now
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,784
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: RobotBuilder/Java help

There's no direct command to control the drive train with the camera... you would need to write code that interprets the camera feed and decides how much to turn the wheels. That could then feed into a normal drive routine, or a custom one if you find that easier.
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote
  #8   Spotlight this post!  
Unread 24-09-2013, 15:59
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: RobotBuilder/Java help

No I mean a code type that is like the arcadeDrive code but it controls the camera. So one joystick for the drive train and the other for the camera.
Reply With Quote
  #9   Spotlight this post!  
Unread 24-09-2013, 16:23
Jon Stratis's Avatar
Jon Stratis Jon Stratis is online now
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,784
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: RobotBuilder/Java help

Quote:
Originally Posted by TenaciousDrones View Post
No I mean a code type that is like the arcadeDrive code but it controls the camera. So one joystick for the drive train and the other for the camera.
I'm not aware of anything like that. If I remember right, servo's are controlled with a range of 0 to 1.0, while a joystick returns a range of -1.0 to 1.0. You could do something like passing the value from the joystick through a conversion function(something like (x+1)/2) into the servo - then releasing the joystick would center the servo, and moving it to either side would give you direct control - the amount you move the joystick would match the amount the camera moved.
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote
  #10   Spotlight this post!  
Unread 24-09-2013, 17:04
Pault's Avatar
Pault Pault is offline
Registered User
FRC #0246 (Overclocked)
Team Role: College Student
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Boston
Posts: 618
Pault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond repute
Re: RobotBuilder/Java help

Quote:
Originally Posted by TenaciousDrones View Post
No I mean a code type that is like the arcadeDrive code but it controls the camera. So one joystick for the drive train and the other for the camera.
There is nothing in robotbuilder that can do that. If you want this feature, you are going to need to figure out how to code it manually. Remember that if you want to be a good coder you are going to need to realize where robotbuilder limits you and you need to break free from it. And btw just because you shouldn't use robotbuilder for this feature you don't have to give up robotbuilder entirely. It is designed so that you can use it for some parts of your code and not for others.
Reply With Quote
  #11   Spotlight this post!  
Unread 27-09-2013, 09:37
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: RobotBuilder/Java help

I think this should work

public void takeJoystickInputs(Joystick left) {
double servoIn = (left.getX() +1)*0.5;
double servoIn2 = (left.getY() +1)*0.5;
pan.set(servoIn);
tilt.set(servoIn2);
}
public void stop() {
pan.set(0.5);
tilt.set(0.5);
}

What do you guys think?
Reply With Quote
  #12   Spotlight this post!  
Unread 27-09-2013, 12:05
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 1,931
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: RobotBuilder/Java help

A couple of things.

The PWM to the servo sets a position. Different than an PWM to a motor that sets a speed. (continuous rotation servos excepted.)

The issue with setting a camera position with a spring return joy stick is holding any position other than neutral. We had better luck using the top hat buttons.
Reply With Quote
  #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
  #14   Spotlight this post!  
Unread 07-10-2013, 13:32
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: RobotBuilder/Java help

Thanks this was exactly what I was looking for. I also added a center command that runs on a trigger push and it works perfectly.
Reply With Quote
  #15   Spotlight this post!  
Unread 23-10-2013, 09:40
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: RobotBuilder/Java help

here's my camera mount prototype so far. I just replaced the screws with zip ties because they're more adjustable and stay in place better.
Attached Thumbnails
Click image for larger version

Name:	download.jpg
Views:	17
Size:	10.0 KB
ID:	15348  
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:14.

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