Skip to content

Commit 0003bd8

Browse files
authored
Update tracking-i2c.py
1 parent 3a0c5cf commit 0003bd8

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

home/CheekyMonkey/tracking-i2c.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# http://myrobotlab.org/content/tracking-results
77
#
88

9+
import time
10+
911
xPin = 0;
1012
yPin = 1;
1113

@@ -46,28 +48,42 @@
4648

4749
tracker.connect(arduinoPort, xPin, yPin, cameraIndex);
4850

51+
#small delay here to resolve servo/attach glitch
52+
sleep(5)
4953
#attach x and y servos to AdaFruit servo driver
50-
tracker.x.attach(adaFruit16c3,xPin,85,20);
51-
tracker.y.attach(adaFruit16c3,yPin,70,20);
54+
tracker.x.attach(adaFruit16c3,xPin,70,20);
55+
tracker.y.attach(adaFruit16c3,yPin,60,20);
5256

5357
tracker.x.setVelocity(20);
5458
tracker.x.setMinMax(60,90);
5559
#x.setInverted(True);
56-
tracker.x.setRest(85);
60+
tracker.x.setRest(70);
5761
tracker.x.rest();
5862
tracker.y.setVelocity(20);
5963
tracker.y.setInverted(True);
60-
tracker.y.setMinMax(60,75);
61-
tracker.y.setRest(70);
64+
tracker.y.setMinMax(50,75);
65+
tracker.y.setRest(60);
6266
tracker.y.rest();
6367

6468
#adjust PID values to suit
65-
tracker.pid.setPID("tracker.x", 5.0, 1.0, 0.1);
66-
tracker.pid.setPID("tracker.y", 5.0, 1.0, 0.1);
69+
pid = Runtime.start("tracker.pid","Pid")
70+
71+
72+
#tracker.pid.setPID("tracker.x", 5.0, 1.0, 0.1);
73+
#tracker.pid.setPID("tracker.y", 20.0, 1.0, 0.1);
74+
#pid.setPID("x", 10.0, 1.0, 0.1);
75+
#pid.setPID("y", 50.0, 1.0, 0.1);
6776

68-
opencv = tracker.getOpenCV();
77+
#opencv = tracker.getOpenCV();
6978
#opencv.broadcastState();
7079

80+
opencv = Runtime.start("tracker.opencv","OpenCV")
81+
pid.setPID("x", 10.0, 1.0, 0.1);
82+
pid.setPID("y", 20.0, 1.0, 0.1);
83+
sleep(2);
84+
opencv.capture();
85+
86+
7187
# do lk optical point tracking
7288
# tracker.startLKTracking();
7389

0 commit comments

Comments
 (0)