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

catkin can't find python service files

asked 2014-05-21 16:11:26 -0500

blakeh gravatar image

I've got a python node which runs a service server. Catkin builds it fine and builds the service files (works fine for another package in C++ which uses the same .srv file). Even though it builds the file fine, at runtime the node can't import it. If I revise the python search path as shown:

PYTHONPATH='/home/blake/Projects/Ros/catkin_ws/devel/lib/python2.7/dist-packages/retractor_ros/srv/':$PYTHONPATH

it works. Here's my CMakelist.txt

cmake_minimum_required(VERSION 2.8.3)
project(retractor_ros)

set(BH_LIB_NAME XXXXXXXXXXX)


## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRE COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  rospy
  roscpp
  std_msgs
  message_generation
  ${BH_LIB_NAME}
)


## Generate services in the 'srv' folder
add_service_files(
   FILES
   PhidgetsServoCommand.srv
#   Service1.srv
#   Service2.srv
)

## Generate added messages and services with any dependencies listed here
 generate_messages(
   DEPENDENCIES
   std_msgs
 )

catkin_package(
  INCLUDE_DIRS 
#   LIBRARIES ${BH_LIB_NAME}
  CATKIN_DEPENDS message_runtime rospy roscpp std_msgs rstate_machine
#  DEPENDS system_lib
)

###########
## Build ##
########### 
include_directories(
  ${catkin_INCLUDE_DIRS}
#   /opt/ros/hydro/include/turtle_actionlib
  /home/blake/Projects/Ros/catkin_ws/devel/include/retractor_ros
  /home/blake/Projects/Ros/catkin_ws/src/pwm_ros
  /home/blake/Projects/Ros/catkin_ws/src/rstate_machine/include
)


## Declare a cpp executable
add_executable(retractor_ros_node retractor_fsm.cpp keyinput.cpp)
target_link_libraries(retractor_ros_node ${BH_LIB_NAME} ${catkin_LIBRARIES})

add_dependencies(${PROJECT_NAME}_node servo_fsm_generate_messages_cpp keyinput.cpp rstate_machine.cpp)

install(PROGRAMS
   scripts/pwm_servo.py
   ../devel/lib/retractor_ros/retractor_ros_node
   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
   )

## Mark executables and/or libraries for installation
install(TARGETS retractor_ros_node
#   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
#   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 ) 
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-05-21 16:37:28 -0500

ahendrix gravatar image

I suspect this happens because you aren't importing the service module correctly in your python node.

I suspect you're doing:

import PhidgetsServoCommand

Instead, you should be doing:

from retractor_ros.srv import PhidgetsServoCommand

We can debug more if you add the import line from your node and the python error you're receiving to your question.

edit flag offensive delete link more

Comments

Thanks - your fix worked! To bad it's not in the documentation !

blakeh gravatar image blakeh  ( 2014-05-22 06:07:25 -0500 )edit
1

Actually it is part of the first rospy Service tutorial: http://wiki.ros.org/rospy_tutorials/Tutorials/WritingServiceClient

Dirk Thomas gravatar image Dirk Thomas  ( 2014-05-22 06:34:57 -0500 )edit

Now that I can import, i find that I can't actually start the service. Basically my project was working as long as I used the "AddTwoInts" service but I think somehow .h files from the ros distribution were sneaking into my build. Now that I have changed the name to "PhidgetsServoCommand", I had trouble above. Now that that is fixed, I can't do rospy.Service(). I'm going to post a new question with details... (Thanks again!)

blakeh gravatar image blakeh  ( 2014-05-22 07:54:57 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-21 16:11:26 -0500

Seen: 2,055 times

Last updated: May 21 '14