could not source the setup.bash in ROS 2?

asked 2019-04-12 06:16:00 -0600

Abirami_Ravi gravatar image

Step 1: I have Ubuntu 18.04 system on which Crystal ROS 2 installation has been done with the binaries.

Step 2: A workspace has been created and inside which I have the package containing publisher and talker node. (~/ros2_ws/src/pub_sub2/src/talker.cpp)

Step 3: In order to generate the executable, following changes have been done in the CMakeLists.txt.

add_executable(talker src/talker.cpp)
ament_target_dependencies(talker rclcpp std_msgs)

add_executable(listener src/listener.cpp)
ament_target_dependencies(listener rclcpp std_msgs)

install(TARGETS
 talker
 listener
 DESTINATION lib/${PROJECT_NAME}
)

Step 4: Build command colcon build --symlink-install was given. Build was successful and terminated without any errors. Executables could be run from the install folder using ./talker or ./listener

Step 5: On sourcing the setup.bash file inside the install folder, following errors were observed:

not found: "/home/user/ros2_ws/install/pub_sub2/share/pub_sub2/local_setup.sh"
not found: "/home/user/ros2_ws/install/pub_sub2/share/pub_sub2/local_setup.bash"
edit retag flag offensive close merge delete

Comments

Can you post the output of colcon version-check.

Dirk Thomas gravatar imageDirk Thomas ( 2019-04-12 08:40:31 -0600 )edit

Following is the output of colcon version-check command:

colcon-argcomplete 0.3.2: up-to-date
colcon-bash 0.3.1: newer version available (0.3.2)
colcon-cmake 0.2.8: newer version available (0.2.9)
colcon-core 0.3.17: newer version available (0.3.20)
colcon-defaults 0.2.1: newer version available (0.2.2)
colcon-devtools 0.2.1: up-to-date
colcon-library-path 0.2.1: up-to-date
colcon-metadata 0.2.1: newer version available (0.2.2)
colcon-notification 0.2.6: newer version available (0.2.7)
colcon-output 0.2.3: up-to-date
colcon-package-information 0.2.2: up-to-date
colcon-package-selection 0.2.3: newer version available (0.2.4)
colcon-parallel-executor 0.2.3: newer version available (0.2.4)
colcon-pkg-config 0.1.0: up-to-date
colcon-powershell 0.3.3: newer version available (0.3.4)
colcon-python-setup-py 0.2.1: up-to-date
colcon-recursive-crawl 0.2.0: up-to-date
colcon-ros 0.3.7: newer version available (0.3.9)
colcon-test-result 0 ...
(more)
Abirami_Ravi gravatar imageAbirami_Ravi ( 2019-04-12 09:39:45 -0600 )edit

I would suggest updating your system and then trying it again.

Dirk Thomas gravatar imageDirk Thomas ( 2019-04-12 09:43:06 -0600 )edit

I removed the following lines of code in the CMakeLists.txt and the problem is resolved.

 if(BUILD_TESTING)
      find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

Could you please explain what is the issue with these two lines?

Abirami_Ravi gravatar imageAbirami_Ravi ( 2019-04-12 09:45:02 -0600 )edit

My understanding is that the preferred method is to source install/local_setup.bash instead of install/setup.bash. This works fine for me.

clyde gravatar imageclyde ( 2019-04-22 14:15:45 -0600 )edit