ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Firstly, you have to re-source your workspace everytime you call catkin_make.

Catkin works in overlays, every workspace you create "overlays" another one. If you consider your ROS install to be as your main "workspace", your personal workspace will overlay the main one. To overlay your workspace with ROS (in other words, make your workspace recognizable by bash), you have to source the setup script found in ~/your_ws/devel directory (I usually use the setup.bash one). To automate the process I usually modify my ~/.bashrc file:

  1. In a terminal type in sudo nano ~/.bashrc.
  2. Scroll to the very bottom and you should see source /opt/ros/your_distro/setup.bash (assuming you followed the default installation procedure, if not, just add it). That line makes the entire ROS environment recognizable by bash.
  3. After the above line, add source ~/your_ws/devel.setup.bash, click CTRL + X, Y, Enter, re-open the terminal. This will now allow bash to recognize and overlay your workspace with the main ROS environment.

Now, everytime you call catkin_make you have to either re-open the terminal or re-source it manually by typing in source ~/your_ws/devel.setup.bash and source ~/.bashrc which will reset the terminal without closing it. If your package is still not recognized (an easy way to find out is by typing rosrun packa.... and clicking TAB midway, which should autocomplete the name), try running rospack list, which will presumably rescan the packages in ROS environment (I don't know exactly how it works).

Secondly, you have to add appropriate CMake macros at the end of your CMakeLists.txt file:

At the very bottom add these two lines for each executable:

  1. add_executable(node_name src/file_name.cpp)
  2. target_link_libraries(node_name ${catkin_LIBRARIES})

This will tell catkin to build and install the executable in your devel/lib/package_name directory.

If none of the above works I am presuming there's something wrong with your ROS install. Providing your CMakeLists.txt file would be helpful.

Firstly, you have to re-source your workspace everytime you call catkin_make.

Catkin works in overlays, every workspace you create "overlays" another one. If you consider your ROS install to be as your main "workspace", your personal workspace will overlay the main one. To overlay your workspace with ROS (in other words, make your workspace recognizable by bash), you have to source the setup script found in ~/your_ws/devel directory (I usually use the setup.bash one). To automate the process I usually modify my ~/.bashrc file:

  1. In a terminal type in sudo nano ~/.bashrc.
  2. Scroll to the very bottom and you should see source /opt/ros/your_distro/setup.bash (assuming you followed the default installation procedure, if not, just add it). That line makes the entire ROS environment recognizable by bash.
  3. After the above line, add source ~/your_ws/devel.setup.bash, click CTRL + X, Y, Enter, re-open the terminal. This will now allow bash to recognize and overlay your workspace with the main ROS environment.

Now, everytime you call catkin_make you have to either re-open the terminal or re-source it manually by typing in source ~/your_ws/devel.setup.bash and source ~/.bashrc which will reset the terminal without closing it. If your package is still not recognized (an easy way to find out is by typing rosrun packa.... and clicking TAB midway, which should autocomplete the name), try running rospack list, which will presumably rescan the packages in ROS environment (I don't know exactly how it works).

Secondly, you have to add appropriate CMake macros at the end of your CMakeLists.txt file:

At the very bottom add these two lines for each executable:

  1. add_executable(node_name src/file_name.cpp)
  2. target_link_libraries(node_name ${catkin_LIBRARIES})

This will tell catkin to build and install the executable in your devel/lib/package_name directory.

If none of the above works I am presuming there's something wrong with your ROS install. Providing your CMakeLists.txt file would be helpful.

EDIT: Update your CMakeLists.txt to:

add_executable(hello src/hello.cpp
target_link_libraries(hello ${catkin_LIBRARIES}

add_executable(pubvel src/pubvel.cpp
target_link_libraries(pubvel ${catkin_LIBRARIES}

Ensure your src is stored in ~/your_ws/src/your_package/src directory.

Firstly, you have to re-source your workspace everytime you call catkin_make.

Catkin works in overlays, every workspace you create "overlays" another one. If you consider your ROS install to be as your main "workspace", your personal workspace will overlay the main one. To overlay your workspace with ROS (in other words, make your workspace recognizable by bash), you have to source the setup script found in ~/your_ws/devel directory (I usually use the setup.bash one). To automate the process I usually modify my ~/.bashrc file:

  1. In a terminal type in sudo nano ~/.bashrc.
  2. Scroll to the very bottom and you should see source /opt/ros/your_distro/setup.bash (assuming you followed the default installation procedure, if not, just add it). That line makes the entire ROS environment recognizable by bash.
  3. After the above line, add source ~/your_ws/devel.setup.bash~/your_ws/devel/setup.bash, click CTRL + X, Y, Enter, re-open the terminal. This will now allow bash to recognize and overlay your workspace with the main ROS environment.

Now, everytime you call catkin_make you have to either re-open the terminal or re-source it manually by typing in source ~/your_ws/devel.setup.bash and source ~/.bashrc which will reset the terminal without closing it. If your package is still not recognized (an easy way to find out is by typing rosrun packa.... and clicking TAB midway, which should autocomplete the name), try running rospack list, which will presumably rescan the packages in ROS environment (I don't know exactly how it works).

Secondly, you have to add appropriate CMake macros at the end of your CMakeLists.txt file:

At the very bottom add these two lines for each executable:

  1. add_executable(node_name src/file_name.cpp)
  2. target_link_libraries(node_name ${catkin_LIBRARIES})

This will tell catkin to build and install the executable in your devel/lib/package_name directory.

If none of the above works I am presuming there's something wrong with your ROS install. Providing your CMakeLists.txt file would be helpful.

EDIT: Update your CMakeLists.txt to:

add_executable(hello src/hello.cpp
target_link_libraries(hello ${catkin_LIBRARIES}

add_executable(pubvel src/pubvel.cpp
target_link_libraries(pubvel ${catkin_LIBRARIES}

Ensure your src is stored in ~/your_ws/src/your_package/src directory.

Firstly, you have to re-source your workspace everytime you call catkin_make.open a new terminal or build a brand new workspace.

Catkin works in overlays, every workspace you create "overlays" another one. If you consider your ROS install to be as your main "workspace", your personal workspace will overlay the main one. To overlay your workspace with ROS (in other words, make your workspace recognizable by bash), you have to source the setup script found in ~/your_ws/devel directory (I usually use the setup.bash one). To automate the process I usually modify my ~/.bashrc file:

  1. In a terminal type in sudo nano ~/.bashrc.
  2. Scroll to the very bottom and you should see source /opt/ros/your_distro/setup.bash (assuming you followed the default installation procedure, if not, just add it). That line makes the entire ROS environment recognizable by bash.
  3. After the above line, add source ~/your_ws/devel/setup.bash, click CTRL + X, Y, Enter, re-open the terminal. This will now allow bash to recognize and overlay your workspace with the main ROS environment.

Now, everytime you call catkin_make you have to either re-open the terminal or re-source it manually by typing in source ~/your_ws/devel.setup.bash and source ~/.bashrc which will reset the terminal without closing it. If your package is still not recognized (an easy way to find out is by typing rosrun packa.... and clicking TAB midway, which should autocomplete the name), try running rospack list, which will presumably rescan the packages in ROS environment (I don't know exactly how it works).

Secondly, you have to add appropriate CMake macros at the end of your CMakeLists.txt file:

At the very bottom add these two lines for each executable:

  1. add_executable(node_name src/file_name.cpp)
  2. target_link_libraries(node_name ${catkin_LIBRARIES})

This will tell catkin to build and install the executable in your devel/lib/package_name directory.

If none of the above works I am presuming there's something wrong with your ROS install. Providing your CMakeLists.txt file would be helpful.

EDIT: Update your CMakeLists.txt to:

add_executable(hello src/hello.cpp
target_link_libraries(hello ${catkin_LIBRARIES}

add_executable(pubvel src/pubvel.cpp
target_link_libraries(pubvel ${catkin_LIBRARIES}

Ensure your src is stored in ~/your_ws/src/your_package/src directory.

Firstly, you have to re-source your workspace everytime you open a new terminal or build a brand new workspace.

Catkin works in overlays, every workspace you create "overlays" another one. If you consider your ROS install to be as your main "workspace", your personal workspace will overlay the main one. To overlay your workspace with ROS (in other words, make your workspace recognizable by bash), you have to source the setup script found in ~/your_ws/devel directory (I usually use the setup.bash one). To automate the process I usually modify my ~/.bashrc file:

  1. In a terminal type in sudo nano ~/.bashrc.
  2. Scroll to the very bottom and you should see source /opt/ros/your_distro/setup.bash (assuming you followed the default installation procedure, if not, just add it). That line makes the entire ROS environment recognizable by bash.
  3. After the above line, add source ~/your_ws/devel/setup.bash, click CTRL + X, Y, Enter, re-open the terminal. This will now allow bash to recognize and overlay your workspace with the main ROS environment.

Now, everytime you call catkin_make you have to either re-open the terminal or re-source it manually by typing in source ~/your_ws/devel.setup.bash and source ~/.bashrc which will reset the terminal without closing it. If your package is still not recognized (an easy way to find out is by typing rosrun packa.... and clicking TAB midway, which should autocomplete the name), try running rospack list, which will presumably rescan the packages in ROS environment (I don't know exactly how it works).

Secondly, you You have to add appropriate CMake macros at the end of your CMakeLists.txt file:

At the very bottom add these two lines for each executable:

  1. add_executable(node_name src/file_name.cpp)
  2. target_link_libraries(node_name ${catkin_LIBRARIES})

This will tell catkin to build and install the executable in your devel/lib/package_name directory.

If none of the above works I am presuming there's something wrong with your ROS install. Providing your CMakeLists.txt file would be helpful.

EDIT: Update your CMakeLists.txt to:

add_executable(hello src/hello.cpp
target_link_libraries(hello ${catkin_LIBRARIES}

add_executable(pubvel src/pubvel.cpp
target_link_libraries(pubvel ${catkin_LIBRARIES}

Ensure your src is stored in ~/your_ws/src/your_package/src directory.