AS: adding first phase of orientation
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python3
|
||||
# EASY-INSTALL-ENTRY-SCRIPT: 'examples-rclpy-guard-conditions==0.15.3','console_scripts','trigger_guard_condition'
|
||||
import re
|
||||
import sys
|
||||
|
||||
# for compatibility with easy_install; see #2198
|
||||
__requires__ = 'examples-rclpy-guard-conditions==0.15.3'
|
||||
|
||||
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('examples-rclpy-guard-conditions==0.15.3', 'console_scripts', 'trigger_guard_condition')())
|
||||
@@ -0,0 +1,17 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: examples-rclpy-guard-conditions
|
||||
Version: 0.15.3
|
||||
Summary: Examples of using guard conditions.
|
||||
Home-page: UNKNOWN
|
||||
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,16 @@
|
||||
package.xml
|
||||
setup.cfg
|
||||
setup.py
|
||||
../../../../build/examples_rclpy_guard_conditions/examples_rclpy_guard_conditions.egg-info/PKG-INFO
|
||||
../../../../build/examples_rclpy_guard_conditions/examples_rclpy_guard_conditions.egg-info/SOURCES.txt
|
||||
../../../../build/examples_rclpy_guard_conditions/examples_rclpy_guard_conditions.egg-info/dependency_links.txt
|
||||
../../../../build/examples_rclpy_guard_conditions/examples_rclpy_guard_conditions.egg-info/entry_points.txt
|
||||
../../../../build/examples_rclpy_guard_conditions/examples_rclpy_guard_conditions.egg-info/requires.txt
|
||||
../../../../build/examples_rclpy_guard_conditions/examples_rclpy_guard_conditions.egg-info/top_level.txt
|
||||
../../../../build/examples_rclpy_guard_conditions/examples_rclpy_guard_conditions.egg-info/zip-safe
|
||||
examples_rclpy_guard_conditions/__init__.py
|
||||
examples_rclpy_guard_conditions/trigger_guard_condition.py
|
||||
resource/examples_rclpy_guard_conditions
|
||||
test/test_copyright.py
|
||||
test/test_flake8.py
|
||||
test/test_pep257.py
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[console_scripts]
|
||||
trigger_guard_condition = examples_rclpy_guard_conditions.trigger_guard_condition:main
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
setuptools
|
||||
@@ -0,0 +1 @@
|
||||
examples_rclpy_guard_conditions
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
# Copyright 2020 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.
|
||||
|
||||
import rclpy
|
||||
|
||||
|
||||
def main(args=None):
|
||||
|
||||
rclpy.init(args=args)
|
||||
node = rclpy.create_node('demo_guard_condition')
|
||||
executor = rclpy.executors.SingleThreadedExecutor()
|
||||
executor.add_node(node)
|
||||
|
||||
def guard_condition_callback():
|
||||
rclpy.shutdown()
|
||||
node.get_logger().info('guard callback called shutdown')
|
||||
|
||||
def timer_callback():
|
||||
guard_condition.trigger()
|
||||
node.get_logger().info('timer callback triggered guard condition')
|
||||
|
||||
node.create_timer(timer_period_sec=2, callback=timer_callback)
|
||||
guard_condition = node.create_guard_condition(guard_condition_callback)
|
||||
|
||||
while rclpy.ok():
|
||||
# First loop: `spin_once` waits for timer to be ready, then calls
|
||||
# the timer's callback, which triggers the guard condition.
|
||||
# Second loop: The guard condition is ready so it's callback is
|
||||
# called. The callback calls shutdown, so the loop doesn't run
|
||||
# again and the program exits.
|
||||
node.get_logger().info("waiting for 'spin_once' to finish...")
|
||||
executor.spin_once()
|
||||
node.get_logger().info("...'spin_once' finished!\n")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user