private IAsyncAction MipDriveWithRateAndTime(bool toward, int rate, int time) { MipRobotConstants.COMMAND_CODE type = toward ? MipRobotConstants.COMMAND_CODE.DRIVE_FORWARD_WITH_TIME : MipRobotConstants.COMMAND_CODE.DRIVE_BACKWARD_WITH_TIME; byte r = (byte)Math.Min(rate, 30); byte t = (byte)Math.Min(time / 7, 255); return(SendMipCommand(type, r, t).AsAsyncAction()); }
private IAsyncAction MipTurnWithRate(int degree, int rate) { MipRobotConstants.COMMAND_CODE type = degree < 0 ? MipRobotConstants.COMMAND_CODE.TURN_LEFT_BY_ANGLE : MipRobotConstants.COMMAND_CODE.TURN_RIGHT_BY_ANGLE; byte d = (byte)(Math.Min(Math.Abs(degree), 360) / 4); byte r = (byte)Math.Min(rate, 24); return(SendMipCommand(type, d, r).AsAsyncAction()); }
private async Task <bool> SendMipCommand(MipRobotConstants.COMMAND_CODE type, params byte[] data) { bool result = await base.SendCommand((byte)type, data); await Task.Delay(50); return(result); }
private async Task <bool> SendMipCommand(MipRobotConstants.COMMAND_CODE type, params byte[] data) { return(await base.SendCommand((byte)type, data)); }