![]() |
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.
|
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! |
Re: RobotBuilder/Java help
Am I able to set it up on smart dashboard?
|
Re: RobotBuilder/Java help
Would I be able to control the camera with a joystick?
|
Re: RobotBuilder/Java help
Quote:
Quote:
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. |
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. |
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.
|
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.
|
Re: RobotBuilder/Java help
Quote:
|
Re: RobotBuilder/Java help
Quote:
|
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? |
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. |
Re: RobotBuilder/Java help
Quote:
Code:
public void moveCamera(Joystick joy) { |
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.
|
Re: RobotBuilder/Java help
1 Attachment(s)
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.
|
| All times are GMT -5. The time now is 11:22. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi