I think it is pretty clear that the vision in the man's mind is what we might today call a flashback. He is reliving an experience (or a whole bunch of experiences) that he had back when he was an artilleryman during the war (since this is Whitman, it's probably the Civil War he is referring to).
The man is no longer in the military. In fact, he is at home in bed, with his wife beside him and his baby sleeping in the next room. But he is not over the war and it still haunts him from time to time.