Majordhome/pixy
Dependencies: MD25 Servoloop mbed pixy
Fork of pixyHelloWorld by
Diff: main.cpp
- Revision:
- 2:9caf24407d32
- Parent:
- 1:cf1bfec4aae0
diff -r cf1bfec4aae0 -r 9caf24407d32 main.cpp --- a/main.cpp Mon Apr 13 12:17:40 2015 +0000 +++ b/main.cpp Tue Apr 14 11:00:56 2015 +0000 @@ -70,7 +70,7 @@ // and move to follow the pan/tilt tracking // of the head. //--------------------------------------- -int32_t size = 400; +int32_t size = 200; void FollowBlock(int trackedBlock) { @@ -80,12 +80,12 @@ size += pixy.blocks[trackedBlock].width * pixy.blocks[trackedBlock].height; size -= size >> 3; // Forward speed decreases as we approach the object (size is larger) -int forwardSpeed = constrain(400 - (size/256), -100, 400); +int forwardSpeed = constrain(200 - (size/256), -100, 200); // Steering differential is proportional to the error times the forward speed int32_t differential = (followError + (followError * forwardSpeed))>>8; // Adjust the left and right speeds by the steering differential. -int leftSpeed = constrain(forwardSpeed + differential, -400, 400); -int rightSpeed = constrain(forwardSpeed - differential, -400, 400); +int leftSpeed = constrain(forwardSpeed + differential, -200, 200); +int rightSpeed = constrain(forwardSpeed - differential, -200, 200); // And set the motor speeds motors.setSpeedRegisters(leftSpeed,rightSpeed); } @@ -104,9 +104,9 @@ tiltLoop.m_pos = random(RCS_MAX_POS * 0.6, RCS_MAX_POS); scanIncrement = -scanIncrement; if (scanIncrement < 0){ -setSpeed(-250,250);} +setSpeed(0,255);} else{ -setSpeed(0,250);} +setSpeed(5,250);} wait(random(250, 500)); } pixy.setServos(panLoop.m_pos, tiltLoop.m_pos); @@ -117,7 +117,9 @@ int main (void) { -uint16_t blocks; + +uint16_t blocks; + t.start(); pc.format(8,Serial::None,1); pc.baud(9600);