Error in .cpp file: 'ros/ros.h' not found

hello… Why every time I get this error for the first line in .cpp file?

1 Like

Hi!

I apologize for the error.

Is this error stopping your program from compiling? If not, please ignore it while we work on the IDE, which is generating this error.

Thanks for your understanding.

BR,

yes
I cant launch the launch file nor run my .cpp file

I try to reset the terminal but in fourth step it display like this as you see in the pictuer

That’s strange.

Can you close your current instance and start another one: Go to the dashboard and close the current instance and then relaunch the course.

  1. image
  2. image Click on the CLOSE button.
    3.Launch the course again.

there is no icon to close the course
555

Ohhh, that’s serious! Perhaps your instance was already closed due to inactivity.

In that case please just launch the course again.

this is another problem how can I launch again the course? it didn’t work as you wrote before. is there another way?

Is it possible the IT support in Robot ignite academy open my account remotely and solve this issue by reset the whole settings?

From the homepage go to the list of courses:
image

Find the course you want to launch and click on START COURSE.

Yes this how I every time start and complete learning but, the .cpp file problem doesn’t solved.

I’m sorry to hear that. Please give us some time to look into this problem and get back to you. It’s a little complicated because I cannot reproduce the issue from here - I also have some C++ files importing that same header without issues.

Thanks for your understanding.

Sir, dose this error of ros master cause unexpected errors in the .cpp files?

@shahad.bakhsh1,

When I tried compiling your package, I found the following errors:

CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package):
  Could not find a package configuration file provided by
  "my_custom_srv_msg_pkg" with any of the following names:

    my_custom_srv_msg_pkgConfig.cmake
    my_custom_srv_msg_pkg-config.cmake

  Add the installation prefix of "my_custom_srv_msg_pkg" to CMAKE_PREFIX_PATH
  or set "my_custom_srv_msg_pkg_DIR" to a directory containing one of the
  above files.  If "my_custom_srv_msg_pkg" provides a separate development
  package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  my_custom_srv_msg_pkg/CMakeLists.txt:10 (find_package)

I fixed this by commenting out line 10 of the CMakeLists.txt specified in the error log. This configuration is wrong - You cannot include a package as a dependency to itself.


CMake Error at /home/user/catkin_ws/devel/share/my_custom_srv_msg_pkg/cmake/my_custom_srv_msg_pkgConfig.cmake:173 (message):
  Project 'my_cpp_class1' tried to find library 'my_custom_srv_msg_pkg'.  The
  library is neither a target nor built/installed properly.  Did you compile
  project 'my_custom_srv_msg_pkg'? Did you find_package() it before the
  subdirectory containing its code is included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  my_cpp_class1/CMakeLists.txt:10 (find_package)

You have a similar error here, so I commented out the dependency. Did you add this dependency by hand? If you are adding package_B as a dependency package_A, you need to specify that when creating package_A, and the CMakeLists.txt entires will be properly added. (Of course, package_B must already exist and must be valid).

catkin_create_pkg package_A roscpp std_msgs package_B

Did you do this?


CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package):
  Could not find a package configuration file provided by
  "trajectory_by_name_srv" with any of the following names:

    trajectory_by_name_srvConfig.cmake
    trajectory_by_name_srv-config.cmake

  Add the installation prefix of "trajectory_by_name_srv" to
  CMAKE_PREFIX_PATH or set "trajectory_by_name_srv_DIR" to a directory
  containing one of the above files.  If "trajectory_by_name_srv" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  service_client_pkg/CMakeLists.txt:10 (find_package)

This is similar to the above. Did you do it as explained there? I have commented out the offending line!


At this point, I will leave you to do the rest.

There are too many errors, and I think it’s because you are not creating the packages from scratch. It seems you copy-pasted several packages and just renamed them. If so, you need to recreate those packages properly using catkin_create_pkg so that the CMakeLists.txt can be properly generated.

this is how I made the services_quiz package:
catkin_create_pkg services1_quiz roscpp msg_stds
and I add message_generation manually

and it didnt work
then I try to create another package:
catkin_create_pkg services_quiz roscpp msg_stds message_generation
and as you see have same problem.

so I didnt do it manually or copy-posted.
That’s why I am still confused and cant complete the course.

It’s not just the quiz package, a lot of packages have wrong configurations.

I recommend you back up all contents of catkin_ws/src locally, remove everything in catkin_ws/src, then start afresh with your quiz package.

  1. Back up catkin_ws/src, with all its files and folders.
    • Right-click on the catkin_ws/src folder in the IDE and select Download, to download it to your local machine.
  2. Remove the folder and recreate it:
cd ~/catkin_ws
rm -rf src/ build/ devel/
mkdir -p src
catkin_make

PS:

It is std_msgs, not msg_stds.

A post was split to a new topic: Cannot find ros.h

did all the steps you said and the error didn’t disappear and when I wrote this to launch my file:
roslaunch services_quiz start_bb8_move_custom_service_server.launch

this message appear:

What is the error you get now when you run catkin_make?