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