public arduino_communication()
        {
            arduino_admin = new Timer {
                Interval = 1
            };
            arduino_admin.Elapsed += arduino_admin_func;
            arduino_admin.Start();

            arduino_serial = new SerialPort();
            //arduino_serial.DataReceived += new SerialDataReceivedEventHandler(serial_data_received);
            command_valid     = false;
            values_received   = new long[2];
            values_transmit   = new long[2];
            motors            = new motor[2];
            calibrate_counter = 0;
        }
Exemple #2
0
		public Motocicleta(string Color,string Marca,int Ano,int Kilometraje){
			int idmotor, tipomotor, int cilindeada,
			int numruedas, tipoRecubrimiento,
			int minDurometro, int maxDurometro)
			_color =color;
			_marca=marca;
			_ano=ano;
			_kilometraje=kilometraje;
			_motor = new motor(idmotor, tipoMotor, cilindrada);

			_rueda = newrueda[numruedas];
			for (int i-0; i < numreuda; i++);
			_ruedas[i] - new Rueda(tipoRecubrimiento, minDurometro, maxDurometro);

			_estanque = new estanque(capacidad);

		}
Exemple #3
0
    void Start()
    {
        //Multicopter motor configuration
        //Quadcopter
        motors = new motor[4];
        motors[0] = new motor(new Vector3(1, 0, 1), 0f, true); //Front left CW
        motors[1] = new motor(new Vector3(1, 0, -1), 0f, false); //Front righ CCW
        motors[2] = new motor(new Vector3(-1, 0, -1), 0f, true); //Rear right CW
        motors[3] = new motor(new Vector3(-1, 0, 1), 0, false); //Rear left CCW

        tx = new Transmitter();
        sensors = new Sensors(GetComponent<Rigidbody>());
        controller = new CFController(0);

        armed = true;
    }
Exemple #4
0
 public void ControlUpdate(motor[] motors, Transmitter tx, Sensors sensors)
 {
     if (armed)
     {
         if (Modes.BARO_MODE)
         {//35 degrees max inclination
             roll.Control(sensors.GetRotation().x, sensors.GetAngularVelocity().x, -tx.GetRoll() * 35);
             pitch.Control(sensors.GetRotation().z, sensors.GetAngularVelocity().z, -tx.GetPitch() * 35);
             yaw.Control(sensors.GetRotation().y, sensors.GetAngularVelocity().y, tx.GetYaw() * 50);
         }
         //Calculates and applies the force to the motors
         for (int i = 0; i < 4; i++)
         {
             //General force (throttle)
             motors[i].force = tx.GetThrottle() * 2.0F; //:) This should take into account the air density, air temp, altitude, batteries charge, etc.
                                                        //Pitch force
             motors[i].force -= motors[i].position.x * (pitch.p + pitch.i + pitch.d);
             //Roll force
             motors[i].force += motors[i].position.z * (roll.p + roll.i + roll.d);// + (-0.1F + Random.value*0.2F);
         }
         if (tx.GetYaw() < -0.9 && tx.GetThrottle() < 0.1)
         {
             contCyclesBeforeArmUnarm++;
         }
         else
         {
             contCyclesBeforeArmUnarm = 0;
         }
         if (contCyclesBeforeArmUnarm >= 100)
         {
             armed = false;
             Debug.Log("UNARMED");
         }
     }
     else
     {
         for (int i = 0; i < 4; i++)
         {
             motors[i].force = 0f;
         }
         if (tx.GetYaw() > 0.9 && tx.GetThrottle() < 0.1)
         {
             contCyclesBeforeArmUnarm++;
         }
         else
         {
             contCyclesBeforeArmUnarm = 0;
         }
         if (contCyclesBeforeArmUnarm >= 100)
         {
             armed = true;
             Debug.Log("ARMED");
         }
     }
 }
    void initializeComponents()
    {
        rigid = GetComponent<Rigidbody2D>();
        currentSprite = GetComponent<SpriteRenderer>();
        currentStatus = GetComponent<status>();
        anim = GetComponent<Animator>();
        audio = GetComponent<AudioSource>();

        motor = GetComponent<motor>();
        jumpController = GetComponent<jumpController>();
        wallJumpController = GetComponent<wallJumpController>();
        gunController = GetComponent<gunController>();
    }