Esempio n. 1
0
        public void BackwardTest()
        {
            var driveHelper = new DriveHelper(this.communicationHelper, this.controlSettings);

            driveHelper.TurboModeOn = false;

            int leftSpeed;
            int rightSpeed;

            driveHelper.CalculateMotorsSpeed(0, -1, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L" + MessageHelper.IntToMessageValue(-this.controlSettings.DriveModeNormalMaxSpeed), this.leftMotorCommand);
            Assert.AreEqual("R" + MessageHelper.IntToMessageValue(-this.controlSettings.DriveModeNormalMaxSpeed), this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(0, -0.5, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            int speed = Convert.ToInt32(255.0 * 0.5);

            speed = DriveHelper.NonlinearSpeedCorrection(speed);
            speed = driveHelper.TurboModeOn ? speed : speed * this.controlSettings.DriveModeNormalMaxSpeed / 255;
            Assert.AreEqual("L" + MessageHelper.IntToMessageValue(-speed), this.leftMotorCommand);
            Assert.AreEqual("R" + MessageHelper.IntToMessageValue(-speed), this.rightMotorCommand);
        }