AS: adding first phase of orientation
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# Copyright 2016 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from example_interfaces.srv import AddTwoInts
|
||||
|
||||
import rclpy
|
||||
|
||||
|
||||
def main(args=None):
|
||||
rclpy.init(args=args)
|
||||
node = rclpy.create_node('minimal_client')
|
||||
cli = node.create_client(AddTwoInts, 'add_two_ints')
|
||||
|
||||
req = AddTwoInts.Request()
|
||||
req.a = 41
|
||||
req.b = 1
|
||||
while not cli.wait_for_service(timeout_sec=1.0):
|
||||
node.get_logger().info('service not available, waiting again...')
|
||||
|
||||
future = cli.call_async(req)
|
||||
rclpy.spin_until_future_complete(node, future)
|
||||
|
||||
result = future.result()
|
||||
node.get_logger().info(
|
||||
'Result of add_two_ints: for %d + %d = %d' %
|
||||
(req.a, req.b, result.sum))
|
||||
|
||||
node.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,48 @@
|
||||
# Copyright 2016 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from example_interfaces.srv import AddTwoInts
|
||||
|
||||
import rclpy
|
||||
|
||||
|
||||
def main(args=None):
|
||||
rclpy.init(args=args)
|
||||
|
||||
node = rclpy.create_node('minimal_client_async')
|
||||
|
||||
cli = node.create_client(AddTwoInts, 'add_two_ints')
|
||||
|
||||
req = AddTwoInts.Request()
|
||||
req.a = 41
|
||||
req.b = 1
|
||||
while not cli.wait_for_service(timeout_sec=1.0):
|
||||
node.get_logger().info('service not available, waiting again...')
|
||||
|
||||
future = cli.call_async(req)
|
||||
while rclpy.ok():
|
||||
rclpy.spin_once(node)
|
||||
if future.done():
|
||||
result = future.result()
|
||||
node.get_logger().info(
|
||||
'Result of add_two_ints: for %d + %d = %d' %
|
||||
(req.a, req.b, result.sum))
|
||||
break
|
||||
|
||||
node.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,67 @@
|
||||
# Copyright 2018 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from example_interfaces.srv import AddTwoInts
|
||||
|
||||
import rclpy
|
||||
from rclpy.callback_groups import ReentrantCallbackGroup
|
||||
|
||||
|
||||
def main(args=None):
|
||||
rclpy.init(args=args)
|
||||
node = rclpy.create_node('minimal_client')
|
||||
# Node's default callback group is mutually exclusive. This would prevent the client response
|
||||
# from being processed until the timer callback finished, but the timer callback in this
|
||||
# example is waiting for the client response
|
||||
cb_group = ReentrantCallbackGroup()
|
||||
cli = node.create_client(AddTwoInts, 'add_two_ints', callback_group=cb_group)
|
||||
did_run = False
|
||||
did_get_result = False
|
||||
|
||||
async def call_service():
|
||||
nonlocal cli, node, did_run, did_get_result
|
||||
did_run = True
|
||||
try:
|
||||
req = AddTwoInts.Request()
|
||||
req.a = 41
|
||||
req.b = 1
|
||||
future = cli.call_async(req)
|
||||
result = await future
|
||||
node.get_logger().info(
|
||||
'Result of add_two_ints: for %d + %d = %d' %
|
||||
(req.a, req.b, result.sum))
|
||||
finally:
|
||||
did_get_result = True
|
||||
|
||||
while not cli.wait_for_service(timeout_sec=1.0):
|
||||
node.get_logger().info('service not available, waiting again...')
|
||||
|
||||
timer = node.create_timer(0.5, call_service, callback_group=cb_group)
|
||||
|
||||
while rclpy.ok() and not did_run:
|
||||
rclpy.spin_once(node)
|
||||
|
||||
if did_run:
|
||||
# call timer callback only once
|
||||
timer.cancel()
|
||||
|
||||
while rclpy.ok() and not did_get_result:
|
||||
rclpy.spin_once(node)
|
||||
|
||||
node.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,56 @@
|
||||
# Copyright 2016 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from example_interfaces.srv import AddTwoInts
|
||||
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
|
||||
|
||||
class MinimalClientAsync(Node):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__('minimal_client_async')
|
||||
self.cli = self.create_client(AddTwoInts, 'add_two_ints')
|
||||
while not self.cli.wait_for_service(timeout_sec=1.0):
|
||||
self.get_logger().info('service not available, waiting again...')
|
||||
self.req = AddTwoInts.Request()
|
||||
|
||||
def send_request(self):
|
||||
self.req.a = 41
|
||||
self.req.b = 1
|
||||
self.future = self.cli.call_async(self.req)
|
||||
|
||||
|
||||
def main(args=None):
|
||||
rclpy.init(args=args)
|
||||
|
||||
minimal_client = MinimalClientAsync()
|
||||
minimal_client.send_request()
|
||||
|
||||
while rclpy.ok():
|
||||
rclpy.spin_once(minimal_client)
|
||||
if minimal_client.future.done():
|
||||
response = minimal_client.future.result()
|
||||
minimal_client.get_logger().info(
|
||||
'Result of add_two_ints: for %d + %d = %d' %
|
||||
(minimal_client.req.a, minimal_client.req.b, response.sum))
|
||||
break
|
||||
|
||||
minimal_client.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
# generated from colcon_core/shell/template/command_prefix.sh.em
|
||||
@@ -0,0 +1,20 @@
|
||||
AMENT_PREFIX_PATH=/opt/ros/humble
|
||||
COLCON=1
|
||||
HOME=/root
|
||||
HOSTNAME=a41c1d4d4b48
|
||||
LANG=C.UTF-8
|
||||
LC_ALL=C.UTF-8
|
||||
LD_LIBRARY_PATH=/opt/ros/humble/opt/rviz_ogre_vendor/lib:/opt/ros/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib
|
||||
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
|
||||
OLDPWD=/root/ros2_ws/src
|
||||
PATH=/opt/ros/humble/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
PWD=/root/ros2_ws/build/examples_rclpy_minimal_client
|
||||
PYTHONPATH=/opt/ros/humble/lib/python3.10/site-packages:/opt/ros/humble/local/lib/python3.10/dist-packages
|
||||
ROS_DISTRO=humble
|
||||
ROS_LOCALHOST_ONLY=0
|
||||
ROS_PYTHON_VERSION=3
|
||||
ROS_VERSION=2
|
||||
SHLVL=1
|
||||
TERM=xterm
|
||||
_=/usr/bin/colcon
|
||||
_colcon_cd_root=/opt/ros/humble/
|
||||
@@ -0,0 +1 @@
|
||||
/root/ros2_ws/src/examples/rclpy/services/minimal_client/examples_rclpy_minimal_client
|
||||
@@ -0,0 +1,19 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: examples-rclpy-minimal-client
|
||||
Version: 0.15.3
|
||||
Summary: Examples of minimal service clients using rclpy.
|
||||
Home-page: UNKNOWN
|
||||
Author: Mikael Arguedas
|
||||
Author-email: mikael@osrfoundation.org
|
||||
Maintainer: Aditya Pande, Shane Loretz
|
||||
Maintainer-email: aditya.pande@openrobotics.org, shane@openrobotics.org
|
||||
License: Apache License, Version 2.0
|
||||
Keywords: ROS
|
||||
Platform: UNKNOWN
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: Apache Software License
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Topic :: Software Development
|
||||
|
||||
UNKNOWN
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
README.md
|
||||
package.xml
|
||||
setup.cfg
|
||||
setup.py
|
||||
../../../../../build/examples_rclpy_minimal_client/examples_rclpy_minimal_client.egg-info/PKG-INFO
|
||||
../../../../../build/examples_rclpy_minimal_client/examples_rclpy_minimal_client.egg-info/SOURCES.txt
|
||||
../../../../../build/examples_rclpy_minimal_client/examples_rclpy_minimal_client.egg-info/dependency_links.txt
|
||||
../../../../../build/examples_rclpy_minimal_client/examples_rclpy_minimal_client.egg-info/entry_points.txt
|
||||
../../../../../build/examples_rclpy_minimal_client/examples_rclpy_minimal_client.egg-info/requires.txt
|
||||
../../../../../build/examples_rclpy_minimal_client/examples_rclpy_minimal_client.egg-info/top_level.txt
|
||||
../../../../../build/examples_rclpy_minimal_client/examples_rclpy_minimal_client.egg-info/zip-safe
|
||||
examples_rclpy_minimal_client/__init__.py
|
||||
examples_rclpy_minimal_client/client.py
|
||||
examples_rclpy_minimal_client/client_async.py
|
||||
examples_rclpy_minimal_client/client_async_callback.py
|
||||
examples_rclpy_minimal_client/client_async_member_function.py
|
||||
resource/examples_rclpy_minimal_client
|
||||
test/test_copyright.py
|
||||
test/test_flake8.py
|
||||
test/test_pep257.py
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[console_scripts]
|
||||
client = examples_rclpy_minimal_client.client:main
|
||||
client_async = examples_rclpy_minimal_client.client_async:main
|
||||
client_async_callback = examples_rclpy_minimal_client.client_async_callback:main
|
||||
client_async_member_function = examples_rclpy_minimal_client.client_async_member_function:main
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
setuptools
|
||||
@@ -0,0 +1 @@
|
||||
examples_rclpy_minimal_client
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
23
ros2_ws/build/examples_rclpy_minimal_client/install.log
Normal file
23
ros2_ws/build/examples_rclpy_minimal_client/install.log
Normal file
@@ -0,0 +1,23 @@
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/__init__.py
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/client.py
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/client_async_member_function.py
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/client_async_callback.py
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/client_async.py
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/__pycache__/__init__.cpython-310.pyc
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/__pycache__/client.cpython-310.pyc
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/__pycache__/client_async_member_function.cpython-310.pyc
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/__pycache__/client_async_callback.cpython-310.pyc
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client/__pycache__/client_async.cpython-310.pyc
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/share/ament_index/resource_index/packages/examples_rclpy_minimal_client
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/share/examples_rclpy_minimal_client/package.xml
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client-0.15.3-py3.10.egg-info/zip-safe
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client-0.15.3-py3.10.egg-info/dependency_links.txt
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client-0.15.3-py3.10.egg-info/top_level.txt
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client-0.15.3-py3.10.egg-info/requires.txt
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client-0.15.3-py3.10.egg-info/entry_points.txt
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client-0.15.3-py3.10.egg-info/PKG-INFO
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/python3.10/site-packages/examples_rclpy_minimal_client-0.15.3-py3.10.egg-info/SOURCES.txt
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/examples_rclpy_minimal_client/client
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/examples_rclpy_minimal_client/client_async
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/examples_rclpy_minimal_client/client_async_callback
|
||||
/root/ros2_ws/install/examples_rclpy_minimal_client/lib/examples_rclpy_minimal_client/client_async_member_function
|
||||
1
ros2_ws/build/examples_rclpy_minimal_client/package.xml
Symbolic link
1
ros2_ws/build/examples_rclpy_minimal_client/package.xml
Symbolic link
@@ -0,0 +1 @@
|
||||
/root/ros2_ws/src/examples/rclpy/services/minimal_client/package.xml
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
import sys
|
||||
if sys.prefix == '/usr':
|
||||
sys.real_prefix = sys.prefix
|
||||
sys.prefix = sys.exec_prefix = '/root/ros2_ws/install/examples_rclpy_minimal_client'
|
||||
@@ -0,0 +1 @@
|
||||
/root/ros2_ws/src/examples/rclpy/services/minimal_client/resource/examples_rclpy_minimal_client
|
||||
1
ros2_ws/build/examples_rclpy_minimal_client/setup.cfg
Symbolic link
1
ros2_ws/build/examples_rclpy_minimal_client/setup.cfg
Symbolic link
@@ -0,0 +1 @@
|
||||
/root/ros2_ws/src/examples/rclpy/services/minimal_client/setup.cfg
|
||||
@@ -0,0 +1 @@
|
||||
prepend-non-duplicate;PYTHONPATH;/root/ros2_ws/build/examples_rclpy_minimal_client
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_powershell/shell/template/hook_prepend_value.ps1.em
|
||||
|
||||
colcon_prepend_unique_value PYTHONPATH "$env:COLCON_CURRENT_PREFIX\/root/ros2_ws/build/examples_rclpy_minimal_client"
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_core/shell/template/hook_prepend_value.sh.em
|
||||
|
||||
_colcon_prepend_unique_value PYTHONPATH "/root/ros2_ws/build/examples_rclpy_minimal_client"
|
||||
Reference in New Issue
Block a user