bool Chirp::overlaps(Led led) { float maxMoveDistance = lastSeen * Config::getRobotSpeed(); float maxRotation = lastSeen * Config::getRobotRotation(); float distance = util::distance(position, led.getPoint()); switch(led.getType()) { case Led::RED: return distance + maxMoveDistance < Config::getRobotDiameter(); case Led::BLUE: return distance + maxMoveDistance < Config::getRobotDiameter() / 2 + Config::getCameraLedSize(); case Led::GREEN: return distance + maxMoveDistance < (1/2.0 + 1.0/4.0) * Config::getRobotDiameter(); } }
bool Chirp::closeTo(Led led) { float maxMoveDistance = lastSeen * Config::getRobotSpeed(); float maxRotation = lastSeen * Config::getRobotRotation(); float distance = util::distance(position, led.getPoint()); switch(led.getType()) { case Led::RED: return distance < maxMoveDistance; case Led::BLUE: return distance < maxMoveDistance + Config::getRobotDiameter() / 2; case Led::GREEN: // TODO: function currently assumes the robot is rotated towards the green light, use maxRotation to gain increased precision return distance < maxMoveDistance + Config::getRobotDiameter() / 4; } }