Switch between Huskylens Algorithms

userHead Birgit.Straker 2023-04-16 20:14:03 881 Views3 Replies

Hi DFRobot Team,

for our actual Arduino robot car project, we use Huskylens as the car's camera. We need to detects Lines AND colored blocks (Obstacles) in our code and have not yet found out if this is possible.

We used the writeAlgorithm function to set the appropriate mode. However, this works only once in a program, we cannot switch to another mode while the program is running.

Is there a mode that can return both learned blocks and learned arrows? 

Or a way to switch between line tracking and colored block detection?

We tried this (pseudocode):

void loop()

{

    huskylens.writeAlgorithm(ALGORITHM_LINE_TRACKING);

    if (huskylens.requestArrowsLearned())

   {

        …. // Do something

    }

 

    huskylens.writeAlgorithm(ALGORITHM_COLOR_RECOGNITION);

    if (huskylens.requestBlocksLearned())

   {

        …. // Do something

    }

 

   … // Do something

}

 

If we start with Algorithm_line_tracking, we get learned line data, but the switch to color recognition does not work and we get no obstacle blocks data. If we switch the order and start with Algorithm_color_recognition,  we get correct obstacle block data, but no more line data. How to solve this?

Best regards, Birgit

2023-04-22 17:06:05

Thanks, the delay did the trick. However, we must use a much smaller delay, as we switch them during our car is actually driving. But 50ms seems to be sufficient.

userHeadPic Birgit.Straker
2023-04-18 11:55:12

Adding a few delay functions will solve this problem.

userHeadPic jenna
2023-04-18 11:54:23
userHeadPic jenna