Get pitch angle using imu

Hello there,

I am currently working on a robot that works on the basis of an inverted pendulum. To keep this stable, I need the pitch angle of the robot for the controller I want to implement. My workflow is based on ROS. My approach would now be to use an imu and get the pitch angle via pose tree.
Hence the questions: is it possible and what should be considered when using the Imu/Imu_joint?
Currently I get no or wrong values ​​out.

thanks in advance and greetings.