Error:
ModuleNotFoundError: No module named 'my_server.action'; 'my_server' is not a package
I have the following structure:
my_server/
├── action/
│ └── MyServer.action
├── CMakeLists.txt
├── package.xml
├── setup.py
├── my_server/
│ ├── __init__.py
│ └── my_server.py
└── resource/
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(my_server)
# 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")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic" )
endif()
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(std_msgs REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(action_msgs REQUIRED)
install(PROGRAMS
${PROJECT_NAME}/my_server.py
DESTINATION lib/${PROJECT_NAME}
)
rosidl_generate_interfaces(${PROJECT_NAME}
"action/MyServer.action"
DEPENDENCIES std_msgs action_msgs builtin_interfaces
)
ament_export_dependencies(rosidl_default_runtime)
ament_package()
Here is my package.xml:
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>my_server</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<build_depend>std_msgs</build_depend>
<build_depend>action_msgs</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>action_msgs</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
setup.py:
from setuptools import find_packages, setup
package_name = 'my_server'
setup(
name=package_name,
version='0.0.0',
packages=find_packages(exclude=['test']),
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='abc',
maintainer_email='meme',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'my_server = my_server.my_server:main',
],
},
)
MyServer.action:
int32 step
---
int32 final
---
int32 feedback
How it's called in my_server.py:
from my_server.action import MyServer
I would really appreciate your help.