From this point on I am switching to ROS2 Galactic. The reason is, a signifficant part of navigation functionality is not implemented in Foxy.
To install Galactic, we have to uninstall Foxy first:
$ sudo apt remove ~nros-foxy-* && sudo apt autoremove
Then run same commands we used to install Foxy and its tools, but replace "foxy" with "galactic" (see in earlier section).
Edit the bashrc file to make sure a correct ROS2 is sourced when you start the terminal:
$ gedit ~/.bashrc # Change # source /opt/ros/foxy/setup.bash # to source /opt/ros/galactic/setup.bash
It is possible that some environment variables in your system will still point to Foxy instead of Galactic. In this case you will get corresponding error messages when trying to compile or run your code. Most likely, restarting the Terminal will solve the problem.