ModuleNotFoundError: No module named 'models' for Rospy
I have trouble to wrap my existing python program into ROS platform. I suppose my ROS structure as following, the package name is controller_msgs, and launch file should be able to call node and node should call /src and then __init__.py, then find dependency files in include. However, it does not work properly. Below is my ROS structure and my CMakefile.txt, package.xml
I need to create a custom message in rospy and publish it. How should I modify my stuff?
/noetic-workspace /build /devel /src /my_meta_pkg /my_pkg_A /my_pkg B /my_pkg_etc... Under /my_pkg_A: /controller_msgs /include /models /runs /utils /launch test.launch /msg /node /src /controller_msgs /__init__.py /foo.py setup.py
CMakeList.txt:
cmake_minimum_required(VERSION 2.8.3)
project(controller_msgs)
find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
message_generation
geometry_msgs
)
catkin_python_setup()
SET(CMAKE_MODULE_PATH ${${PROJECT_NAME}_SOURCE_DIR}/cmake)
FILE(GLOB rosMsgFiles RELATIVE "${${PROJECT_NAME}_SOURCE_DIR}/msg/dds"
"${${PROJECT_NAME}_SOURCE_DIR}/msg/dds/*.msg")
## Generate messages in the 'msg' folder
add_message_files(
FILES
dds/DoorLocationPacket.msg
)
generate_messages(
DEPENDENCIES
std_msgs
geometry_msgs
)
install(PROGRAMS
#scripts/simon_script1
nodes/door_detection_node
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
Package.xml is simpler, I only include the essential code here:
<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>message_generation</run_depend>