Package com.test.simplecarusorobot

Source Code of com.test.simplecarusorobot.SimpleFRCController

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.test.simplecarusorobot;

import ca.teamdave.caruso.CarusoException;
import ca.teamdave.caruso.Controller;
import ca.teamdave.caruso.Machine;
import ca.teamdave.caruso.actuator.BooleanActuator;
import ca.teamdave.caruso.sensor.BooleanSensor;

/**
*
* @author leigh
*/
public class SimpleFRCController implements Controller{

    private BooleanSensor armUpButton;
    private BooleanSensor armDownButton;
    private BooleanActuator armValve;

    public void robotInit(Machine machine) throws CarusoException {
        this.armUpButton = new BooleanSensor(machine.getSensor(SimpleFRCIO.ARM_UP_BUTTON));
        this.armDownButton = new BooleanSensor(machine.getSensor(SimpleFRCIO.ARM_DOWN_BUTTON));

        this.armValve = new BooleanActuator(machine.getActuator(SimpleFRCIO.ARM_VALVE));

    }

    /**
     * A simple controller that makes a arm with two limit buttons move accross
     * it's limits
     * if the arm is touching either button, then move it in the opposite
     * direction
     * @throws CarusoException
     */
    public void periodicUpdate() throws CarusoException {

        if (this.armUpButton.get()) {
            this.armValve.set(false);
        } else if (this.armDownButton.get()) {
            this.armValve.set(true);
        }
    }



}
TOP

Related Classes of com.test.simplecarusorobot.SimpleFRCController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.