The robot direction in rviz and the actual robot direction are different

I think I’ve set it up right. But when I get it to work, it only moves in strange directions.
I think it’s because the orientation of the robot in rviz is weird.
Also, even if set to ‘upward’, if ‘map.txt’ is deleted, it defaults to forward again.
Please help me to solve these problems

Did you look at this page: Camera Installation | Learn Ubiquity Robots and ROS
If so, notice the direction of the raspicam ribbon cable for use of ‘upward’.

Note where each wheel was when you first made the map by using 2 pieces of tape on the floor. Then later after saving the map and ready to navigate start the robot from a power-up situation how it was located for when you first made the map.

There are other ways to do this but just try this at this time as it is simplest.

I have not re-verified this for quite some time. The way that ‘upward’ tells the robot code the orientation of the camera is through our URDF file. If you modified the urdf file that could also explain this behavior.

There is other information on use of upward mount here: Fiducial-Based Localization | Learn Ubiquity Robots and ROS