Skip to content

Commit

Permalink
implemented service_relay
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias-luedtke committed Dec 9, 2016
1 parent c7bf355 commit bfadecb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions service_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 2.8.3)
project(service_tools)

find_package(catkin REQUIRED
COMPONENTS
)

catkin_package()


catkin_install_python(PROGRAMS scripts/service_relay
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
18 changes: 18 additions & 0 deletions service_tools/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<package format="2">
<name>service_tools</name>
<version>0.6.4</version>
<description>
Service tools
</description>

<maintainer email="[email protected]">Florian Weisshardt</maintainer>
<author email="[email protected]">Mathias Lüdtke</author>

<license>LGPL</license>

<buildtool_depend>catkin</buildtool_depend>

<exec_depend>rospy</exec_depend>
<exec_depend>rosservice</exec_depend>

</package>
21 changes: 21 additions & 0 deletions service_tools/scripts/service_relay
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python

import rospy
import rosservice

if __name__ == "__main__":
argv = rospy.myargv()
if len(argv) != 3:
rospy.logerr("service_relay IN OUT")

rospy.init_node("service_relay")

local_name, remote_name = argv[1], argv[2]

rospy.wait_for_service(remote_name)
srv_def = rosservice.get_service_class_by_name(remote_name)
remote = rospy.ServiceProxy(remote_name, srv_def)

local = rospy.Service(local_name,srv_def, remote.call)
rospy.loginfo("Started relay from %s to %s (%s)" % (local_name, remote_name, srv_def._type))
rospy.spin()

0 comments on commit bfadecb

Please sign in to comment.