Add CustomTimer and separate left/right leg handling
Imported from the unarchived 'hexapod' sketch folder. The real date of this version is unknown; file dates were lost in a 2016-11-14 copy.
This commit is contained in:
1 parent
0447cb8c7a
commit
972ba2cb73
3 files changed
+116
-48
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
class CustomTimer
|
||||||
|
{
|
||||||
|
int time;
|
||||||
|
boolean start=true;
|
||||||
|
public boolean delay(int delay)
|
||||||
|
{
|
||||||
|
if (start)
|
||||||
|
{
|
||||||
|
time = millis();
|
||||||
|
start = false;
|
||||||
|
}
|
||||||
|
if (millis() - time >= delay)
|
||||||
|
{
|
||||||
|
start = true;
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -188,40 +188,84 @@ class Foot
|
|||||||
Z = -1 * (Z - TranslateZ);
|
Z = -1 * (Z - TranslateZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
double a = (90 - degrees((float)(O1())));
|
if (leftLegorRight)
|
||||||
double b = (180 - degrees((float)(T1())));
|
{ // right
|
||||||
double c = degrees((float)(T3()));
|
double a = (90 - degrees((float)(O1())));
|
||||||
|
double b = (180 - degrees((float)(T1())));
|
||||||
|
double c = degrees((float)(T3()));
|
||||||
|
|
||||||
if ((a >= 15) & (a <= 165)
|
if ((a >= 15) & (a <= 165)
|
||||||
& (b >= 15) & (b <= 165)
|
& (b >= 15) & (b <= 165)
|
||||||
& (c >= 15) & (c <= 165))
|
& (c >= 15) & (c <= 165))
|
||||||
{
|
{
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
O1 = a;
|
O1 = a;
|
||||||
O2 = b;
|
O2 = b;
|
||||||
O3 = c;
|
O3 = c;
|
||||||
|
|
||||||
double d = sin((float)(b*(PI/180)));
|
double d = sin((float)(b*(PI/180)));
|
||||||
if ( d != 0 )
|
if ( d != 0 )
|
||||||
X2 = d * l1;
|
X2 = d * l1;
|
||||||
else
|
else
|
||||||
X2 = 0;
|
X2 = 0;
|
||||||
|
|
||||||
d = cos((float)(b*(PI/180)));
|
d = cos((float)(b*(PI/180)));
|
||||||
if ( d != 0 )
|
if ( d != 0 )
|
||||||
Y2 = d * l1;
|
Y2 = d * l1;
|
||||||
else
|
else
|
||||||
Y2 = 0;
|
Y2 = 0;
|
||||||
|
|
||||||
d = sin((float)((a-90)*(PI/180)));
|
d = sin((float)((a-90)*(PI/180)));
|
||||||
if ( d != 0 )
|
if ( d != 0 )
|
||||||
Z2 = d * abs((float)(X2));
|
Z2 = d * abs((float)(X2));
|
||||||
else
|
else
|
||||||
Z2 = 0;
|
Z2 = 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
error = true;
|
double a = (90 - degrees((float)(O1())));
|
||||||
|
double b = degrees((float)(T1()));
|
||||||
|
double c = 180 - degrees((float)(T3()));
|
||||||
|
|
||||||
|
if ((a >= 15) & (a <= 165)
|
||||||
|
& (b >= 15) & (b <= 165)
|
||||||
|
& (c >= 15) & (c <= 165))
|
||||||
|
{
|
||||||
|
error = false;
|
||||||
|
|
||||||
|
O1 = a;
|
||||||
|
O2 = b;
|
||||||
|
O3 = c;
|
||||||
|
|
||||||
|
a = (90 - degrees((float)(O1())));
|
||||||
|
b = (180 - degrees((float)(T1())));
|
||||||
|
c = degrees((float)(T3()));
|
||||||
|
|
||||||
|
double d = sin((float)(b*(PI/180)));
|
||||||
|
if ( d != 0 )
|
||||||
|
X2 = d * l1;
|
||||||
|
else
|
||||||
|
X2 = 0;
|
||||||
|
|
||||||
|
d = cos((float)(b*(PI/180)));
|
||||||
|
if ( d != 0 )
|
||||||
|
Y2 = d * l1;
|
||||||
|
else
|
||||||
|
Y2 = 0;
|
||||||
|
|
||||||
|
d = sin((float)((a-90)*(PI/180)));
|
||||||
|
if ( d != 0 )
|
||||||
|
Z2 = d * abs((float)(X2));
|
||||||
|
else
|
||||||
|
Z2 = 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,22 @@ Foot foot6 = new Foot();
|
|||||||
// 10
|
// 10
|
||||||
// 10
|
// 10
|
||||||
|
|
||||||
|
// LAYOUT HARDWARE
|
||||||
|
// _U_
|
||||||
|
// 0==/ \==3
|
||||||
|
// >***<
|
||||||
|
// 1===|---|===4
|
||||||
|
// >***<
|
||||||
|
// 2==\___/==5
|
||||||
|
|
||||||
|
// LAYOUT SOFTWARE?
|
||||||
|
// _U_
|
||||||
|
// 1==/ \==6
|
||||||
|
// >***<
|
||||||
|
// 2===|---|===5
|
||||||
|
// >***<
|
||||||
|
// 3==\___/==4
|
||||||
|
|
||||||
PVector point1 = new PVector(4.75, 0, 10);
|
PVector point1 = new PVector(4.75, 0, 10);
|
||||||
PVector point2 = new PVector(7, 0, 0);
|
PVector point2 = new PVector(7, 0, 0);
|
||||||
PVector point3 = new PVector(4.75, 0, -10);
|
PVector point3 = new PVector(4.75, 0, -10);
|
||||||
@@ -161,26 +177,6 @@ void Vertex(double x, double y, double z)
|
|||||||
vertex((float)x, (float)y, (float)z);
|
vertex((float)x, (float)y, (float)z);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomTimer
|
|
||||||
{
|
|
||||||
int time;
|
|
||||||
boolean start=true;
|
|
||||||
public boolean delay(int delay)
|
|
||||||
{
|
|
||||||
if (start)
|
|
||||||
{
|
|
||||||
time = millis();
|
|
||||||
start = false;
|
|
||||||
}
|
|
||||||
if (millis() - time >= delay)
|
|
||||||
{
|
|
||||||
start = true;
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawFeet()
|
void DrawFeet()
|
||||||
{
|
{
|
||||||
foot1.Translate(point1);
|
foot1.Translate(point1);
|
||||||
@@ -215,13 +211,22 @@ void RobotWalk()
|
|||||||
|
|
||||||
animationRepeat = true;
|
animationRepeat = true;
|
||||||
animationSpeed = 20;
|
animationSpeed = 20;
|
||||||
|
/*
|
||||||
foot1.SetFootCoordinates(Animation(walk1, 6, 2)); // BULLSHIT BUG
|
foot1.SetFootCoordinates(Animation(walk1, 6, 2)); // BULLSHIT BUG
|
||||||
foot1.SetFootCoordinates(Animation(walk1, 6, 2));
|
foot1.SetFootCoordinates(Animation(walk1, 6, 2));
|
||||||
foot2.SetFootCoordinates(Animation(walk1, 6, 3));
|
foot2.SetFootCoordinates(Animation(walk1, 6, 3));
|
||||||
foot3.SetFootCoordinates(Animation(walk1, 6, 4));//
|
foot3.SetFootCoordinates(Animation(walk1, 6, 4));//
|
||||||
foot4.SetFootCoordinates(Animation(walk1, 6, 1));//
|
foot4.SetFootCoordinates(Animation(walk1, 6, 1));//
|
||||||
foot5.SetFootCoordinates(Animation(walk1, 6, 0));
|
foot5.SetFootCoordinates(Animation(walk1, 6, 0));
|
||||||
foot6.SetFootCoordinates(Animation(walk1, 6, 5));
|
foot6.SetFootCoordinates(Animation(walk1, 6, 5));*/
|
||||||
|
foot1.SetFootCoordinates(Animation(walk1, 6, 1)); // BULLSHIT BUG
|
||||||
|
foot1.SetFootCoordinates(Animation(walk1, 6, 1));
|
||||||
|
foot2.SetFootCoordinates(Animation(walk1, 6, 3));
|
||||||
|
foot3.SetFootCoordinates(Animation(walk1, 6, 5));//
|
||||||
|
|
||||||
|
foot4.SetFootCoordinates(Animation(walk1, 6, 0));//
|
||||||
|
foot5.SetFootCoordinates(Animation(walk1, 6, 2));
|
||||||
|
foot6.SetFootCoordinates(Animation(walk1, 6, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user