예제 #1
0
        public void TurboDriveTest()
        {
            var driveHelper = new DriveHelper(this.communicationHelper, this.controlSettings);
            driveHelper.TurboModeOn = true;

            int leftSpeed;
            int rightSpeed;

            driveHelper.CalculateMotorsSpeed(0, 1, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L00FF", this.leftMotorCommand);
            Assert.AreEqual("R00FF", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(0, 0.5, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L00DD", this.leftMotorCommand);
            Assert.AreEqual("R00DD", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(0, -1, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("LFF01", this.leftMotorCommand);
            Assert.AreEqual("RFF01", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(0, -0.5, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("LFF23", this.leftMotorCommand);
            Assert.AreEqual("RFF23", this.rightMotorCommand);
        }
예제 #2
0
파일: GameRobot.cs 프로젝트: QsDev/csharp
        /// <summary>
        /// Initializes a new instance of the GameRobot class.
        /// </summary>
        public GameRobot()
        {
            this.IsFixedTimeStep = false;
            this.graphics        = new GraphicsDeviceManager(this);
            this.graphics.SynchronizeWithVerticalRetrace = false;

            // this.graphics.IsFullScreen = true;
            // this.IsMouseVisible = false;
            Content.RootDirectory = "Content";

            this.controlSettingsHelper = new ControlSettingsHelper();
            this.controlSettingsHelper.Load();

            this.communicationHelper = new UdpCommunicationHelper(
                this.controlSettingsHelper.Settings.RoboHeadAddress,
                this.controlSettingsHelper.Settings.UdpSendPort,
                this.controlSettingsHelper.Settings.UdpReceivePort,
                this.controlSettingsHelper.Settings.SingleMessageRepetitionsCount);

            this.flashlightHelper = new FlashlightHelper(this.communicationHelper);
            this.driveHelper      = new DriveHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.lookHelper       = new LookHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.moodHelper       = new MoodHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.gunHelper        = new GunHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.videoHelper      = new VideoHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.audioHelper      = new AudioHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
        }
예제 #3
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);
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the GameRobot class.
        /// </summary>
        public GameRobot()
        {
            this.IsFixedTimeStep = false;
            this.graphics = new GraphicsDeviceManager(this);
            this.graphics.SynchronizeWithVerticalRetrace = false;

            // this.graphics.IsFullScreen = true;
            // this.IsMouseVisible = false;
            Content.RootDirectory = "Content";

            this.controlSettingsHelper = new ControlSettingsHelper();
            this.controlSettingsHelper.Load();

            this.communicationHelper = new UdpCommunicationHelper(
                this.controlSettingsHelper.Settings.RoboHeadAddress,
                this.controlSettingsHelper.Settings.UdpSendPort,
                this.controlSettingsHelper.Settings.UdpReceivePort,
                this.controlSettingsHelper.Settings.SingleMessageRepetitionsCount);

            this.flashlightHelper = new FlashlightHelper(this.communicationHelper);
            this.driveHelper = new DriveHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.lookHelper = new LookHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.moodHelper = new MoodHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.gunHelper = new GunHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.videoHelper = new VideoHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.audioHelper = new AudioHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
        }
예제 #5
0
        public void HalfRightBackward()
        {
            var driveHelper = new DriveHelper(this.communicationHelper, this.controlSettings);

            driveHelper.TurboModeOn = true;

            int leftSpeed;
            int rightSpeed;

            driveHelper.CalculateMotorsSpeed(0.7071, -0.7071, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("LFF01", this.leftMotorCommand);
            Assert.AreEqual("RFFB6", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(0.3536, -0.3536, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("LFF23", this.leftMotorCommand);
            Assert.AreEqual("RFFC9", this.rightMotorCommand);
        }
예제 #6
0
        public void HalfRightForward()
        {
            var driveHelper = new DriveHelper(this.communicationHelper, this.controlSettings);

            driveHelper.TurboModeOn = true;

            int leftSpeed;
            int rightSpeed;

            driveHelper.CalculateMotorsSpeed(0.7071, 0.7071, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L00FF", this.leftMotorCommand);
            Assert.AreEqual("R004A", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(0.3536, 0.3536, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L00DD", this.leftMotorCommand);
            Assert.AreEqual("R0037", this.rightMotorCommand);
        }
예제 #7
0
        public void RotationTest1()
        {
            var driveHelper = new DriveHelper(this.communicationHelper, this.controlSettings);

            driveHelper.TurboModeOn = true;

            int leftSpeed;
            int rightSpeed;

            driveHelper.CalculateMotorsSpeed(1, 0, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L00FF", this.leftMotorCommand);
            Assert.AreEqual("R0000", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(0.5, 0, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L00DD", this.leftMotorCommand);
            Assert.AreEqual("R0000", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(-1, 0, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L0000", this.leftMotorCommand);
            Assert.AreEqual("R00FF", this.rightMotorCommand);

            driveHelper.CalculateMotorsSpeed(-0.5, 0, out leftSpeed, out rightSpeed);
            driveHelper.GenerateMotorCommands(leftSpeed, rightSpeed, out this.leftMotorCommand, out this.rightMotorCommand);
            Assert.AreEqual("L0000", this.leftMotorCommand);
            Assert.AreEqual("R00DD", this.rightMotorCommand);
        }
예제 #8
0
 public void StopTest()
 {
     var driveHelper = new DriveHelper(this.communicationHelper, this.controlSettings);
     driveHelper.GenerateMotorCommands(0, 0, out this.leftMotorCommand, out this.rightMotorCommand);
     Assert.AreEqual("L0000", this.leftMotorCommand);
     Assert.AreEqual("R0000", this.rightMotorCommand);
 }