ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Tutorials/WritingServiceClient(python) - beginner_tutorials.srv

asked 2015-02-21 03:56:33 -0500

CroWizCom gravatar image

updated 2015-02-21 04:49:12 -0500

http://wiki.ros.org/ROS/Tutorials/Wri...

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="z@todo.todo">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
edit retag flag offensive close merge delete

Comments

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.

jarvisschultz gravatar image jarvisschultz  ( 2015-02-21 10:51:41 -0500 )edit

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
CroWizCom gravatar image CroWizCom  ( 2015-02-21 12:07:53 -0500 )edit

catkin_make output

-- beginner_tutorials: 1 messages, 1 services
-- Configuring done
-- Generating done
-- Build files have been written to: ...
CroWizCom gravatar image CroWizCom  ( 2015-02-21 12:08:36 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-02-24 01:51:02 -0500

CroWizCom gravatar image

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2015-02-21 03:56:33 -0500

Seen: 2,219 times

Last updated: Feb 24 '15