コード例 #1
0
ファイル: Scorpio.cs プロジェクト: nagyist/nSt.ScorpioCsharp
        /// <summary>
        /// This is where all sensors and motors are stopped
        /// </summary>
        public void DisconnectAll()
        {
            // Stop sensing
            if (LightIntensitySensor.IsSensing())
            {
                LightIntensitySensor.StopSensing();
            }
            if (SoundLevelSensor.IsSensing())
            {
                SoundLevelSensor.StopSensing();
            }
            if (SoundRatioSensor.IsSensing())
            {
                SoundRatioSensor.StopSensing();
            }
            if (UltrasonicSensor.IsSensing())
            {
                UltrasonicSensor.StopSensing();
            }
            if (TouchSensor.IsSensing())
            {
                TouchSensor.StopSensing();
            }
            //TODO clear sensors?

            // Stop behaviors
            if (WalkBehavior.IsWalking)
            {
                WalkBehavior.Stop();
            }

            // Stop motors
            if (MotorTail.IsRunning)
            {
                MotorTail.Stop();
            }
            if (MotorRight.IsRunning)
            {
                MotorRight.Stop();
            }
            if (MotorLeft.IsRunning)
            {
                MotorLeft.Stop();
            }

            System.Threading.Thread.Sleep(1000);

            Brick.Disconnect();
            IsConnectionStarted = false;
        }
コード例 #2
0
        public void Forward(float leftSpeed, float rightSpeed)
        {
            if (leftSpeed >= 0)
            {
                MotorLeft.Forward(leftSpeed);
            }
            else
            {
                MotorLeft.Reverse(Math.Abs(leftSpeed));
            }

            if (rightSpeed >= 0)
            {
                MotorRight.Forward(rightSpeed);
            }
            else
            {
                MotorRight.Reverse(Math.Abs(rightSpeed));
            }
        }
コード例 #3
0
 public void Forward(float speed)
 {
     MotorLeft.Forward(speed);
     MotorRight.Forward(speed);
 }
コード例 #4
0
 public void Stop()
 {
     MotorLeft.Stop();
     MotorRight.Stop();
 }
コード例 #5
0
 public void SpinRight(float speed)
 {
     MotorLeft.Forward(speed);
     MotorRight.Reverse(speed);
 }
コード例 #6
0
 public void Reverse(float speed)
 {
     MotorLeft.Reverse(speed);
     MotorRight.Reverse(speed);
 }