Commit ecaa693d authored by Ashley Chen's avatar Ashley Chen
Browse files

adding VogueWings pattern. far from flawless

parent cb6b0118
......@@ -643,6 +643,9 @@ public abstract class FlightEngine implements FlightTrack {
patterns.add(new RaspberryTrip(lx));
patterns.add(new Twinkle(lx));
patterns.add(new LightHouseColor(lx));
patterns.add(new SlowFlap(lx));
patterns.add(new SplitWings(lx));
patterns.add(new VogueWings(lx));
}
/* Create an array with a new instance of each available Pattern. */
......
package engine;
import java.util.List;
import java.util.List;
import java.util.PrimitiveIterator.OfInt;
import java.util.ArrayList;
import model.FlyerModel;
......@@ -138,7 +139,7 @@ class WheelOfcolor extends FlightPattern{
* Flyer wing only function, where the flyers traverse in an ordering, flpping its wings in succession
* @author Kyung-Tae Kim <kim1@stanford.edu>
*/
class climbFlap extends FlightPattern{
class ClimbFlap extends FlightPattern{
int NUM_FLYERS = Geometry.NUM_FLYERS;
int FLYER_MOD = NUM_FLYERS - 1;
final BoundedParameter rate = new BoundedParameter("RATE", 5000, 5000, 100000);
......@@ -147,7 +148,7 @@ class climbFlap extends FlightPattern{
final BoundedParameter speed = new BoundedParameter("SPEED", 5000, 12500, 25000);
final SinLFO colorFlap = new SinLFO(0, 360, speed);
climbFlap(LX lx){
ClimbFlap(LX lx){
super(lx);
addParameter("climbFlap_RATE", rate);
//Starting modulator that takes in those speeds
......@@ -172,14 +173,14 @@ class climbFlap extends FlightPattern{
* Flaps the wings in a slow fashion where the right and left wing are skewed
* @author Kyung-Tae Kim <kim1@stanford.edu>
*/
class slowFlap extends FlightPattern{
class SlowFlap extends FlightPattern{
int NUM_FLYERS = Geometry.NUM_FLYERS;
int FLYER_MOD = NUM_FLYERS - 1;
//Speed by which the wings are rotating "GUESS"
final BoundedParameter speed = new BoundedParameter("SPEED", 5000, 12500, 25000);
final SinLFO colorFlap = new SinLFO(0, 360, speed);
slowFlap(LX lx){
SlowFlap(LX lx){
super(lx);
addParameter("slowFlap_SPEED", speed);
addModulator(colorFlap).start();
......@@ -1231,7 +1232,7 @@ class ColorWall extends FlightPattern {
class Twinkle extends FlightPattern {
private SinLFO[] bright;
final BoundedParameter brightnessParam = new BoundedParameter("Brightness", 0.8, 0.5, 1);
final BoundedParameter brightnessParam = new BoundedParameter("Brightness", 0.9, 0.5, 1);
final int numBrights = 30;
final int density = 20;
int[] sparkleTimeOuts;
......@@ -1380,9 +1381,6 @@ class TestSweep extends FlightPattern {
TestSweep(LX lx) {
super(lx);
addParameter("test_x", x = new BoundedParameter("X", 0, model.xMin, model.xMax));
// the following y param should light the two shortest rods of a shrub when the beam is set to 1
// may be useful for adjusting the rotation of the shrubs in the JSON config
// addParameter(y = new BasicParameter("Y", 20.8, lx.model.yMin, lx.model.yMax));
addParameter("test_y", y = new BoundedParameter("Y", 0, model.yMin, model.yMax));
addParameter("test_z", z = new BoundedParameter("Z", 0, model.zMin, model.zMax));
addParameter("test_beam", beam = new BoundedParameter("beam", 5, 1, 15));
......@@ -1404,4 +1402,84 @@ class TestSweep extends FlightPattern {
}
}
}
}
/**
* Pattern to make the wings appear as if they're dancing.
* Move into a position then hold the pose.
* Pretty glitchy, but it might work okay with how commands are issued to the actual
* wing motors themselves.
*
* @author Ashley Chen <ashleyic@cs.stanford.edu>
*/
class VogueWings extends FlightPattern{
final BoundedParameter speed = new BoundedParameter("SPEED", 5000, 5000, 25000);
Random rand = new Random();
OfInt randomSkew;
long millisOffset = System.currentTimeMillis();
private SinLFO[] leftPoseTransitions = new SinLFO[20];
private SinLFO[] rightPoseTransitions = new SinLFO[20];
int firstLeftPose;
int firstRightPose;
int leftCursor = 0;
int rightCursor = 1;
boolean isPosed = false;
VogueWings(LX lx){
super(lx);
addParameter("VogueWings_SPEED", speed);
randomSkew = rand.ints(-90, 90).iterator();
int leftSkew = 0;
int rightSkew = 0;
firstLeftPose = leftSkew;
firstRightPose = rightSkew;
for (int i = 0; i < leftPoseTransitions.length; i++ ) {
if (i != leftPoseTransitions.length - 1) {
int temp = randomSkew.nextInt();
leftPoseTransitions[i] = new SinLFO(leftSkew, temp, speed);
leftSkew = temp;
temp = randomSkew.nextInt();
rightPoseTransitions[i] = new SinLFO(rightSkew, temp, speed);
rightSkew = temp;
} else {
leftPoseTransitions[i] = new SinLFO(leftSkew, firstLeftPose, speed);
rightPoseTransitions[i] = new SinLFO(rightSkew, firstRightPose, speed);
}
addModulator(leftPoseTransitions[i]).start();
addModulator(rightPoseTransitions[i]).start();
}
}
@Override
public void run(double deltaMs){
if ((int)speed.getValuef()/2 < (int)(System.currentTimeMillis() - millisOffset)) {
millisOffset = System.currentTimeMillis();
if (isPosed) {
if (leftCursor != leftPoseTransitions.length - 1) {
leftCursor++;
} else {
leftCursor = 0;
}
if (rightCursor != rightPoseTransitions.length - 1) {
rightCursor++;
} else {
rightCursor = 0;
}
isPosed = false;
} else {
isPosed = true;
}
}
if (!isPosed) {
for (int i = 0; i < Geometry.NUM_FLYERS; i++) {
setSkew(model.getFlyerLeftWing(i),(int)leftPoseTransitions[leftCursor].getValuef());
setSkew(model.getFlyerRightWing(i),(int)rightPoseTransitions[rightCursor].getValuef());
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment