Hi there!
The answer to your question is personification.
Personification means to give something human-like traits, something that is not human. In the sentence, the author gives the trees human traits by saying that they "groaned and shook their heads".
Hope this helps!