Bi Ped robot and panning servo question (blocking function?)
if you've seen of previous posts, have 2 robots have same objectives. 1 on tracks , other bi ped walking robot. i've had them both 3 years , continuously make them both more accurate, advanced , efficient. typically leapfrog past each other in efficiency , tasks untill other catch up.
the bi ped robot in question has 6 servos movement , 1 servo panning. pan servo has camera colors , ir distance sensor avoid objects. robot accurate , supposed to. i'm looking make better. panning servo pans in between steps, not while robot walking. i'm trying make pan servo pan continuously while robot walking , scanning objects. i'm afraid walk() blocking function not allowing pan servo pan while robot walking. below current code appropriate loops.
above can see once servo pans either side robot takes 2 steps scan again.
here loop. of these functions work expected.
next i'll post i've tried , results.
the bi ped robot in question has 6 servos movement , 1 servo panning. pan servo has camera colors , ir distance sensor avoid objects. robot accurate , supposed to. i'm looking make better. panning servo pans in between steps, not while robot walking. i'm trying make pan servo pan continuously while robot walking , scanning objects. i'm afraid walk() blocking function not allowing pan servo pan while robot walking. below current code appropriate loops.
code: [select]
int scanincrement = (rcs_max_pos - rcs_min_pos) / 150;
uint32_t lastmove = 0;
void scanforblocks()
{
if (millis() - lastmove > 8)
{
lastmove = millis();
panloop.m_pos += scanincrement;
if ((panloop.m_pos >= rcs_max_pos) || (panloop.m_pos <= rcs_min_pos))
{
tiltloop.m_pos = random(rcs_max_pos * 0.6, rcs_max_pos);
scanincrement = -scanincrement;
if (scanincrement != 0)
{
walk(15);
walk(15);
}
}
pixy.setservos(panloop.m_pos, tiltloop.m_pos);
}
}
above can see once servo pans either side robot takes 2 steps scan again.
here loop. of these functions work expected.
code: [select]
void loop()
{
read_ir();
scanforblocks();
camera();
if ((ir > middle) && (millis() - lastblocktime < 500))
{
walk(5);
r2d2();
{
while ((ir > middle) && (millis() - lastblocktime < 600000))
{
rest();
read_ir();
}
}
}
else if ((panloop.m_pos < rcs_center_pos) && ir > far && (millis() - lastblocktime > 500))
{
laugh();
turn_right(200);
}
else if ((panloop.m_pos > rcs_center_pos) && ir > far && (millis() - lastblocktime > 500))
{
laugh();
turn_left(200);
}
}
next i'll post i've tried , results.
it seems problem in code didn't post (the walk() function.)
it seems it's poor design scanforblocks() function capable of walking. places walk() called should within same module or function.
it seems it's poor design scanforblocks() function capable of walking. places walk() called should within same module or function.
Arduino Forum > Using Arduino > Programming Questions > Bi Ped robot and panning servo question (blocking function?)
arduino
Comments
Post a Comment