Error in Rosject


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.

Please help me :slight_smile:

/Rasmus MT

@r.malmvig ,

Did you source your packages again after making the changes?
The error traceback hints at workspace not being sourced.

Did you check if the message type matches ROS2?

— Girish

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:

1 Like

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:

  1. Make sure, as @GasPatxo has indicated, that you don’t have any source of ROS1 in your .bashrc file. For that, follow @GasPatxo instructions
  2. Go to ~/ros2_ws and delete build, install and log directories
  3. Restart ALL the terminals (by clicking on the red cross icon of EACH terminal)
  4. On one of the restarted terminals, go to ~/ros2_ws
  5. Source /opt/ros/foxy/setup.bash
  6. 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.

1 Like

Thank you so much for the replies!!

This snippet is from the ROS2 in 5 days course where I also have the issue. Do I just delete the /opt/ros/noetic part?

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!

1 Like

Do not delete anything in the file. Just comment the lines that are not necessary, those are:

  • the ones about noetic
  • the ones about public_sim_ws
  • the ones about catkin_ws
1 Like


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.

I think I found something.

Now I must find out how to change it

Are you sure you modified the file? Did you double check that it is modified after the procedure?

Yes… But then I delete the install file and uncomment again… still same issue

I find it weird since it is line by line the issue I had. Make sure you are using fresh terminals and that the file is properly modified.

Other than that, I do not know how to help you. I’ll leave it to the pros

1 Like

It’s ok :slight_smile: 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

1 Like

Ok now my question is: How can I get the operating system back to foxy when it seems infused with noetic?

You need a fresh shell, just click on the :x: on the side of the shell name to kill the current one and start a new blank one.

You should source a file that only sources foxy and not noetic. Read the file with cat <filename> or read&write with vim <filename>.

ok @r.malmvig there is definitely something wrong with your setup. In order to be able to find the error I need the following:

  1. 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
  2. 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
  3. 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:

  1. Edit your .bashrc file and remove all related to noetic (remove means comment)
  2. Close that terminal and open a new one
  3. On that terminal, go to the ros2_ws and delete build install and log`
  4. Close that terminal and open a new one again
  5. Got to ros2_ws and source /opt/ros/foxy/setup.bash
  6. Compile that workspace
  7. Close the terminal and open a new one again
  8. 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

1 Like


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.

Is there some way to just reset the whole thing?

@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

How do you take a look at my area?