why in the code you are using "local_position/pose" and "local_position/velocity_local" topics instead of "local_position/odom" topic? since the odom topic has bot pose and twist/velocity.
I was trying to change the topic to the "local_position/odom" topic, it worked great in the simulator but somehow didn't work great in real hardware, if I plot the data in plotjuggler, I found that the update interval of "local_position/odom" topic was inconsistent. Is it your consideration of not using the odom topic? do you know why it happened? (green odom topic, yellow local_position topic)