Former world superbike champion and MotoGP rider Colin Edwards has announced he will retire from racing at the end of the season.