ROS2 Only able to run built packages from install/
Hello All,
I am new to ROS2 ( on ubuntu 20.04). I was following the tutorial and was able to spool up a pub/sub. However, when I open a new terminal (made sure to source /opt/foxy/setup.bash - put it in my bashrc) I am unable to run my packages. They do not show up. when I check the number of packages available in the terminal I ran colcon build by doing ros2 run <tab> it says would you like to show all 273 packages. When I open another terminal and try it again it says would you like to show all 253 packages.
I am only able to run my packages in other terminals when I go to my workspace/install/<package name=""> then execute the binary. How do I get ROS2 to be able to run these packages without CD to this folder every time then execute the binary. In ROS1 I never had this issue.
Also I've tried many times to run . install/setup.bash from my workspace directory but I keep getting that either the local_setup.bash does not exist so - I then proceeded to copy the local_setup.bash to where it is needed. afterwards I then copied _local_setup_util_sh.py as well. but I keep getting the error saying no such file or directory
/usr/bin/python3: can't open file '/home/niiquaye/ros2_foxy_training/install/rviz_ogre_vendor/_local_setup_util_sh.py': [Errno 2] No such file or directory
Here is my Cmakelist - sorry for the format I am not sure how to use the properly as it just puts all my code one line
cmake_minimum_required(VERSION 3.5)
project(first_package)
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
add_executable(talker src/publisher_member_function.cpp)
ament_target_dependencies(talker rclcpp std_msgs)
add_executable(listener src/subscriber_member_function.cpp)
ament_target_dependencies(listener rclcpp std_msgs)
install(TARGETS
talker
listener
DESTINATION lib/${PROJECT_NAME})
ament_package()
@rover_challenger FYI you can use the preformatted text (
1010101
) button to format code/terminal output and this will preserve formatting and add syntax highlighting making the text easier to read. Using HTML elements (such as<code>
) doesn't really render will on this site and makes the text wrapped in these elements difficult to readI'll admit I don't know enough about CMake/Colcon/Ament to know for sure if this is anything important, but I've noticed that the
CMakeLists.txt
files in my packages install targets toshare/${PROJECT_NAME}
instead oflib/${PROJECT_NAME}
. Could be worth trying to quickly change that line, rebuild, and see if you can properly source your packages?