How to compute homotopy classes of maps on the 2-torus? Let $\mathbb T^2$ be the 2-Torus and let $X$ be a topological space.
Is there any way of computing $[\mathbb T^2,X]$, the set of homotopy class of continuous maps $\mathbb T^2\to X$ if I know, for instance, the homotopy groups of $X$?
Actually, I am interested in the case $X=\mathbb{CP^\infty}$. I would like to classify $\mathbb T^1$-principal bundles over $\mathbb T^2$ (in fact $\mathbb T^2$-principal bundles, but this follows easily.)
 A: This is a good chance to advertise the paper
Ellis, G.J. Homotopy classification the J. H. C. Whitehead way. Exposition. Math. 6(2) (1988) 97-110.
Graham Ellis is referring to Whitehead's paper "Combinatorial Homotopy II", not so well read as "Combinatorial Homotopy I". 
He writes:" Almost 40 years ago J.H.C. Whitehead showed in
\cite{W49:CHII} that, for connected $CW$-complexes $X, Y$ with dim
$X \le n$ and $\pi_i Y = 0$ for $2\le i \le \ n - 1$, the homotopy
classification of maps $X \to Y$ can be reduced to a purely
algebraic problem of classifying, up to an appropriate notion of
homotopy, the $\pi_1$-equivariant chain homomorphisms $C_* \widetilde{X}
\to C_* \widetilde{Y}$ between the cellular chain complexes of the
universal  covers. The classification of homotopy equivalences $Y
\simeq Y$ can similarly be reduced to a purely algebraic problem.
Moreover, the algebra of the cellular chains of the universal
covers closely reflects the topology, and provides pleasant and
interesting exercises.
"These results ought to be a standard piece of elementary algebraic
topology. Yet, perhaps because of the somewhat esoteric exposition
given in \cite{W49:CHII}, and perhaps because of a lack of worked
examples, they have remained largely ignored. The purpose of the
present paper is to rectify this situation." 
A: If you want to calculate $[\mathbb T^2,\mathbb CP^\infty]$, perhaps, it's easier to use the classification of maps to $\mathbb CP^\infty$ instead: $[X,\mathbb CP^\infty]=H^2(X)$; so $[\mathbb T^2,\mathbb CP^\infty]=H^2(\mathbb T^2)=\mathbb Z$.
A: (Disclaimer. The previous version of this answer contained serious mistake: it didn't take into account non-triviality of the action of $\pi_1$ on $\pi_2$.)
Claim. The set $[\mathbb T^2,X]_*$ (of pointed maps) can be identified with the set
$$\{(a,b)\in\pi_1(X)^2|ab=ba\}\times\pi_2(X)/\langle t-t^a,t-t^b\mid t\in\pi_2\rangle,$$
where $(-)^\gamma$ denotes the action of $\pi_1$ on $\pi_n$.
And if $\pi_1$ acts trivially on $\pi_2$, $[\mathbb T^2,X]_\ast\approx\{(a,b)\in\pi_1(X)^2|ab=ba\}\times\pi_2(X)$. In particular, if $\pi_1(X)=0$, $[\mathbb T^2,X]_\ast=[\mathbb T^2,X]\cong\pi_2(X)=H_2(X)$.

Proof (sketch). Indeed, parallel and meridian of $\mathbb T^2$ maps to a pair of elements of $\pi_1(X)$ and the 2-cell of the torus maps to a null-homotopy of $aba^{-1}b^{-1}$, but homotopies between trivial loop and some other null-homotopic loop can be identified (non-canonically!) with $\pi_2(X)$.
Let's see if this element of $\pi_2$ is well-defined. If we move $a$ by some (pointed) homotopy $t$ (that can be again identified with an element of $\pi_2$), we get $s'=s+t-t^b$ (in particular, if either both $a$ and $b$ are trivial or $\pi_1(X)$ acts trivially on $\pi_2(X)$, the element $s$ is well-defined).
/* This kind of elementary obstruction theory (cf.) can be applied, I believe, to any 2-dimensional CW-complex $S$ giving (in the case $\pi_1(X)$ acts trivially on $\pi_2(X)$) $[S,X]\approx H^1(S;\pi_1(X))\times H^2(S;\pi_2(X))$. But in higher dimensions the situation becomes more complicated. */

So, for example,
$$[\mathbb T^2,\mathbb CP^\infty]\cong\pi_2(\mathbb CP^\infty)\cong\mathbb Z.$$
But, say,
$$[\mathbb T^2,\mathbb R P^2]_\ast\cong(\mathbb Z/2)^2\times\mathbb Z/{\sim}\cong\{(0,0)\}\times \mathbb Z\sqcup\{(0,1),(1,0),(1,1)\}\times\mathbb Z/2$$
(if the element of  $\pi_1^2$ is nontrivial, the element of $\pi_2$ is defined only mod 2; and in non-pointed case all $\mathbb Z$ become $\mathbb N$; ref).
