Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Controlling the camera with a joystick (http://www.chiefdelphi.com/forums/showthread.php?t=80868)

Dakabt 22-01-2010 16:42

Controlling the camera with a joystick
 
Hello I was wondering how (if possible) I would be able to allow a joystick to be used to control the camera on the robot.

lscime 22-01-2010 17:18

Re: Controlling the camera with a joystick
 
Assuming you mean that you want to move the servos on the camera mount using a joystick, yes it is indeed possible.

We've been playing around with such control for about a week. Here is a one method in LabVIEW. Essentially you can tell the servo "goal" position to increment by 1 (or another value) every time the main loop loops if a certain condition is met (i.e. a joystick in a particular position). The servos will constantly goal seek on this new position. We accomplished this by storing the "goal" position in a shift register and incrementing/decrementing/not changing this value depending on a case statement triggered by a joystick.

Again this in LabVIEW but the same principle should apply in Java and C.

Hope this helps,
Student Programmer, Team #2614.

non847 23-01-2010 04:34

Re: Controlling the camera with a joystick
 
how about setting the angle of the servos proportionate to the axes of the joystick? works great!

EricWilliams 24-01-2010 14:24

Re: Controlling the camera with a joystick
 
Quote:

Originally Posted by non847 (Post 905069)
how about setting the angle of the servos proportionate to the axes of the joystick? works great!

This requires you to hold the joystick in a non-centered position if you want the camera to be anywhere but centered.

psychomonkey 31-01-2010 20:13

Re: Controlling the camera with a joystick
 
Quote:

Originally Posted by lscime (Post 904822)
Essentially you can tell the servo "goal" position to increment by 1 (or another value) every time the main loop loops if a certain condition is met (i.e. a joystick in a particular position). The servos will constantly goal seek on this new position. We accomplished this by storing the "goal" position in a shift register and incrementing/decrementing/not changing this value depending on a case statement triggered by a joystick.

So, if I understand correctly, In order to run this code, it must be in a while loop INSIDE the initial teleop case structure? I tried doing this and every time, I would get a watchdog error. I know that I didn't have a shift register. Do I need one on each side of the loop?:confused:

apalrd 31-01-2010 20:38

Re: Controlling the camera with a joystick
 
No while loops inside while loops.
Use a shift register and put the code in the main loop.

Alan Anderson 31-01-2010 21:06

Re: Controlling the camera with a joystick
 
Quote:

Originally Posted by lscime (Post 904822)
We accomplished this by storing the "goal" position in a shift register and incrementing/decrementing/not changing this value depending on a case statement triggered by a joystick.

You can also do without the shift register. Since the FPGA knows what value you've set the servo to, you can use a Get Angle or Get Position vi to retrieve it, apply whatever modifications you wish to the value, and give it to a Set Angle or Set Position vi.

(If you're changing the value by extremely small amounts, you might need to watch out for rounding errors in the conversion between servo position and PWM value.)

psychomonkey 31-01-2010 23:20

Re: Controlling the camera with a joystick
 
Quote:

Originally Posted by apalrd (Post 910872)
No while loops inside while loops.
Use a shift register and put the code in the main loop.

I'm not doing that. In the code this year, the teleop is all inside a case structure. Can I place a while loop inside a case structure?

psychomonkey 31-01-2010 23:26

Re: Controlling the camera with a joystick
 
Quote:

Originally Posted by psychomonkey (Post 910947)
I'm not doing that. In the code this year, the teleop is all inside a case structure. Can I place a while loop inside a case structure?

You know what, I just realized that you were referring to the robot main.vi, not the teleop.vi. My apologies. So instead of using the while loop, I should just use comparison vi's on the joysticks to lead to increment vi's inside case structures?

psychomonkey 01-02-2010 21:51

Re: Controlling the camera with a joystick
 
Got it, thanks.


All times are GMT -5. The time now is 02:06.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi