ROS2 Custom Messages Not Found
While trying to run my python script, I get ModuleNotFoundError: No module named 'lightring_msgs'
. I know the message types are being generated; the package files are in the install directory. Why can't python find the module?
My project layout
/lightring_driver
/lightring_driver
<driver files>
package.xml
setup.cfg
setup.py
/lightring_msgs
/msg
CMakeLists.txt
package.xml
setup.cfg
lightring_msgs/CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(lightring_msgs)
# Default to C++14
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(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(lightring_msgs
"msg/LightringCommand.msg"
DEPENDENCIES builtin_interfaces
)
ament_package()
lightring_msgs/package.xml
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>lightring_msgs</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="jacob@todo.todo">jacob</maintainer>
<license>TODO: License declaration</license>
<depend>builtin_interfaces</depend>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rosidl_default_generators</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
How are you building these packages? did you source the
setup.bash
/setup.bat
file after building? Is the location that you installed to on yourPYTHONPATH
as a result?Looks like not sourcing
setup.sh
(in my case) was the issue. Thank you!