New Zealand
Asked — Edited
Resolved Resolved by Rich!

Look Around

Hi this might sound like a dumb question...

I have a Pan/Tilt bracket with the Wireless Camera mounted to it. I want to have the ability to drive the robot to a location and park up and look around. I can achieve this effect using the horizontal and vertical servo control but would like to control this function either using the keyboard or a joystick.

When I've tried with the joystick control the servos always try to re-center.

Can someone please help me out with this ?


ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

United Kingdom
#1  

That it how it has been designed, the servos follow the joystick so if the joystick is returned to the home position the camera will return to the home position.

You could set the servos to N/A on joystick 2 and use the $JoystickX2 and $JoystickY2 variables to trigger moving the servos... You could have the joystick position based on the value of $JoystickX2 and $JoystickY2 or you could use the ServoUp and ServoDown command to move the servo up or down if the joystick is moved.

Canada
#2  

Another thing you could do is get a joystick with out a spring back to center or try to remove the spring that centers the stick from an old one you are ok with breaking

United Kingdom
#3  

I've not checked this as I don't have a robot with a pan/tilt and joystick to test on at the moment so if it has problems please post and I'll relook at it. But something like this should sort it out.

Set the Joystick 2 servos to NA and tick the box to save the variable in the joystick config.

Add and run this script (adjust to suit).


# Set the tolerance of the joystick
$positivetolerance = 0.2
# calculate negative tolerance
$negativetolerance = 0-$positivetolerance

# Set the servo ports
# pan servo to D0
# tilt servo to D1

# Set movement steps
$moveamount = 2

:loop
# Move the servos with the joystick
# Pan servo
IF($JoystickX2 > $positivetolerance)
  ServoUp(D0, $moveamount)
EndIf
IF($JoystckX2 < $negativetolerance)
  ServoDown(D0, $moveamount)
EndIf
# Tilt servo
IF($JoystickY2 > $positivetolerance)
  ServoUp(D1, $moveamount)
EndIf
IF($JoystckY2 < $negativetolerance)
  ServoDown(D1, $moveamount)
EndIf

# Sleep to avoid saturation of coms
Sleep(100)

# Loop
Goto(loop)

New Zealand
#4  

Hi Rich Sorry its taken me so long to get back to you on this. Your solution worked perfectly:) Thanks for your help:)