top of page

Software

Public·126 members

Making Bittle respond to a color

I was trying out some sample code in camera.h to make Bittle repond to colors. My routine looks like this:

int colorBehavior(int color) {

if (color == MU_COLOR_RED) {

PTLF("Step");

tQueue->addTask('k', "pee");

tQueue->addTask('k', "sit");

tQueue->addTask('i', "");

return 1;

} else if (color == MU_COLOR_BLUE) {

PTLF("");

tQueue->addTask('k', "pu");

tQueue->addTask('k', "sit");

tQueue->addTask('i', "");

return 1;

}

return 0;

}


I am invoking this routine when Bittle first detects either red or blue color with the following code in


void muCameraSetup() MuVisionType object[] = { VISION_BODY_DETECT, VISION_BALL_DETECT, VISION_COLOR_RECOGNITION};

String objectName[] = { "body", "ball", "color" };

int count = 0;

...

else if (objectIdx == 2) { // Implementing logic if color is detected

int color = (*Mu).GetValue(object[objectIdx], kLabel);

if (color != lastColorType) { lastColorType = color;

if (count < 1) {

count += colorBehavior(color);

}

To me, the code seems technically correct. However, Bittle starts making rapid servo motions once the code is uploaded. The servos dont stop until I remove the battery. Is there something fundamentally wrong with my code?


I also dont get what tQueue is (other than it being some queue where you can push commands that will be executed asynchronously).


Thanks for the help.







43 Views

If you send a 'i' command with joint angle to control the head, the head will be unbinded from the gait. A single 'i' will bind it with the gait again.

About

Learn programming by teaching Nybble new tricks!

bottom of page