summaryrefslogtreecommitdiff
path: root/src/DumbWalkAnimation.java
blob: 7ff44d12c10b6d27be1a0fd4017317124f8eb122 (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

/**
 * 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;

    /**
     * Sets the new position for the robot.
     */
    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);
    }

    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;
    }
}