AS: adding first phase of orientation
This commit is contained in:
33
ros2_ws/install/py_srvcli/lib/py_srvcli/client
Executable file
33
ros2_ws/install/py_srvcli/lib/py_srvcli/client
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python3
|
||||
# EASY-INSTALL-ENTRY-SCRIPT: 'py-srvcli==0.0.0','console_scripts','client'
|
||||
import re
|
||||
import sys
|
||||
|
||||
# for compatibility with easy_install; see #2198
|
||||
__requires__ = 'py-srvcli==0.0.0'
|
||||
|
||||
try:
|
||||
from importlib.metadata import distribution
|
||||
except ImportError:
|
||||
try:
|
||||
from importlib_metadata import distribution
|
||||
except ImportError:
|
||||
from pkg_resources import load_entry_point
|
||||
|
||||
|
||||
def importlib_load_entry_point(spec, group, name):
|
||||
dist_name, _, _ = spec.partition('==')
|
||||
matches = (
|
||||
entry_point
|
||||
for entry_point in distribution(dist_name).entry_points
|
||||
if entry_point.group == group and entry_point.name == name
|
||||
)
|
||||
return next(matches).load()
|
||||
|
||||
|
||||
globals().setdefault('load_entry_point', importlib_load_entry_point)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(load_entry_point('py-srvcli==0.0.0', 'console_scripts', 'client')())
|
||||
33
ros2_ws/install/py_srvcli/lib/py_srvcli/service
Executable file
33
ros2_ws/install/py_srvcli/lib/py_srvcli/service
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python3
|
||||
# EASY-INSTALL-ENTRY-SCRIPT: 'py-srvcli==0.0.0','console_scripts','service'
|
||||
import re
|
||||
import sys
|
||||
|
||||
# for compatibility with easy_install; see #2198
|
||||
__requires__ = 'py-srvcli==0.0.0'
|
||||
|
||||
try:
|
||||
from importlib.metadata import distribution
|
||||
except ImportError:
|
||||
try:
|
||||
from importlib_metadata import distribution
|
||||
except ImportError:
|
||||
from pkg_resources import load_entry_point
|
||||
|
||||
|
||||
def importlib_load_entry_point(spec, group, name):
|
||||
dist_name, _, _ = spec.partition('==')
|
||||
matches = (
|
||||
entry_point
|
||||
for entry_point in distribution(dist_name).entry_points
|
||||
if entry_point.group == group and entry_point.name == name
|
||||
)
|
||||
return next(matches).load()
|
||||
|
||||
|
||||
globals().setdefault('load_entry_point', importlib_load_entry_point)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(load_entry_point('py-srvcli==0.0.0', 'console_scripts', 'service')())
|
||||
@@ -0,0 +1,13 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: py-srvcli
|
||||
Version: 0.0.0
|
||||
Summary: srvcli
|
||||
Home-page: UNKNOWN
|
||||
Maintainer: root
|
||||
Maintainer-email: root@todo.todo
|
||||
License: Apache-2.0
|
||||
Platform: UNKNOWN
|
||||
License-File: LICENSE
|
||||
|
||||
UNKNOWN
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
LICENSE
|
||||
package.xml
|
||||
setup.cfg
|
||||
setup.py
|
||||
../../build/py_srvcli/py_srvcli.egg-info/PKG-INFO
|
||||
../../build/py_srvcli/py_srvcli.egg-info/SOURCES.txt
|
||||
../../build/py_srvcli/py_srvcli.egg-info/dependency_links.txt
|
||||
../../build/py_srvcli/py_srvcli.egg-info/entry_points.txt
|
||||
../../build/py_srvcli/py_srvcli.egg-info/requires.txt
|
||||
../../build/py_srvcli/py_srvcli.egg-info/top_level.txt
|
||||
../../build/py_srvcli/py_srvcli.egg-info/zip-safe
|
||||
py_srvcli/__init__.py
|
||||
py_srvcli/client_member_function.py
|
||||
py_srvcli/service_member_function.py
|
||||
resource/py_srvcli
|
||||
test/test_copyright.py
|
||||
test/test_flake8.py
|
||||
test/test_pep257.py
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[console_scripts]
|
||||
client = py_srvcli.client_member_function:main
|
||||
service = py_srvcli.service_member_function:main
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
setuptools
|
||||
@@ -0,0 +1 @@
|
||||
py_srvcli
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
import sys
|
||||
|
||||
from tutorial_interfaces.srv import AddThreeInts
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
|
||||
|
||||
class MinimalClientAsync(Node):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__('minimal_client_async')
|
||||
self.cli = self.create_client(AddThreeInts, 'add_three_ints')
|
||||
while not self.cli.wait_for_service(timeout_sec=1.0):
|
||||
self.get_logger().info('service not available, waiting again...')
|
||||
self.req = AddThreeInts.Request()
|
||||
|
||||
def send_request(self, a, b, c):
|
||||
self.req.a = a
|
||||
self.req.b = b
|
||||
self.req.c = c
|
||||
return self.cli.call_async(self.req)
|
||||
|
||||
|
||||
def main():
|
||||
rclpy.init()
|
||||
|
||||
minimal_client = MinimalClientAsync()
|
||||
future = minimal_client.send_request(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]))
|
||||
rclpy.spin_until_future_complete(minimal_client, future)
|
||||
response = future.result()
|
||||
minimal_client.get_logger().info(
|
||||
'Result of add_three_ints: for %d + %d + %d = %d' %
|
||||
(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), response.sum))
|
||||
|
||||
minimal_client.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,31 @@
|
||||
from tutorial_interfaces.srv import AddThreeInts
|
||||
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
|
||||
|
||||
class MinimalService(Node):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__('minimal_service')
|
||||
self.srv = self.create_service(AddThreeInts, 'add_three_ints', self.add_three_ints_callback)
|
||||
|
||||
def add_three_ints_callback(self, request, response):
|
||||
response.sum = request.a + request.b + request.c
|
||||
self.get_logger().info('Incoming request\na: %d b: %d c: %d' % (request.a, request.b, request.c))
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def main():
|
||||
rclpy.init()
|
||||
|
||||
minimal_service = MinimalService()
|
||||
|
||||
rclpy.spin(minimal_service)
|
||||
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user