without seeing the code that confirms your claim I can only speculate at this time and do some wild-guessing.
Maybe between simulation and real robot there is an input that is changed, or reversed, right is left and left is right or up is down and down is up. could be one possible cause. I would start checking that and follow each step from input to the output on the screen an compare both in simulation and real robot.
The very last cause that i would think of is that one of the core c++ libraries are broken. But should you regardless think that the math library is broken after carefully checking everything multiple times you could try build your code with a different compiler. But this might be a major undertaking since the process is not free of pain. I would not recommend doing that.
Sorry if I am kind of poking around in the dark but without the code and the environment where it runs I am feeling that further troubleshooting is not really effective at the moment.
Thanks you very much for replying. I almost forgot I posted this.
I had written the code this way for the ROS Basics in 5 Days with C++.
At this point, I have finished my presentation for ROS Basics course (Py and C++) and have obtained the certificates.
Nevertheless, I will share the code as a private message with a link to this post.
Just like you explained, I noticed that the real robot arena was rotated 180 degrees.
To give you a quick reference, the double pedestrian crossing line that you see next to the 4 obstacles in the center of the arena was actually on the direct diagonal opposite side in the real robot. So as you said, the left was right and up was down.
Thank you very much for getting back to me on this issue.
Girish