Hello,
Just bough a Zumo for Arduino kits with a Pixy2 and Pan-Tilt kit. after following the guide on the Pixycam website, I can make everything works just as intend.
However, when running ccc_zumo_chase demo. My Zumo will always run over the object. After inspec the code, I found there is no code on keeping the distance with object when find and track the block().
I’d like to keep the bot always at same distance when find and tracked. here are the code I think it could work… but I am so convinced I did WRONG… where should I put the code to?
int32_t size = 400;
void FollowBlock(int trackedBlock)
{
int32_t followError = RCS_CENTER_POS - panLoop.m_pos;
size += pixy.ccc.blocks[trackedBlock].m_width * pixy.ccc.blocks[trackedBlock].m_height;
size -= size >> 3;
int forwardSpeed = constrain(400 - (size/256), -100, 400);
int32_t differential = (followError + (followError * forwardSpeed))>>8;
int leftSpeed = constrain(forwardSpeed + differential, -400, 400);
int rightSpeed = constrain(forwardSpeed - differential, -400, 400);
motors.setLeftSpeed(leftSpeed);
motors.setRightSpeed(rightSpeed);
}
I’m just starting to learn C++ and taking beginner online courses. Basically I have no idea what I am doing… this is a great project for me to start learning.
Thank you so much for your time looking into this.
Sam