Ejemplo n.º 1
0
  // Flip the robot forward and backwards while changing the LED color
  private void runVibrateMacro() {
    if (mRobot == null) return;

    setRobotToDefaultState();

    MacroObject macro = new MacroObject();

    // Stabilization must be turned off before you can issue motor commands
    macro.addCommand(new Stabilization(false, 0));

    macro.addCommand(new LoopStart(mLoopsSeekBar.getProgress()));
    // Change the LED to red
    macro.addCommand(new RGB(255, 0, 0, 0));
    // Run the robot's motors backwards
    macro.addCommand(
        new RawMotor(RawMotor.DriveMode.REVERSE, 255, RawMotor.DriveMode.REVERSE, 255, 100));
    macro.addCommand(new Delay(100));
    // Change the LED to green
    macro.addCommand(new RGB(0, 255, 0, 0));
    // Run the robot's motors forward
    macro.addCommand(
        new RawMotor(RawMotor.DriveMode.FORWARD, 255, RawMotor.DriveMode.FORWARD, 255, 100));
    macro.addCommand(new Delay(100));
    macro.addCommand(new LoopEnd());

    // Turn stabilization back on
    macro.addCommand(new Stabilization(true, 0));

    // Send the macro to the robot and play
    macro.setMode(MacroObject.MacroObjectMode.Normal);
    macro.setRobot(mRobot.getRobot());
    macro.playMacro();
  }
Ejemplo n.º 2
0
  // Drive the robot in a figure 8 formation
  private void runFigureEightMacro() {
    if (mRobot == null) return;

    setRobotToDefaultState();

    float speed = mSpeedSeekBar.getProgress() * 0.01f;

    MacroObject macro = new MacroObject();

    macro.addCommand(new Roll(speed, 0, 1000));
    macro.addCommand(new LoopStart(mLoopsSeekBar.getProgress()));
    // Pivot
    macro.addCommand(new RotateOverTime(360, mDelaySeekBar.getProgress()));
    macro.addCommand(new Delay(mDelaySeekBar.getProgress()));
    // Pivot
    macro.addCommand(new RotateOverTime(-360, mDelaySeekBar.getProgress()));
    macro.addCommand(new Delay(mDelaySeekBar.getProgress()));
    macro.addCommand(new LoopEnd());
    // Stop
    macro.addCommand(new Roll(0.0f, 0, 255));

    // Send the macro to the robot and play
    macro.setMode(MacroObject.MacroObjectMode.Normal);
    macro.setRobot(mRobot.getRobot());
    macro.playMacro();
  }
Ejemplo n.º 3
0
  // Move the robot in a pattern based on the speed and loop seekbar values
  private void runShapeMacro() {
    // If the looping value is set to null or the robot isn't connected, return
    if (mRobot == null || mLoopsSeekBar.getProgress() == 0) return;

    setRobotToDefaultState();

    MacroObject macro = new MacroObject();
    float speed = mSpeedSeekBar.getProgress() * 0.01f;

    // Set the robot LED color to blue
    macro.addCommand(new RGB(0, 0, 255, 255));

    // Loop through driving in various directions
    for (int i = 0; i < mLoopsSeekBar.getProgress(); i++) {
      macro.addCommand(new Roll(speed, i * (360 / mLoopsSeekBar.getProgress()), 0));
      macro.addCommand(new Delay(mDelaySeekBar.getProgress()));
      macro.addCommand(new Roll(0.0f, i * (260 / mLoopsSeekBar.getProgress()), 255));
    }

    // Stop the robot
    macro.addCommand(new Roll(0.0f, 0, 255));

    // Send the macro to the robot and play
    macro.setMode(MacroObject.MacroObjectMode.Normal);
    macro.setRobot(mRobot.getRobot());
    macro.playMacro();
  }
Ejemplo n.º 4
0
  // Move the robot in the shape of a square with each edge being a new color
  private void runSquareMacro() {
    if (mRobot == null) return;

    setRobotToDefaultState();
    float speed = mSpeedSeekBar.getProgress() * 0.01f;

    MacroObject macro = new MacroObject();

    // Set the robot LED to green
    macro.addCommand(new RGB(0, 255, 0, 255));
    // Move the robot forward
    macro.addCommand(new Roll(speed, 0, 0));
    // Wait until the robot should stop moving
    macro.addCommand(new Delay(mDelaySeekBar.getProgress()));
    // Stop
    macro.addCommand(new Roll(0.0f, 0, 255));

    // Set the robot LED to blue
    macro.addCommand(new RGB(0, 0, 255, 255));
    // Move the robot to the right
    macro.addCommand(new Roll(speed, 90, 0));
    // Wait until the robot should stop moving
    macro.addCommand(new Delay(mDelaySeekBar.getProgress()));
    // Stop
    macro.addCommand(new Roll(0.0f, 90, 255));

    // Set the robot LED to yellow
    macro.addCommand(new RGB(255, 255, 0, 255));
    // Move the robot backwards
    macro.addCommand(new Roll(speed, 180, 0));
    // Wait until the robot should stop moving
    macro.addCommand(new Delay(mDelaySeekBar.getProgress()));
    // Stop
    macro.addCommand(new Roll(0.0f, 180, 255));

    // Set the robot LED to red
    macro.addCommand(new RGB(255, 0, 0, 255));
    // Move the robot to the left
    macro.addCommand(new Roll(255, 270, 0));
    // Wait until the robot should stop moving
    macro.addCommand(new Delay(mDelaySeekBar.getProgress()));
    // Stop
    macro.addCommand(new Roll(0.0f, 270, 255));

    // Send the macro to the robot and play
    macro.setMode(MacroObject.MacroObjectMode.Normal);
    macro.setRobot(mRobot.getRobot());
    macro.playMacro();
  }
Ejemplo n.º 5
0
  // Spin the robot in circles
  private void runSpinMacro() {
    setRobotToDefaultState();
    float speed = mSpeedSeekBar.getProgress() * 0.01f;

    MacroObject macro = new MacroObject();

    // Set the back LED to full brightness
    macro.addCommand(new BackLED(255, 0));

    // Loop through rotating the robot
    macro.addCommand(new LoopStart(mLoopsSeekBar.getProgress()));
    macro.addCommand(new RotateOverTime(360, (int) (500 * speed)));
    macro.addCommand(new Delay((int) (500 * speed)));
    macro.addCommand(new LoopEnd());

    // Dim the back LED
    macro.addCommand(new BackLED(0, 0));

    // Send the macro to the robot and play
    macro.setMode(MacroObject.MacroObjectMode.Normal);
    macro.setRobot(mRobot.getRobot());
    macro.playMacro();
  }