0
$\begingroup$

Rosanswers logo

http://wiki.ros.org/ROS/Tutorials/WritingServiceClient(python)

I am missing a step where beginner_tutorials.srv is created.

Somewhat expected, when running add_two_ints_server.py I get the error

ImportError: No module named beginner_tutorials.srv

Trying to use AddTwoInts.srv instead did not get me anywhere ..

Here is CmakeList.txt

project(beginner_tutorials)
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
)
 add_message_files(
   FILES
   Num.msg
 )
add_service_files(
  FILES
  AddTwoInts.srv
)
 generate_messages(
   DEPENDENCIES
   std_msgs
 )
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES beginner_tutorials
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
#  DEPENDS system_lib
)
include_directories(
  ${catkin_INCLUDE_DIRS}
)

Here is package.xml

<?xml version="1.0"?>
<package>
  <name>beginner_tutorials</name>
  <version>0.0.0</version>
  <description>The beginner_tutorials package</description>

  <maintainer email="[email protected]">z</maintainer>

  <license>TODO</license>

<build_depend>message_generation</build_depend>
<run_depend>message_runtime</run_depend>
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>

  <export>
  </export>
</package>

Here is the content of srv directory

z@z-P5Q-EM:~/catkin_ws/src/beginner_tutorials/srv$ ls
AddTwoInts.srv  beginner_tutorials.srv
z@z-P5Q-EM:~/catkin_ws/src/beginner_tutorials/srv$ cat AddTwoInts.srv 
int64 a
int64 b
---
int64 sum
z@z-P5Q-EM:~/catkin_ws/src/beginner_tutorials/srv$ cat beginner_tutorials.srv 
int64 a
int64 b
---
int64 sum

rossrv output

z@z-P5Q-EM:~/catkin_ws/src/beginner_tutorials/srv$ rossrv show beginner_tutorials.srv
[beginner_tutorials/beginner_tutorials]:
int64 a
int64 b
---
int64 sum

z@z-P5Q-EM:~/catkin_ws/src/beginner_tutorials/srv$ rossrv show AddTwoInts
[beginner_tutorials/AddTwoInts]:
int64 a
int64 b
---
int64 sum

[rospy_tutorials/AddTwoInts]:
int64 a
int64 b
---
int64 sum

Originally posted by CroWizCom on ROS Answers with karma: 16 on 2015-02-21

Post score: 0


Original comments

Comment by jarvisschultz on 2015-02-21:
Have you successfully run catkin_make? That is what should actually convert the service definition into Python and C++ code that can be used in a node. Also, make sure that you have sourced your setup.bash in the terminal you are running the server in.

Comment by CroWizCom on 2015-02-21:
catkin_make runs fine, just like tutorials up to that point. in .bashrc I have

source /opt/ros/indigo/setup.bash
source ~/catkin_ws/devel/setup.bash

Comment by CroWizCom on 2015-02-21:
catkin_make output

-- beginner_tutorials: 1 messages, 1 services
-- Configuring done
-- Generating done
-- Build files have been written to: ...
$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The problem was in .bashrc. I entered source ~/catkin_ws/devel/setup.bash there, but export PYTHONPATH ..., that somehow got populated few lines down, overrided the proper setting. So I moved source ~/catkin_ws/devel/setup.bash to the end of the .bashrc and everything is swell now.


Originally posted by CroWizCom with karma: 16 on 2015-02-24

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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