コード例 #1
0
ファイル: ScribblerDrive.cs プロジェクト: yingted/Myro
        IEnumerator <ITask> MoveForHelper(float leftpower, float rightpower, float milliseconds)
        {
            drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest(leftpower, rightpower);
            _mainPort.SetDrivePower(request);

            yield return(Arbiter.Receive(false, TimeoutPort((int)milliseconds), delegate(DateTime t) { }));

            drive.SetDrivePowerRequest stop = new drive.SetDrivePowerRequest(0, 0);
            _mainPort.SetDrivePower(stop);
        }
コード例 #2
0
        public void HttpPostHandler(HttpPost httpPost)
        {
            HttpPostRequestData formData = httpPost.GetHeader <HttpPostRequestData>();

            try
            {
                DsspOperation operation = formData.TranslatedOperation;

                if (operation is DriveDistance)
                {
                    _mainPort.Post((DriveDistance)operation);
                }
                else if (operation is SetDrivePower)
                {
                    _mainPort.Post((SetDrivePower)operation);
                }
                else if (operation is RotateDegrees)
                {
                    _mainPort.Post((RotateDegrees)operation);
                }
                else if (operation is EnableDrive)
                {
                    _mainPort.Post((EnableDrive)operation);
                }
                else if (operation is AllStop)
                {
                    _mainPort.Post((AllStop)operation);
                }
                else if (operation is ResetEncoders)
                {
                    _mainPort.Post((ResetEncoders)operation);
                }
                else
                {
                    NameValueCollection parameters = formData.Parameters;

                    if (parameters["StartDashboard"] != null)
                    {
                        string          Dashboardcontract = "http://schemas.microsoft.com/robotics/2006/01/simpledashboard.user.html";
                        ServiceInfoType info   = new ServiceInfoType(Dashboardcontract);
                        cons.Create     create = new cons.Create(info);
                        create.TimeSpan = DsspOperation.DefaultShortTimeSpan;

                        ConstructorPort.Post(create);
                        Activate(Arbiter.Choice(
                                     create.ResponsePort,
                                     delegate(CreateResponse createResponse) { },
                                     delegate(Fault f) { LogError(f); }
                                     ));
                    }
                    else if (parameters["DrivePower"] != null)
                    {
                        double power = double.Parse(parameters["Power"]);
                        SetDrivePowerRequest drivepower = new SetDrivePowerRequest();
                        drivepower.LeftWheelPower  = power;
                        drivepower.RightWheelPower = power;
                        _mainPort.Post(new SetDrivePower(drivepower));
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
                HttpPostSuccess(httpPost);
            }
            catch
            {
                HttpPostFailure(httpPost);
            }
        }
コード例 #3
0
ファイル: Drive.cs プロジェクト: slgrobotics/TrackRoamer
        public void HttpPostHandler(HttpPost httpPost)
        {
            HttpPostRequestData formData = httpPost.GetHeader<HttpPostRequestData>();

            try
            {
                DsspOperation operation = formData.TranslatedOperation;

                if (operation is DriveDistance)
                {
                    _mainPort.Post((DriveDistance)operation);
                }
                else if (operation is SetDrivePower)
                {
                    _mainPort.Post((SetDrivePower)operation);
                }
                else if (operation is RotateDegrees)
                {
                    _mainPort.Post((RotateDegrees)operation);
                }
                else if (operation is EnableDrive)
                {
                    _mainPort.Post((EnableDrive)operation);
                }
                else if (operation is AllStop)
                {
                    _mainPort.Post((AllStop)operation);
                }
                else
                {
                    NameValueCollection parameters = formData.Parameters;

                    if (parameters["StartDashboard"] != null)
                    {
                        string Dashboardcontract = "http://schemas.microsoft.com/robotics/2006/01/simpledashboard.html";
                        ServiceInfoType info = new ServiceInfoType(Dashboardcontract);
                        cons.Create create = new cons.Create(info);
                        create.TimeSpan = DsspOperation.DefaultShortTimeSpan;

                        ConstructorPort.Post(create);
                        Arbiter.Choice(
                            create.ResponsePort,
                            delegate(CreateResponse createResponse) { },
                            delegate(Fault f) { LogError(f); }
                        );
                    }
                    else if (parameters["DrivePower"] != null)
                    {
                        double power = double.Parse(parameters["Power"]);
                        SetDrivePowerRequest drivepower = new SetDrivePowerRequest();
                        drivepower.LeftWheelPower = power;
                        drivepower.RightWheelPower = power;
                        _mainPort.Post(new SetDrivePower(drivepower));
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
                HttpPostSuccess(httpPost);
            }
            catch
            {
                HttpPostFailure(httpPost);
            }
        }
コード例 #4
0
 /// <summary>
 /// SetDrivePower Initialization Constructor
 /// </summary>
 /// <param name="body"></param>
 public SetDrivePower(SetDrivePowerRequest body)
 {
     Body = body;
 }
コード例 #5
0
ファイル: ScribblerDrive.cs プロジェクト: yingted/Myro
 public void TurnRight(float power)
 {
     drive.SetDrivePowerRequest right = new drive.SetDrivePowerRequest(power, -power);
     _mainPort.SetDrivePower(right);
 }
コード例 #6
0
ファイル: ScribblerDrive.cs プロジェクト: yingted/Myro
 public void TurnLeft(float power)
 {
     drive.SetDrivePowerRequest left = new drive.SetDrivePowerRequest(-power, power);
     _mainPort.SetDrivePower(left);
 }
コード例 #7
0
ファイル: ScribblerDrive.cs プロジェクト: yingted/Myro
 public void Stop()
 {
     drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest(0, 0);
     _mainPort.SetDrivePower(request);
 }
コード例 #8
0
ファイル: ScribblerDrive.cs プロジェクト: yingted/Myro
 public void SetMotors(float leftPower, float rightPower)
 {
     drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest(leftPower, rightPower);
     _mainPort.SetDrivePower(request);
 }
コード例 #9
0
ファイル: ScribblerDrive.cs プロジェクト: yingted/Myro
 public void Forward(float power)
 {
     drive.SetDrivePowerRequest forwards = new drive.SetDrivePowerRequest(power, power);
     _mainPort.SetDrivePower(forwards);
 }
コード例 #10
0
ファイル: ScribblerDrive.cs プロジェクト: yingted/Myro
 public void Backward(float power)
 {
     drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest(-power, -power);
     _mainPort.SetDrivePower(request);
 }