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

ROS2 Custom Messages Not Found

asked 2018-10-23 19:12:40 -0600

beck gravatar image

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>
edit retag flag offensive close merge delete

Comments

1

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 your PYTHONPATH as a result?

William gravatar image William  ( 2018-10-25 00:03:50 -0600 )edit

Looks like not sourcing setup.sh (in my case) was the issue. Thank you!

beck gravatar image beck  ( 2018-10-25 11:32:46 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-10-25 11:35:25 -0600

beck gravatar image

I forgot to source install/setup.sh after building. Thanks @William!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2018-10-23 19:12:40 -0600

Seen: 3,417 times

Last updated: Oct 25 '18