blob: 5dc2ac1e228e9db0e6a6564344eb29c1c53c56d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/**
* A WalkAnimation that does not result in a smooth transition. The formula and
* constants are chosen at random.
*
* @author Peter Wu
*/
public class DumbWalkAnimation implements WalkAnimation {
private double robot_pos_meters;
private final double legLength;
DumbWalkAnimation(float legTopLength, float legBottomLength) {
this.legLength = legTopLength + legBottomLength;
}
/**
* Sets the new position for the robot.
*/
@Override
public void updatePosition(double pos) {
this.robot_pos_meters = pos;
}
private double getTime() {
return robot_pos_meters / 5;
}
@Override
public double getLegAngleLeft() {
return Math.sin(-getTime()) * 30.0;
}
@Override
public double getLegAngleRight() {
return -getLegAngleLeft();
}
@Override
public double getKneeAngleLeft() {
return 75.0 + Math.abs(Math.cos(getTime()) * 90.0);
}
@Override
public double getKneeAngleRight() {
return getKneeAngleLeft();
}
@Override
public double getArmAngleLeft() {
// static non-moving arms.
return 0;
}
@Override
public double getArmAngleRight() {
// static non-moving arms.
return 0;
}
@Override
public double getBottomOffset() {
return legLength;
}
}
|