Exemplo n.º 1
0
        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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
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
                {
                    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);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// SetDrivePower Initialization Constructor
 /// </summary>
 /// <param name="body"></param>
 public SetDrivePower(SetDrivePowerRequest body)
 {
     Body = body;
 }
Exemplo n.º 5
0
 public void TurnRight(float power)
 {
     drive.SetDrivePowerRequest right = new drive.SetDrivePowerRequest(power, -power);
     _mainPort.SetDrivePower(right);
 }
Exemplo n.º 6
0
 public void TurnLeft(float power)
 {
     drive.SetDrivePowerRequest left = new drive.SetDrivePowerRequest(-power, power);
     _mainPort.SetDrivePower(left);
 }
Exemplo n.º 7
0
 public void Stop()
 {
     drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest(0, 0);
     _mainPort.SetDrivePower(request);
 }
Exemplo n.º 8
0
 public void SetMotors(float leftPower, float rightPower)
 {
     drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest(leftPower, rightPower);
     _mainPort.SetDrivePower(request);
 }
Exemplo n.º 9
0
 public void Forward(float power)
 {
     drive.SetDrivePowerRequest forwards = new drive.SetDrivePowerRequest(power, power);
     _mainPort.SetDrivePower(forwards);
 }
Exemplo n.º 10
0
 public void Backward(float power)
 {
     drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest(-power, -power);
     _mainPort.SetDrivePower(request);
 }