summaryrefslogtreecommitdiff
path: root/src/DumbWalkAnimation.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/DumbWalkAnimation.java')
-rw-r--r--src/DumbWalkAnimation.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/DumbWalkAnimation.java b/src/DumbWalkAnimation.java
new file mode 100644
index 0000000..7ff44d1
--- /dev/null
+++ b/src/DumbWalkAnimation.java
@@ -0,0 +1,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;
+ }
+}