
Prenil
Hi everyone,
I've been playing around with the color tracking on my JD and while I can get the tracking to work, I'm having trouble getting the servos to move in response to seeing a color. Here is the code I have been using to try and Identify the color blue and then point in the general direction of the blue object:
:loop
$CameraObjectColor = ("Blue" ) ControlCommand("Camera", CameraStart)
SayWait("let me see" )
ControlCommand("Camera", CameraMultiColorTrackingEnable)
IF ($CameraObjectColor != "Blue" ) SayWait(" No I do not see the color" ) ENDIF
IF ($CameraObjectColor = "Blue" ) SayWait("I see a dot colored" + $CameraObjectColor) SayWait("It is in" +$CameraVerticalQuadrant +"and" + $CameraHorizontalQuadrant) ENDIF IF($CameraHorizontalQuadrant < 0) Servo(D4, 110) IF($CameraVerticalQuadrant < 0) Servo(D3, 75) ENDIF IF($CameraVerticalQuadrant > 0) Servo(D3, 110) ENDIF ENDIF IF($CameraHorizontalQuadrant < 0) Servo(D7, 110) IF($CameraVerticalQuadrant < 0) Servo(D2, 75) ENDIF IF($CameraVerticalQuadrant > 0) Servo(D2, 110) ENDIF ENDIF goto (loop)
I have not been able to get the servos to move at all. Can anyone suggest what I might be doing wrong? Thank you
I put the repeatuntil in you code so the script will keep executing... meaning it will keep looking for blue, otherwise it will look just once and then quit... Repeatuntil(1=2) just means that this condition will never be met so the repeatuntil loop will keep looping ... that's all that means
@Prenil01 Did you have the goto loop in your code when you first posted it? If you did, I missed that, sorry... Then you don't need the repeatuntil command....
Why not enable servo tracking instead of writing code?
@RichardR It was in my code but I appreciate you adding that anyway. It taught me something I didn't know before so thank you for that !
@Rich to your previous comment: No offense taken at all- I welcome any constructive criticism. If it isn't too much of a bother for you, I'd really appreciate you showing me how to improve my coding.
@DJ_Sures I enjoy being able to code it in a script. However I've had more free time to work on this recently and I will definitely try the interface soon as well. Just one question about that to make sure I understand properly. Would it be correct to say that enabling servo tracking allows any servo to be moved by a predetermined amount when tracking an object and tracking by relative position moves the robot to keep the object in the middle of the camera assuming that the camera can't move?