Obscure, as is common among colloquialisms. OED mentions possible association with Dutch trappen, to tread or stamp the foot, but objects that the connection is unconvincing.
Practice speaking and memorizing "trapes" and many other words and sentences in English.