Пример #1
0
        public static void Main()
        {
            // Motors
            Motor motorA = new Motor(Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D12, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5);
            Motor motorB = new Motor(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D13);

            motorA.Reversed = true;
            motorB.Reversed = false;

            // Rangers
            InfraredDistanceSensor irFront = new InfraredDistanceSensor(Pins.GPIO_PIN_A4);
            InfraredDistanceSensor irBack  = new InfraredDistanceSensor(Pins.GPIO_PIN_A5);

            // Robot and its controller
            StasisRobot      bot        = new StasisRobot(motorA, motorB, irFront, irBack);
            StasisController controller = new StasisController(bot);

            Timer thinkTimer = new Timer(new TimerCallback(delegate
            {
                controller.Think();
            }), null, 0, 15);

            // Keep alive
            Thread.Sleep(Timeout.Infinite);
        }
Пример #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="leftMotor"></param>
 /// <param name="rightMotor"></param>
 /// <param name="encoders"></param>
 /// <param name="frontRanger"></param>
 /// <param name="rearRanger"></param>
 public StasisRobot(Motor leftMotor, Motor rightMotor, InfraredDistanceSensor frontRanger, InfraredDistanceSensor rearRanger)
 {
     this.LeftMotor = leftMotor;
     this.RightMotor = rightMotor;
     this.FrontIRSensor = frontRanger;
     this.RearIRSensor = rearRanger;
     this.RearIRSensor.Offset = 2.2;
 }
Пример #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="leftMotor"></param>
 /// <param name="rightMotor"></param>
 /// <param name="encoders"></param>
 /// <param name="frontRanger"></param>
 /// <param name="rearRanger"></param>
 public StasisRobot(Motor leftMotor, Motor rightMotor, InfraredDistanceSensor frontRanger, InfraredDistanceSensor rearRanger)
 {
     this.LeftMotor           = leftMotor;
     this.RightMotor          = rightMotor;
     this.FrontIRSensor       = frontRanger;
     this.RearIRSensor        = rearRanger;
     this.RearIRSensor.Offset = 2.2;
 }
Пример #4
0
        public static void Main()
        {
            // Motors
            Motor motorA = new Motor(Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D12, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5);
            Motor motorB = new Motor(Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D13);
            motorA.Reversed = true;
            motorB.Reversed = false;

            // Rangers
            InfraredDistanceSensor irFront = new InfraredDistanceSensor(Pins.GPIO_PIN_A4);
            InfraredDistanceSensor irBack = new InfraredDistanceSensor(Pins.GPIO_PIN_A5);

            // Robot and its controller
            StasisRobot bot = new StasisRobot(motorA, motorB, irFront, irBack);
            StasisController controller = new StasisController(bot);

            Timer thinkTimer = new Timer(new TimerCallback(delegate
            {
                controller.Think();
            }), null, 0, 15);

            // Keep alive
            Thread.Sleep(Timeout.Infinite);
        }