This issue keeps coming up for me. Everything is working fine. I talk to the simulation through the /cmd_vel topic, making it move with Twist messages (msg.linear.x = 0.2). I make one adjustment (now msg.angular.z = 0.2) and I suddenly get this message:
Now I can’t even run my basic package (which is this one “my_package”) which I use to verify that this error has nothing to do with the changes I made in the .py file.
Everything is sourced and working until suddenly it doesn’t work.
I think I faced the same issue and it was tricky. It might be because you ros2_ws/install/setup.bash file is also sourcing from ROS1. Please anyone correct me if I am wrong, but I understand that you either want to source one or the other, else it can cause trouble. So on a fresh terminal please do the following:
cd ~/ros2_ws
source install/setup.bash
vim install/setup.bash
Scroll a bit down with the arrows and send a screenshot of this or check yourself it is also sourcing from catkin_make:
I think @GasPatxo is right: you are somehow sourcing both ROS1 and ROS2. This is not good unless you know what you are doing (for instance, launching the ROS1_bridge).
For the general situations, you should either source only ROS1 or only ROS2. In this case, you need to source only ROS2.
So in order to go back to a proper ROS2-only setup, you need to do the following:
Make sure, as @GasPatxo has indicated, that you don’t have any source of ROS1 in your .bashrc file. For that, follow @GasPatxo instructions
Go to ~/ros2_ws and delete build, install and log directories
Restart ALL the terminals (by clicking on the red cross icon of EACH terminal)
On one of the restarted terminals, go to ~/ros2_ws
Source /opt/ros/foxy/setup.bash
Recompile the ros2_ws
This should have generated a new fresh code which only sources ROS2. THIS IS GENERAL PROCEDURE WHEN WORKING WITH ROS IN A PROFESSIONAL ENVIRONMENT. We do this all the time, when we suspect we corrupted our workspaces.
Try now to do your thing and let us know if it works.
I would comment both the noetic and the catkin_ws parts. As you can see in my picture, I only the foxy & simulation workspaces and I have not expirencied any further touble. Worst case scenario just uncomment the catkin_ws.
For sure someone else knows more than me on this so please share your knowledge!
I appreciate your help.
I performed the whole procedure and the same problem arises. I make sure to run a package which I know has worked in the past. Also when building the packages again, the lines again are uncommented. I also tried commenting after rebuilding but still I get the same message…
When I source /opt/ros/foxy/setup.bash I get a message about mixing paths so you may be right that there is such an issue somewhere.
It’s ok Thank you a lot for sharing your knowledge!
I will stick around to see if anyone knows why I am so deeply rooted in noetic and how to change it
ok @r.malmvig there is definitely something wrong with your setup. In order to be able to find the error I need the following:
Clarify if you are working on a rosject or on a course. The title of this thread says working on rosject but your question is inside the ROS2 in 5 Days course Forum. So I don’t know where to look
Please, ALWAYS TAKE SCREENSHOTS OF THE WHOLE SCREEN. Do not take a screenshot. of a part of the screen because you are removing a lot of information. For instance, if you had took a screenshot of the whole screen I would already know if that is a course or a rosject, and which one it is
If it is a rosject, tell me which rosject is and I will check it inside
About how to get a system back to Foxy:
Edit your .bashrc file and remove all related to noetic (remove means comment)
Close that terminal and open a new one
On that terminal, go to the ros2_ws and delete buildinstall and log`
Close that terminal and open a new one again
Got to ros2_ws and source /opt/ros/foxy/setup.bash
Compile that workspace
Close the terminal and open a new one again
Source your ros2_ws
You should have now a clean Foxy system. If those steps do not lead you to a clean Foxy state, then you have not properly done one of the steps or there is a big problem on your system. Please let me know where are you working and I’ll check personally
Yes for some reason I don’t have the problem in the Rosject now but only in the ROS2 basics in 5 days course. I did all the steps above and it didn’t do it.
@r.malmvig for the courses, the system is reset every time you open it. The only thing that is not reset is your build and install directories. So, if you are having a problem in the course, that is because your build and install are wrong and need to be rebuilt (using the procedure above).
Since you mention you already did it, but still the same error, then let me have a look at your area right now and come back to you with a definitive solution