From 365c6882fd4957b9a727eb6af1ec2ede421f5e91 Mon Sep 17 00:00:00 2001 From: Vincent Belpois Date: Thu, 9 May 2024 10:12:26 +0200 Subject: [PATCH] Added match launch file with all required nodes and robtot itself --- README.md | 6 - .../src/sequenceur_homologation.py | 1 + src/matchs/LICENSE.md | 201 ++++++++++++++++++ src/matchs/README.md | 7 + src/matchs/config/.gitignore | 0 src/matchs/launch/.gitignore | 0 src/matchs/launch/match1.launch.py | 51 +++++ src/matchs/package.xml | 23 ++ src/matchs/resource/matches | 0 src/matchs/setup.cfg | 4 + src/matchs/setup.py | 29 +++ src/matchs/src/__init__.py | 0 .../src/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 147 bytes .../sequenceur_homologation.cpython-310.pyc | Bin 0 -> 2295 bytes src/matchs/src/sequenceur_match1.py | 65 ++++++ 15 files changed, 381 insertions(+), 6 deletions(-) delete mode 100644 README.md create mode 100644 src/matchs/LICENSE.md create mode 100644 src/matchs/README.md create mode 100644 src/matchs/config/.gitignore create mode 100644 src/matchs/launch/.gitignore create mode 100644 src/matchs/launch/match1.launch.py create mode 100644 src/matchs/package.xml create mode 100644 src/matchs/resource/matches create mode 100644 src/matchs/setup.cfg create mode 100644 src/matchs/setup.py create mode 100644 src/matchs/src/__init__.py create mode 100644 src/matchs/src/__pycache__/__init__.cpython-310.pyc create mode 100644 src/matchs/src/__pycache__/sequenceur_homologation.cpython-310.pyc create mode 100644 src/matchs/src/sequenceur_match1.py diff --git a/README.md b/README.md deleted file mode 100644 index f8a21f1..0000000 --- a/README.md +++ /dev/null @@ -1,6 +0,0 @@ -#

ezBot-ROS_ws

-This branch is the ROS2 workspace for our robot **ezBot**. - -The ROS2 version is Humble Hawksmbill (LTS) for it's long time support. -The latest version Iron Irwini just released so I'm not sure that it will be stable enough and if it is correctly documentated. -Humble Hawksbill diff --git a/src/homologation/src/sequenceur_homologation.py b/src/homologation/src/sequenceur_homologation.py index 1743049..3c5c883 100644 --- a/src/homologation/src/sequenceur_homologation.py +++ b/src/homologation/src/sequenceur_homologation.py @@ -19,6 +19,7 @@ def __init__(self): self.detected_object = False self.cmd_vel = Twist() self.cmd_vel.linear.x = 0.2 + #self.cmd_vel.linear.y = 0.2 self.cmd_vel.angular.z = 0.0 self.start_time = 0 self.cumulated_time = 0 diff --git a/src/matchs/LICENSE.md b/src/matchs/LICENSE.md new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/src/matchs/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/src/matchs/README.md b/src/matchs/README.md new file mode 100644 index 0000000..d2f2f88 --- /dev/null +++ b/src/matchs/README.md @@ -0,0 +1,7 @@ +## Robot Package Template + +This is a GitHub template. You can make your own copy by clicking the green "Use this template" button. + +It is recommended that you keep the repo/package name the same, but if you do change it, ensure you do a "Find all" using your IDE (or the built-in GitHub IDE by hitting the `.` key) and rename all instances of `my_bot` to whatever your project's name is. + +Note that each directory currently has at least one file in it to ensure that git tracks the files (and, consequently, that a fresh clone has direcctories present for CMake to find). These example files can be removed if required (and the directories can be removed if `CMakeLists.txt` is adjusted accordingly). \ No newline at end of file diff --git a/src/matchs/config/.gitignore b/src/matchs/config/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/src/matchs/launch/.gitignore b/src/matchs/launch/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/src/matchs/launch/match1.launch.py b/src/matchs/launch/match1.launch.py new file mode 100644 index 0000000..99e1763 --- /dev/null +++ b/src/matchs/launch/match1.launch.py @@ -0,0 +1,51 @@ +import launch +from launch.actions import IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration +from launch import LaunchDescription +from launch_ros.actions import Node +from ament_index_python.packages import get_package_share_directory + +import os +import launch_ros.actions + +def generate_launch_description(): + + robot = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + get_package_share_directory('ezbot_robot'),'launch', 'real_robot.launch.py' + )]), + ) + tirette_node = Node( + package='ezbot_command_module', + executable='tirette_node', + name='tirette_node', + output='screen' + ) + + lidar_colision_avoidance = Node( + package='listen_package', + executable='ecoute', + name='ecoute', + output='screen' + ) + + match = Node( + package='matches', + executable='match1', + name='match1', + output='screen' + ) + + + + + return LaunchDescription([ + robot, + tirette_node, + lidar_colision_avoidance, + match + ]) + +if __name__ == '__main__': + generate_launch_description() \ No newline at end of file diff --git a/src/matchs/package.xml b/src/matchs/package.xml new file mode 100644 index 0000000..3f47501 --- /dev/null +++ b/src/matchs/package.xml @@ -0,0 +1,23 @@ + + + + matches + 0.0.0 + todo le loup + MY NAME + TODO: License declaration + + ament_cmake + ament_cmake_python + + rclcpp + std_msgs + rclpy + + ament_lint_auto + ament_lint_common + + + ament_python + + diff --git a/src/matchs/resource/matches b/src/matchs/resource/matches new file mode 100644 index 0000000..e69de29 diff --git a/src/matchs/setup.cfg b/src/matchs/setup.cfg new file mode 100644 index 0000000..3b63d57 --- /dev/null +++ b/src/matchs/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/matches +[install] +install_scripts=$base/lib/matches diff --git a/src/matchs/setup.py b/src/matchs/setup.py new file mode 100644 index 0000000..f478b5d --- /dev/null +++ b/src/matchs/setup.py @@ -0,0 +1,29 @@ +from setuptools import find_packages, setup +import os +from glob import glob + +package_name = 'matches' + +setup( + name=package_name, + version='0.0.0', + packages=find_packages(exclude=['test']), + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + (os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*launch.[pxy][yma]*'))) + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='vincent', + maintainer_email='vincent.belpois@gmail.com', + description='TODO: Package description', + license='Apache-2.0', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'match1 = src.match1:main' + ], + }, +) diff --git a/src/matchs/src/__init__.py b/src/matchs/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/matchs/src/__pycache__/__init__.cpython-310.pyc b/src/matchs/src/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b07f8d2499167573c50c5d29a424f3323a777b6b GIT binary patch literal 147 zcmd1j<>g`k0!|j2G!Xq5L?8o3AjbiSi&=m~3PUi1CZpdfkB`sH%PfhH*DI*J#bJ}1pHiBW OY6mi}mQ~@We$O*mwxOAk?f0Ia?dRY7<8pa9WcYpx?>@TU zW9%{u@SVW_f@!W|VPPCi3xfgkPC+b+<%ly0>buG=aAPT-_vLpRt zCVk}`xlvDsvMYmQ9))U2_Vyh8kqVC(^!c`J!=>jqjcpCN@wQ5-hK}*KYn>KjuAnVm3EOAd==q!QnOCK7`r&udiWEcIa?FTgg0=FiyYO*%DBCg7w zrPjr3GQ`X^+h4cZ8@As#RSpQPpuhtDaLRnALJ;qLNxj zRbx={;Db?_7pa75LO8^kNXnwtWtJ&DN^&Wls7%ZX?2%8E{QK8m===TNgKck2AVgZEwGifNqE$?G%yz0or&BsdQ|Ot&xrs@fWjk@QXVw>$L_4j? z5oY7uX3^eZzUbyli!P{{L3{jkwv(mRuF|?g+pW!c(O%Q^Tg^JnaRK0mLCjC-G~#Y+ zlv%xaQ1^TvKT8W0Ys0@c-MARfGNKPm2oQCROXbR}B(ofHc%b3?&0JnSp*&b89Z{tS z)7Ddf>+v^=N07W|Ai65k9JPGP)#I zHmCb~8KCshs+&acb^HVTKK_7*_=)l{9^86$3T>V{JaMqY`A0OhFVQO6|Bz28){(p0 z?2K=v4}0Z5E4vEf2w%wy<(RfYoFBJ&#vWIWTKqDQ5uNw-8*8I_a#;d zlx^CtUB&dbpd9_(%esWkc^h`O^b#z6_?*gPoB4mm=;9d8coXh*D9%P2B~kuR%tBu;J)CeeOFHf`cY39p54P3J+c!+`hyK_V79M!+iVaSJgMg_hrUHa# zFbLd%t4aQn(04R;?R41a{1YUhakz-xBm9yU)6Kk-iSazfIfu?>zCdSL- zwD<&+y^4k12>`$TjAj8L%>#uY*kNCjrU|VTn{<|@3mQ~2DUid}CM7c6x2gAQV}(*x z>;3;GZ2)YN24Q7S(S*x_T{beTalzfjZJ*OqQ&BhtULSD)y!pTh-wVQ!doTV4M_^0F literal 0 HcmV?d00001 diff --git a/src/matchs/src/sequenceur_match1.py b/src/matchs/src/sequenceur_match1.py new file mode 100644 index 0000000..3c5c883 --- /dev/null +++ b/src/matchs/src/sequenceur_match1.py @@ -0,0 +1,65 @@ +## things to do: +# - listen to the (ros2) topic tirette (bool) status, once it goes from zero to 1 make the robot move with cmd_vel (0.2m.s-1) for 6 seconds (cumulated) +# - listen to the topic detected object (string), if there is anything and we are moving send cmd_vel (0.0m.s-1) to avoid it + +import rclpy +from rclpy.node import Node +from std_msgs.msg import String, Bool +from geometry_msgs.msg import Twist +import time + +class SequenceurHomologation(Node): + def __init__(self): + super().__init__('sequenceur_homologation') + self.subscription_tirette = self.create_subscription(Bool, 'tirette_status', self.tirette_callback, 10) + self.subscription_detected_object = self.create_subscription(String, 'object_detected', self.detected_object_callback, 10) + self.publisher_cmd_vel = self.create_publisher(Twist, '/omnidirectional_controller/cmd_vel_unstamped', 10) + self.timer = self.create_timer(0.1, self.timer_callback) + self.tirette = False + self.detected_object = False + self.cmd_vel = Twist() + self.cmd_vel.linear.x = 0.2 + #self.cmd_vel.linear.y = 0.2 + self.cmd_vel.angular.z = 0.0 + self.start_time = 0 + self.cumulated_time = 0 + self.start_moving = False + self.time_since_detection = 0 + + def tirette_callback(self, msg): + self.tirette = msg.data + + def detected_object_callback(self, msg): + self.time_since_detection = 0 + + def timer_callback(self): + + if self.tirette: + self.time_since_detection = self.time_since_detection + 0.1 + + if not self.start_moving: + self.start_time = time.time() + self.start_moving = True + self.cumulated_time = time.time() - self.start_time + if self.cumulated_time < 6 and self.time_since_detection > 0.5: + self.publisher_cmd_vel.publish(self.cmd_vel) + else: + self.publisher_cmd_vel.publish(Twist()) + else: + self.cumulated_time = 0 + self.start_moving = False + if self.time_since_detection<0.5 and self.start_moving: + self.publisher_cmd_vel.publish(Twist()) + +def main(args=None): + rclpy.init(args=args) + + sequenceur = SequenceurHomologation() + + rclpy.spin(sequenceur) + + sequenceur.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() \ No newline at end of file