Skip to content

Commit

Permalink
node: Add ServiceProxy/create_client
Browse files Browse the repository at this point in the history
  • Loading branch information
jara001 committed Jul 31, 2024
1 parent eff4350 commit 7b14543
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
- `helpers`:
- `Publisher`, `Subscriber` and `Timer` decorators for ROS1 nodes.
- `Execute` function to create node instance and spin it.
- `uninode`:
- Support for ServiceProxy/create_client.

### Fixed
- `reconfigure`:
Expand Down
13 changes: 13 additions & 0 deletions autopsy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@ def Service(self, name, service_class, handler, buff_size=65536, error_handler=N
return super(Node, self).create_service(srv_type = service_class, srv_name = name, callback = handler)


def ServiceProxy(self, name, service_class, persistent=False, headers=None):
"""Create a handle for invoking a service call.
Arguments (only those that are used):
name -- name of the service, str
service_class -- class of the ROS service message
Reference:
http://docs.ros.org/en/kinetic/api/rospy/html/rospy.impl.tcpros_service.ServiceProxy-class.html
"""
return super(Node, self).create_client(srv_type = service_class, srv_name = name)


def Time(self, secs = 0, nsecs = 0):
"""Create a Time object.
Expand Down
14 changes: 14 additions & 0 deletions autopsy/ros1_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ def create_service(self, srv_type, srv_name, callback, **kwargs):
return rospy.Service(name = srv_name, service_class = srv_type, handler = callback)


def create_client(self, srv_type, srv_name, **kwargs):
"""Create a service client.
Arguments:
srv_type -- class of the used ROS service message
srv_name -- name of the service
**kwargs -- other, currently unsupported arguments
Reference:
https://docs.ros2.org/latest/api/rclpy/api/node.html#rclpy.node.Node.create_client
"""
return rospy.ServiceProxy(name = srv_name, service_class = srv_type)


def get_clock(self):
"""Get clock used by the node."""
return Clock()
Expand Down

0 comments on commit 7b14543

Please sign in to comment.