1
$\begingroup$

I'm trying to import a custom message type to use in a basic publisher. The custom message file is located at /home/username/catkin_ws/src/ee106s24/msg My import statement in publisher.py is from ee106s24.msg import EE106lab_custom_new.

Running rosrun ee106s24 publisher.py gives me this error: Traceback (most recent call last): File "/home/username/catkin_ws/src/ee106s24/src/publisher.py", line 5, in <module> from ee106s24.msg import EE106lab_custom_new ModuleNotFoundError: No module named 'ee106s24'

I don't know if my import statement is wrong, or I'm using catkin_make in the wrong directory or not sourcing something correctly.

Here is my CMakeList:

project(ee106s24)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
  message_generation
)

## Generate messages in the 'msg' folder
add_message_files(
   FILES
  EE106lab_custom_new.msg
)

## Generate services in the 'srv' folder
# add_service_files(
#   FILES
#   Service1.srv
#   Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
#   FILES
#   Action1.action
#   Action2.action
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
#   DEPENDENCIES
#   std_msgs
# )


###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
   #INCLUDE_DIRS include
   #LIBRARIES 
   #ee106s24
   CATKIN_DEPENDS rospy std_msgs
  # DEPENDS system_lib
   message_generation

)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)


```
$\endgroup$

1 Answer 1

1
$\begingroup$

The generate_messages() call is commented out. This means the messages are not generated. Uncomment it and it should work.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.