0
$\begingroup$

I have created a simple custom ROS service for ROS Noetic. My import line is:

from fishbot_ros.srv import chess_service, chess_serviceResponse

The file structure is like this:

.
└── parent
    ├── src
    │   └── chess_node.py
    └── srv
        └── chess_service.srv

The service is generated correctly and is viewable by rossrv show. I have cleaned devel and build subfolders and then executed catkin make.

My CMakeLists.txt has the following sections:

find_package(catkin REQUIRED COMPONENTS
  rospy
  message_generation
  std_msgs
)

add_service_files(
  FILES
  chess_service.srv
)

My package.xml has the following:

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>rospy</build_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <build_depend>message_generation</build_depend>
  <exec_depend>message_runtime</exec_depend>

Please help me understand what I'm doing wrong. I did this for a different project a while ago, and I've done everything the same.

$\endgroup$

1 Answer 1

0
$\begingroup$

Welcome to Robotics Stack Exchange!

If my_ros_pkg and MyService.srv are the name of the ROS package and name of the service file, respectively, please use the following line to import the service:

from my_ros_pkg.srv import MyService, MyServiceRequest, MyServiceResponse
$\endgroup$
3
  • $\begingroup$ Hi Ravi, thanks for your comment. Unfortunately, this did not work, I still got the same error as below: from fishbot_ros.srv import chess_service, chess_serviceResponse ModuleNotFoundError: No module named 'fishbot_ros' $\endgroup$ Sep 27, 2023 at 5:06
  • $\begingroup$ I assume fishbot_ros is ROS pkg. You may look at following: 1. CMakeLists.txt and Python Node 2. CMakeLists.txt and Python Node $\endgroup$
    – ravi
    Sep 27, 2023 at 6:16
  • 1
    $\begingroup$ Thank you Ravi. The issue was in my CMakeLists. I had the generate messages section commented out. $\endgroup$ Sep 27, 2023 at 7:15

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.