Walt Whitman's "O Captain! My Captain!" is written as an extended metaphor and is about the assassination of Abraham Lincoln after the end of the Civil War, framed through the imagery of a captain deceased on a ship returning from a difficult voyage. The captain, of course, is President Abraham Lincoln, the ship represents the United States, and that difficult voyage refers to the Civil War.
This poem opens with the line, "O Captain! my Captain! Our fearful trip is done." This line introduces the metaphor around which this entire poem is organized. With this particular phrasing, Whitman is simultaneously characterizing the nature of this ship's journey as a dangerous and frightening one, but also as one located in the past. The ship has successfully completed that journey. In that sense, you can read this line as possessing a triumphant tone to it, though that sense of triumph will become more mournful as you read of the captain's death.
Of course, remember that this line is tied directly into the poem's metaphorical language, and thus, its characterization of the journey also applies to its characterization of these events in American History. The United States, at the point in time, has only just emerged from the turmoil of the Civil War, and in that sense, this should be a momentous occasion. However, when at last that war has ended, tragedy strikes with the assassination of Abraham Lincoln.