From 6d96f1b99c3977d57382906bd60230e9140464aa Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 13 Oct 2025 10:47:49 +0200 Subject: [PATCH] Added ROS2 packages (without submodule references) --- ros2_ws/src/cmd_vel_mux | 1 + ros2_ws/src/ecl_core | 1 + ros2_ws/src/ecl_lite | 1 + ros2_ws/src/file_server2/CMakeLists.txt | 76 +++ ros2_ws/src/file_server2/LICENSE | 202 +++++++ .../publish_description_piper.launch.py | 52 ++ .../launch/publish_description_r2d2.launch.py | 69 +++ .../publish_description_turtlebot2.launch.py | 35 ++ ...lish_description_turtlebot4_lite.launch.py | 49 ++ ..._description_turtlebot4_standard.launch.py | 49 ++ .../launch/ros_sharp_communication.launch.py | 67 +++ .../launch/visualize_robot.launch.py | 92 ++++ ros2_ws/src/file_server2/package.xml | 34 ++ .../rviz/robot_visualization.rviz | 325 +++++++++++ ros2_ws/src/file_server2/src/file_server.cpp | 176 ++++++ .../src/file_server2/srv/GetBinaryFile.srv | 4 + .../src/file_server2/srv/SaveBinaryFile.srv | 4 + .../src/file_server2/urdf/custom_r2d2.urdf | 513 ++++++++++++++++++ ros2_ws/src/gazebo_simulation_scene2/LICENSE | 202 +++++++ .../config/gazebo_bridge.yaml | 54 ++ .../config/gazebo_bridge_effort.yaml | 57 ++ .../gazebo_simulation_scene2/__init__.py | 0 .../gazebo_simulation_scene2/joy_to_twist2.py | 86 +++ .../gazebo_simulation_scene_camera.launch.py | 111 ++++ ...imulation_scene_complete_with_UI.launch.py | 126 +++++ ...zebo_simulation_scene_diff_drive.launch.py | 119 ++++ .../src/gazebo_simulation_scene2/package.xml | 20 + .../resource/gazebo_simulation_scene2 | 0 .../src/gazebo_simulation_scene2/setup.cfg | 4 + ros2_ws/src/gazebo_simulation_scene2/setup.py | 32 ++ .../test/test_copyright.py | 25 + .../test/test_flake8.py | 25 + .../test/test_pep257.py | 23 + .../worlds/gazebo_simulation_scene2_world.sdf | 296 ++++++++++ ros2_ws/src/kobuki_core | 1 + ros2_ws/src/kobuki_ros | 1 + ros2_ws/src/kobuki_ros_interfaces | 1 + ros2_ws/src/piper_ros | 1 + ros2_ws/src/unity_simulation_scene2/LICENSE | 202 +++++++ .../launch/unity_simulation_scene.launch.py | 52 ++ .../src/unity_simulation_scene2/package.xml | 26 + .../resource/unity_simulation_scene2 | 0 ros2_ws/src/unity_simulation_scene2/setup.cfg | 4 + ros2_ws/src/unity_simulation_scene2/setup.py | 29 + .../test/test_copyright.py | 25 + .../test/test_flake8.py | 25 + .../test/test_pep257.py | 23 + .../unity_simulation_scene2/__init__.py | 0 .../unity_simulation_scene2/mouse_to_joy2.py | 98 ++++ ros2_ws/src/urdf_export_test/LICENSE | 202 +++++++ ros2_ws/src/urdf_export_test/package.xml | 18 + .../resource/urdf_export_test | 0 ros2_ws/src/urdf_export_test/setup.cfg | 4 + ros2_ws/src/urdf_export_test/setup.py | 29 + .../urdf_export_test/test/test_copyright.py | 25 + .../src/urdf_export_test/test/test_flake8.py | 25 + .../src/urdf_export_test/test/test_pep257.py | 23 + .../urdf_export_test/__init__.py | 0 58 files changed, 3744 insertions(+) create mode 160000 ros2_ws/src/cmd_vel_mux create mode 160000 ros2_ws/src/ecl_core create mode 160000 ros2_ws/src/ecl_lite create mode 100644 ros2_ws/src/file_server2/CMakeLists.txt create mode 100644 ros2_ws/src/file_server2/LICENSE create mode 100644 ros2_ws/src/file_server2/launch/publish_description_piper.launch.py create mode 100644 ros2_ws/src/file_server2/launch/publish_description_r2d2.launch.py create mode 100644 ros2_ws/src/file_server2/launch/publish_description_turtlebot2.launch.py create mode 100644 ros2_ws/src/file_server2/launch/publish_description_turtlebot4_lite.launch.py create mode 100644 ros2_ws/src/file_server2/launch/publish_description_turtlebot4_standard.launch.py create mode 100644 ros2_ws/src/file_server2/launch/ros_sharp_communication.launch.py create mode 100644 ros2_ws/src/file_server2/launch/visualize_robot.launch.py create mode 100644 ros2_ws/src/file_server2/package.xml create mode 100644 ros2_ws/src/file_server2/rviz/robot_visualization.rviz create mode 100644 ros2_ws/src/file_server2/src/file_server.cpp create mode 100644 ros2_ws/src/file_server2/srv/GetBinaryFile.srv create mode 100644 ros2_ws/src/file_server2/srv/SaveBinaryFile.srv create mode 100644 ros2_ws/src/file_server2/urdf/custom_r2d2.urdf create mode 100644 ros2_ws/src/gazebo_simulation_scene2/LICENSE create mode 100644 ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge.yaml create mode 100644 ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge_effort.yaml create mode 100644 ros2_ws/src/gazebo_simulation_scene2/gazebo_simulation_scene2/__init__.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/gazebo_simulation_scene2/joy_to_twist2.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_camera.launch.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_complete_with_UI.launch.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_diff_drive.launch.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/package.xml create mode 100644 ros2_ws/src/gazebo_simulation_scene2/resource/gazebo_simulation_scene2 create mode 100644 ros2_ws/src/gazebo_simulation_scene2/setup.cfg create mode 100644 ros2_ws/src/gazebo_simulation_scene2/setup.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/test/test_copyright.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/test/test_flake8.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/test/test_pep257.py create mode 100644 ros2_ws/src/gazebo_simulation_scene2/worlds/gazebo_simulation_scene2_world.sdf create mode 160000 ros2_ws/src/kobuki_core create mode 160000 ros2_ws/src/kobuki_ros create mode 160000 ros2_ws/src/kobuki_ros_interfaces create mode 160000 ros2_ws/src/piper_ros create mode 100644 ros2_ws/src/unity_simulation_scene2/LICENSE create mode 100644 ros2_ws/src/unity_simulation_scene2/launch/unity_simulation_scene.launch.py create mode 100644 ros2_ws/src/unity_simulation_scene2/package.xml create mode 100644 ros2_ws/src/unity_simulation_scene2/resource/unity_simulation_scene2 create mode 100644 ros2_ws/src/unity_simulation_scene2/setup.cfg create mode 100644 ros2_ws/src/unity_simulation_scene2/setup.py create mode 100644 ros2_ws/src/unity_simulation_scene2/test/test_copyright.py create mode 100644 ros2_ws/src/unity_simulation_scene2/test/test_flake8.py create mode 100644 ros2_ws/src/unity_simulation_scene2/test/test_pep257.py create mode 100644 ros2_ws/src/unity_simulation_scene2/unity_simulation_scene2/__init__.py create mode 100644 ros2_ws/src/unity_simulation_scene2/unity_simulation_scene2/mouse_to_joy2.py create mode 100644 ros2_ws/src/urdf_export_test/LICENSE create mode 100644 ros2_ws/src/urdf_export_test/package.xml create mode 100644 ros2_ws/src/urdf_export_test/resource/urdf_export_test create mode 100644 ros2_ws/src/urdf_export_test/setup.cfg create mode 100644 ros2_ws/src/urdf_export_test/setup.py create mode 100644 ros2_ws/src/urdf_export_test/test/test_copyright.py create mode 100644 ros2_ws/src/urdf_export_test/test/test_flake8.py create mode 100644 ros2_ws/src/urdf_export_test/test/test_pep257.py create mode 100644 ros2_ws/src/urdf_export_test/urdf_export_test/__init__.py diff --git a/ros2_ws/src/cmd_vel_mux b/ros2_ws/src/cmd_vel_mux new file mode 160000 index 0000000..bf9f4ce --- /dev/null +++ b/ros2_ws/src/cmd_vel_mux @@ -0,0 +1 @@ +Subproject commit bf9f4ce6ebfa04906d09d58b53af8302f68b9e2d diff --git a/ros2_ws/src/ecl_core b/ros2_ws/src/ecl_core new file mode 160000 index 0000000..7bcdf80 --- /dev/null +++ b/ros2_ws/src/ecl_core @@ -0,0 +1 @@ +Subproject commit 7bcdf804237486740071011900f3f5a55a70a9cd diff --git a/ros2_ws/src/ecl_lite b/ros2_ws/src/ecl_lite new file mode 160000 index 0000000..f9b8aa0 --- /dev/null +++ b/ros2_ws/src/ecl_lite @@ -0,0 +1 @@ +Subproject commit f9b8aa04c97ea332ae8ea7e052a31f7ec2670c9a diff --git a/ros2_ws/src/file_server2/CMakeLists.txt b/ros2_ws/src/file_server2/CMakeLists.txt new file mode 100644 index 0000000..2eb94ef --- /dev/null +++ b/ros2_ws/src/file_server2/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.5) +project(file_server2) + +# Default to C++17 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + +# Find dependencies +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) +find_package(std_msgs REQUIRED) +find_package(rosidl_default_generators REQUIRED) + +# Add message and service dependencies +set(msg_dependencies + std_msgs +) + +set(srv_files + "srv/GetBinaryFile.srv" + "srv/SaveBinaryFile.srv" +) + +rosidl_generate_interfaces(${PROJECT_NAME} + ${srv_files} + DEPENDENCIES ${msg_dependencies} +) + +# Build the executable +add_executable(file_server2_node src/file_server.cpp) + +ament_target_dependencies(file_server2_node + rclcpp + std_msgs +) + +# Get the typesupport targets +rosidl_get_typesupport_target(typesupport_target_cpp ${PROJECT_NAME} rosidl_typesupport_cpp) + +# Link the typesupport targets to your project +target_link_libraries(file_server2_node ${typesupport_target_cpp}) + +# rosidl_target_interfaces(file_server2_node ${PROJECT_NAME} "rosidl_typesupport_cpp") + +# Install +install(TARGETS file_server2_node + DESTINATION lib/${PROJECT_NAME} +) + +# Install launch files +install(DIRECTORY + launch + DESTINATION share/${PROJECT_NAME}/ +) + +# Install directories +install(DIRECTORY + srv + DESTINATION share/${PROJECT_NAME}/ +) + +# Install rviz files +install(DIRECTORY + rviz + DESTINATION share/${PROJECT_NAME} +) + +# Install urdf file +install(DIRECTORY + urdf + DESTINATION share/${PROJECT_NAME} +) + +# Install package.xml +ament_package() diff --git a/ros2_ws/src/file_server2/LICENSE b/ros2_ws/src/file_server2/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/ros2_ws/src/file_server2/LICENSE @@ -0,0 +1,202 @@ + + 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/ros2_ws/src/file_server2/launch/publish_description_piper.launch.py b/ros2_ws/src/file_server2/launch/publish_description_piper.launch.py new file mode 100644 index 0000000..e72306d --- /dev/null +++ b/ros2_ws/src/file_server2/launch/publish_description_piper.launch.py @@ -0,0 +1,52 @@ +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Define launch arguments + port_arg = DeclareLaunchArgument( + 'port', + default_value='9090', + description='Port number for ROS communication' + ) + + gripper_arg = DeclareLaunchArgument( + 'gripper_type', + default_value='piper_with_gripper', + description='Choose which robot configuration to launch' + ) + + # Define paths + pkg_file_server2 = get_package_share_directory('file_server2') + rosbridge_server_launch_file = PathJoinSubstitution([ + pkg_file_server2, + 'launch', + 'ros_sharp_communication.launch.py' + ]) + + pkg_piper_description = get_package_share_directory('piper_description') + tb4_standard_launch_file = PathJoinSubstitution([ + pkg_piper_description, + 'launch', + LaunchConfiguration('gripper_type'), + 'display_urdf.launch.py' + ]) + + # Include ROS Sharp Communication launch file + ros_sharp_communication_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([rosbridge_server_launch_file]), + launch_arguments=[('port', LaunchConfiguration('port'))] + ) + + tb4_standard_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([tb4_standard_launch_file]) + ) + + return LaunchDescription([ + port_arg, + gripper_arg, + ros_sharp_communication_launch, + tb4_standard_launch + ]) diff --git a/ros2_ws/src/file_server2/launch/publish_description_r2d2.launch.py b/ros2_ws/src/file_server2/launch/publish_description_r2d2.launch.py new file mode 100644 index 0000000..35cfd3a --- /dev/null +++ b/ros2_ws/src/file_server2/launch/publish_description_r2d2.launch.py @@ -0,0 +1,69 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from launch_ros.actions import Node +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Define launch arguments + print("URDF Launch Path:") + print(get_package_share_directory('urdf_launch')) + port_arg = DeclareLaunchArgument('port', default_value='9090', description='Port number for ROS communication') + urdf_file_arg = DeclareLaunchArgument('urdf_file', default_value='custom_r2d2.urdf', description='URDF file name') + + # Define paths + pkg_file_server2 = get_package_share_directory('file_server2') + rosbridge_server_launch_file = PathJoinSubstitution( + [pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py']) + + urdf_launch_path = get_package_share_directory('urdf_launch') + urdf_launch_launch_file = PathJoinSubstitution( + [urdf_launch_path, 'launch', 'description.launch.py']) + + custom_urdf_file_path = PathJoinSubstitution([ + pkg_file_server2, + "urdf", + LaunchConfiguration('urdf_file') + ]) + + # Include ROS Sharp Communication launch file + ros_sharp_communication_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([rosbridge_server_launch_file]), + launch_arguments=[('port', LaunchConfiguration('port'))] + ) + + r2d2_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([urdf_launch_launch_file]), + launch_arguments={ + 'urdf_package': 'urdf_tutorial', + 'urdf_package_path': custom_urdf_file_path}.items() + ) + + joint_state_publisher_node = Node( + package='joint_state_publisher', + executable='joint_state_publisher' + ) + + + return LaunchDescription([ + port_arg, + urdf_file_arg, + ros_sharp_communication_launch, + r2d2_launch, + # joint_state_publisher_node + ]) + diff --git a/ros2_ws/src/file_server2/launch/publish_description_turtlebot2.launch.py b/ros2_ws/src/file_server2/launch/publish_description_turtlebot2.launch.py new file mode 100644 index 0000000..1e7387a --- /dev/null +++ b/ros2_ws/src/file_server2/launch/publish_description_turtlebot2.launch.py @@ -0,0 +1,35 @@ +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Define launch arguments + port_arg = DeclareLaunchArgument('port', default_value='9090', description='Port number for ROS communication') + + # Define paths + pkg_file_server2 = get_package_share_directory('file_server2') + rosbridge_server_launch_file = PathJoinSubstitution( + [pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py']) + + pkg_tb4_bringup = get_package_share_directory('kobuki_description') + tb4_standard_launch_file = PathJoinSubstitution( + [pkg_tb4_bringup, 'launch', 'robot_description.launch.py']) + + + # Include ROS Sharp Communication launch file + ros_sharp_communication_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([rosbridge_server_launch_file]), + launch_arguments=[('port', LaunchConfiguration('port'))] + ) + + tb4_standard_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([tb4_standard_launch_file]) + ) + + return LaunchDescription([ + port_arg, + ros_sharp_communication_launch, + tb4_standard_launch + ]) diff --git a/ros2_ws/src/file_server2/launch/publish_description_turtlebot4_lite.launch.py b/ros2_ws/src/file_server2/launch/publish_description_turtlebot4_lite.launch.py new file mode 100644 index 0000000..ca51581 --- /dev/null +++ b/ros2_ws/src/file_server2/launch/publish_description_turtlebot4_lite.launch.py @@ -0,0 +1,49 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Define launch arguments + port_arg = DeclareLaunchArgument('port', default_value='9090', description='Port number for ROS communication') + + # Define paths + pkg_file_server2 = get_package_share_directory('file_server2') + rosbridge_server_launch_file = PathJoinSubstitution( + [pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py']) + + pkg_tb4_bringup = get_package_share_directory('turtlebot4_bringup') + tb4_standard_launch_file = PathJoinSubstitution( + [pkg_tb4_bringup, 'launch', 'lite.launch.py']) + + + # Include ROS Sharp Communication launch file + ros_sharp_communication_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([rosbridge_server_launch_file]), + launch_arguments=[('port', LaunchConfiguration('port'))] + ) + + tb4_standard_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([tb4_standard_launch_file]) + ) + + return LaunchDescription([ + port_arg, + ros_sharp_communication_launch, + tb4_standard_launch + ]) + diff --git a/ros2_ws/src/file_server2/launch/publish_description_turtlebot4_standard.launch.py b/ros2_ws/src/file_server2/launch/publish_description_turtlebot4_standard.launch.py new file mode 100644 index 0000000..a04e4ec --- /dev/null +++ b/ros2_ws/src/file_server2/launch/publish_description_turtlebot4_standard.launch.py @@ -0,0 +1,49 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Define launch arguments + port_arg = DeclareLaunchArgument('port', default_value='9090', description='Port number for ROS communication') + + # Define paths + pkg_file_server2 = get_package_share_directory('file_server2') + rosbridge_server_launch_file = PathJoinSubstitution( + [pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py']) + + pkg_tb4_bringup = get_package_share_directory('turtlebot4_bringup') + tb4_standard_launch_file = PathJoinSubstitution( + [pkg_tb4_bringup, 'launch', 'standard.launch.py']) + + + # Include ROS Sharp Communication launch file + ros_sharp_communication_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([rosbridge_server_launch_file]), + launch_arguments=[('port', LaunchConfiguration('port'))] + ) + + tb4_standard_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([tb4_standard_launch_file]) + ) + + return LaunchDescription([ + port_arg, + ros_sharp_communication_launch, + tb4_standard_launch + ]) + diff --git a/ros2_ws/src/file_server2/launch/ros_sharp_communication.launch.py b/ros2_ws/src/file_server2/launch/ros_sharp_communication.launch.py new file mode 100644 index 0000000..67d024c --- /dev/null +++ b/ros2_ws/src/file_server2/launch/ros_sharp_communication.launch.py @@ -0,0 +1,67 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.launch_description_sources import FrontendLaunchDescriptionSource +from launch_ros.actions import Node +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Define launch arguments + port_arg = DeclareLaunchArgument('port', + default_value='9090', + description='Port number for ROS communication (default: 9090)') + + fragment_timeout_arg = DeclareLaunchArgument('fragment_timeout', + default_value='600', + description='Timeout for fragment reassembly in seconds (default: 600)') + + unregister_timeout_arg = DeclareLaunchArgument('unregister_timeout', + default_value='10.0', + description='Timeout for unregistering in seconds (default: 10.0)') + + max_message_size_arg = DeclareLaunchArgument('max_message_size', + default_value='100000000', + description='Maximum message size in bytes (default: 10000000)') + + pkg_rosbridge_server = get_package_share_directory('rosbridge_server') + + rosbridge_server_launch = PathJoinSubstitution( + [pkg_rosbridge_server, 'launch', 'rosbridge_websocket_launch.xml']) + + return LaunchDescription([ + port_arg, + fragment_timeout_arg, + unregister_timeout_arg, + max_message_size_arg, + + IncludeLaunchDescription( + FrontendLaunchDescriptionSource([rosbridge_server_launch]), + launch_arguments={ + 'port': LaunchConfiguration('port'), + 'fragment_timeout': LaunchConfiguration('fragment_timeout'), + 'unregister_timeout': LaunchConfiguration('unregister_timeout'), + 'max_message_size': LaunchConfiguration('max_message_size') + }.items() + ), + + Node( + package='file_server2', + executable='file_server2_node', + output='screen' + ) + + ]) + diff --git a/ros2_ws/src/file_server2/launch/visualize_robot.launch.py b/ros2_ws/src/file_server2/launch/visualize_robot.launch.py new file mode 100644 index 0000000..1612469 --- /dev/null +++ b/ros2_ws/src/file_server2/launch/visualize_robot.launch.py @@ -0,0 +1,92 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com/m.emrecakal@gmail.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch_ros.actions import Node, SetParameter +from launch.actions import DeclareLaunchArgument, OpaqueFunction +from launch.substitutions import LaunchConfiguration +from ament_index_python.packages import get_package_share_directory +import os +from tempfile import NamedTemporaryFile + +def generate_launch_description(): + # Declare launch arguments + gui_arg = DeclareLaunchArgument('gui', default_value='true', description='Whether to show GUI') + urdf_file_arg = DeclareLaunchArgument('urdf_file', default_value='robot_description.urdf', description='URDF file name') + package_name_arg = DeclareLaunchArgument('package_name', default_value='urdf_export_test', description='Package name containing URDF file') + rviz_config_file_arg = DeclareLaunchArgument('rviz_config_file', default_value='robot_visualization.rviz', description='RViz configuration file') + + return LaunchDescription([ + gui_arg, + urdf_file_arg, + package_name_arg, + rviz_config_file_arg, + OpaqueFunction(function=launch_setup) + ]) + +def launch_setup(context, *args, **kwargs): + urdf_file = LaunchConfiguration('urdf_file').perform(context) + package_name = LaunchConfiguration('package_name').perform(context) + rviz_config_file = LaunchConfiguration('rviz_config_file').perform(context) + + # Construct the URDF file path + urdf_file_path = os.path.join( + get_package_share_directory(package_name), + urdf_file + ) + + # Read the URDF file content + with open(urdf_file_path, 'r') as infp: + robot_description = infp.read() + + # Path to the RViz configuration file + rviz_config_file_path = os.path.join( + get_package_share_directory("file_server2"), + 'rviz', + rviz_config_file + ) + + # Read the RViz config file, replace the placeholder with the actual path, and write to a temporary file + with open(rviz_config_file_path, 'r') as infp: + rviz_config_content = infp.read().replace('Description File:', 'Description File: ' + urdf_file_path) + + tmp_rviz_config_file = NamedTemporaryFile(delete=False, suffix='.rviz') + with open(tmp_rviz_config_file.name, 'w') as outfp: + outfp.write(rviz_config_content) + + # Define nodes + joint_state_publisher_node = Node( + package='joint_state_publisher_gui', + executable='joint_state_publisher_gui' + ) + + + robot_state_publisher_node = Node( + package='robot_state_publisher', + executable='robot_state_publisher', + parameters=[{'robot_description': robot_description}] + ) + + rviz_node = Node( + package='rviz2', + executable='rviz2', + name='rviz2', + output='screen', + arguments=['-d', rviz_config_file_path] + ) + + return [ + joint_state_publisher_node, + robot_state_publisher_node, + rviz_node + ] diff --git a/ros2_ws/src/file_server2/package.xml b/ros2_ws/src/file_server2/package.xml new file mode 100644 index 0000000..aabfcde --- /dev/null +++ b/ros2_ws/src/file_server2/package.xml @@ -0,0 +1,34 @@ + + + file_server2 + 1.0.0 + The file server package + + Mehmet Emre Cakal + + Apache License, Version 2.0 + + + + Martin Bischoff + Mehmet Emre Cakal + + + ament_cmake + rosidl_default_generators + + std_msgs + rclcpp + + rosidl_interface_packages + + rosidl_default_runtime + rclcpp + std_msgs + + + + ament_cmake + + + diff --git a/ros2_ws/src/file_server2/rviz/robot_visualization.rviz b/ros2_ws/src/file_server2/rviz/robot_visualization.rviz new file mode 100644 index 0000000..03b0f77 --- /dev/null +++ b/ros2_ws/src/file_server2/rviz/robot_visualization.rviz @@ -0,0 +1,325 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + - /RobotModel1 + - /RobotModel1/Status1 + - /Image1 + - /Image1/Topic1 + Splitter Ratio: 0.5 + Tree Height: 982 + - Class: rviz_common/Selection + Name: Selection + - Class: rviz_common/Tool Properties + Expanded: + - /2D Goal Pose1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz_common/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz_common/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: "" +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Alpha: 1 + Class: rviz_default_plugins/RobotModel + Collision Enabled: false + Description File: + Description Source: File + Description Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: "" + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + box: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + gripper_pole: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + head: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_back_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_base: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_front_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_gripper: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_leg: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_tip: + Alpha: 1 + Show Axes: false + Show Trail: false + right_back_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_base: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_front_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_gripper: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_leg: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_tip: + Alpha: 1 + Show Axes: false + Show Trail: false + Mass Properties: + Inertia: false + Mass: false + Name: RobotModel + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Class: rviz_default_plugins/Image + Enabled: true + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Image + Normalize Range: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /unity/image/compressed + Value: true + - Class: rviz_default_plugins/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: true + base_link: + Value: true + box: + Value: true + gripper_pole: + Value: true + head: + Value: true + left_back_wheel: + Value: true + left_base: + Value: true + left_front_wheel: + Value: true + left_gripper: + Value: true + left_leg: + Value: true + left_tip: + Value: true + right_back_wheel: + Value: true + right_base: + Value: true + right_front_wheel: + Value: true + right_gripper: + Value: true + right_leg: + Value: true + right_tip: + Value: true + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: false + Tree: + base_link: + gripper_pole: + left_gripper: + left_tip: + {} + right_gripper: + right_tip: + {} + head: + box: + {} + left_leg: + left_base: + left_back_wheel: + {} + left_front_wheel: + {} + right_leg: + right_base: + right_back_wheel: + {} + right_front_wheel: + {} + Update Interval: 0 + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: base_link + Frame Rate: 60 + Name: root + Tools: + - Class: rviz_default_plugins/Interact + Hide Inactive Objects: true + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + - Class: rviz_default_plugins/SetInitialPose + Covariance x: 0.25 + Covariance y: 0.25 + Covariance yaw: 0.06853891909122467 + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /initialpose + - Class: rviz_default_plugins/SetGoal + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /goal_pose + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /clicked_point + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 1.561121940612793 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: -0.09661322832107544 + Y: 0.06589896976947784 + Z: 0.021446451544761658 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.5103980898857117 + Target Frame: + Value: Orbit (rviz) + Yaw: 0.785398006439209 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 2055 + Hide Left Dock: false + Hide Right Dock: false + Image: + collapsed: false + QMainWindow State: 000000ff00000000fd0000000400000000000003840000076dfc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b0000045f000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a0049006d00610067006501000004a0000003080000002800fffffffb0000000c00430061006d0065007200610000000233000000bc0000000000000000000000010000010f0000076dfc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b0000076d000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e1000001970000000300000ef40000003efc0100000002fb0000000800540069006d0065010000000000000ef40000025300fffffffb0000000800540069006d0065010000000000000450000000000000000000000a550000076d00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 3828 + X: 3840 + Y: 0 diff --git a/ros2_ws/src/file_server2/src/file_server.cpp b/ros2_ws/src/file_server2/src/file_server.cpp new file mode 100644 index 0000000..2407adc --- /dev/null +++ b/ros2_ws/src/file_server2/src/file_server.cpp @@ -0,0 +1,176 @@ +/* +© Siemens AG, 2017-2018 +Author: Dr. Martin Bischoff (martin.bischoff@siemens.com) + +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 +. +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. + +- Added ROS2 support. +- Added mutex and lock guards to make the save_file_callback thread-safe. + (C) Siemens AG, 2024, Mehmet Emre Cakal (emre.cakal@siemens.com/m.emrecakal@gmail.com) +*/ + +#include +#include +#include "file_server2/srv/get_binary_file.hpp" +#include "file_server2/srv/save_binary_file.hpp" +#include +#include +#include +#include +#include +#include + +using namespace std::placeholders; + +class FileServerNode : public rclcpp::Node +{ +public: + FileServerNode() : Node("file_server") + { + get_file_service_ = this->create_service( + "/file_server/get_file", + std::bind(&FileServerNode::get_file_callback, this, _1, _2)); + + save_file_service_ = this->create_service( + "/file_server/save_file", + std::bind(&FileServerNode::save_file_callback, this, _1, _2)); + + RCLCPP_INFO(this->get_logger(), "ROS2 File Server initialized."); + } + +private: + void get_file_callback( + const std::shared_ptr request, + std::shared_ptr response) + { + if (request->name.compare(0, 10, "package://") != 0) + { + RCLCPP_INFO(this->get_logger(), "Only \"package://\" addresses allowed."); + return; + } + + std::string address = request->name.substr(10); + std::string package = address.substr(0, address.find("/")); + std::string filepath = address.substr(package.length()); + std::string directory = ament_index_cpp::get_package_share_directory(package); + directory += filepath; + + std::ifstream inputfile(directory.c_str(), std::ios::binary); + if (!inputfile.is_open()) + { + RCLCPP_INFO(this->get_logger(), "File \"%s\" not found.", request->name.c_str()); + return; + } + + response->value.assign( + std::istreambuf_iterator(inputfile), + std::istreambuf_iterator()); + + RCLCPP_INFO(this->get_logger(), "get_file request: %s", request->name.c_str()); + } + + void create_directories(const std::string& packagePath, const std::string& filePath) + { + if (filePath.empty()) + { + return; + } + + create_directories(packagePath, filePath.substr(0, filePath.find_last_of("/"))); + + struct stat sb; + if (!(stat((packagePath + filePath).c_str(), &sb) == 0 && S_ISDIR(sb.st_mode))) + { + mkdir((packagePath + filePath).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + } + } + + std::string generate_ros_package(const std::string& packageName) + { + std::string package_share_dir = ament_index_cpp::get_package_share_directory(packageName); + std::string directory = package_share_dir; + + std::string packageXmlContents = "\n\n " + packageName + "\n 0.0.0\n The " + packageName + " package\n\n Ros#\n\n Apache 2.0\n\n ament_cmake\n rclcpp\n rclcpp\n\n \n \n"; + + std::ofstream xmlfile(directory + "/package.xml", std::ios::out | std::ios::binary); + xmlfile << packageXmlContents; + xmlfile.close(); + + std::string cmakelist_content = "cmake_minimum_required(VERSION 3.5)\nproject(" + packageName + ")\n\nfind_package(ament_cmake REQUIRED)\nfind_package(rclcpp REQUIRED)\n\nadd_executable(" + packageName + "_node src/" + packageName + "_node.cpp)\nament_target_dependencies(" + packageName + "_node rclcpp)\n\ninstall(TARGETS " + packageName + "_node\n DESTINATION lib/" + packageName + ")\n\nament_package()"; + + std::ofstream cmakefile(directory + "/CMakeLists.txt", std::ios::out | std::ios::binary); + cmakefile << cmakelist_content; + cmakefile.close(); + + return directory; + } + + void save_file_callback( + const std::shared_ptr request, + std::shared_ptr response) + { + std::lock_guard guard(save_file_mutex_); + + RCLCPP_INFO(this->get_logger(), "save_file request: %s", request->name.c_str()); + + if (request->name.compare(0, 10, "package://") != 0) + { + RCLCPP_INFO(this->get_logger(), "Only \"package://\" addresses allowed."); + return; + } + + std::string address = request->name.substr(10); + std::string package = address.substr(0, address.find("/")); + std::string filepath = address.substr(package.length()); + std::string directory; + + try { + directory = ament_index_cpp::get_package_share_directory(package); + } catch (const std::exception &e) { + RCLCPP_INFO(this->get_logger(), "Package \"%s\" not found. Creating a new package.", package.c_str()); + directory = generate_ros_package(package); + } + + create_directories(directory, filepath.substr(0, filepath.find_last_of("/"))); + directory += filepath; + + std::ofstream file_to_save(directory.c_str(), std::ios::binary); + if (!file_to_save.is_open()) + { + RCLCPP_ERROR(this->get_logger(), "Failed to open file: %s", directory.c_str()); + return; + } + + file_to_save.write(reinterpret_cast(request->value.data()), request->value.size()); + file_to_save.close(); + + response->name = request->name; + + RCLCPP_INFO(this->get_logger(), "save_file request completed: %s", request->name.c_str()); + } + + rclcpp::Service::SharedPtr get_file_service_; + rclcpp::Service::SharedPtr save_file_service_; + std::mutex save_file_mutex_; +}; + +int main(int argc, char **argv) +{ + rclcpp::init(argc, argv); + + auto node = std::make_shared(); + rclcpp::executors::MultiThreadedExecutor executor; + executor.add_node(node); + executor.spin(); + + rclcpp::shutdown(); + return 0; +} diff --git a/ros2_ws/src/file_server2/srv/GetBinaryFile.srv b/ros2_ws/src/file_server2/srv/GetBinaryFile.srv new file mode 100644 index 0000000..a6a8f7b --- /dev/null +++ b/ros2_ws/src/file_server2/srv/GetBinaryFile.srv @@ -0,0 +1,4 @@ +string name +--- +uint8[] value + diff --git a/ros2_ws/src/file_server2/srv/SaveBinaryFile.srv b/ros2_ws/src/file_server2/srv/SaveBinaryFile.srv new file mode 100644 index 0000000..66118f4 --- /dev/null +++ b/ros2_ws/src/file_server2/srv/SaveBinaryFile.srv @@ -0,0 +1,4 @@ +string name +uint8[] value +--- +string name diff --git a/ros2_ws/src/file_server2/urdf/custom_r2d2.urdf b/ros2_ws/src/file_server2/urdf/custom_r2d2.urdf new file mode 100644 index 0000000..83c92f9 --- /dev/null +++ b/ros2_ws/src/file_server2/urdf/custom_r2d2.urdf @@ -0,0 +1,513 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + head_swivel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + left_front_wheel_joint + left_back_wheel_joint + right_front_wheel_joint + right_back_wheel_joint + 0.44 + 0.035 + 1 + -1 + 2 + -2 + 10 + -10 + 10 + -10 + /model/r2d2/odometry_estimate_dont_use + + + + + + + head_swivel + + + + + + + + 1.547 + + 320 + 240 + + + 0.1 + 100 + + + 1 + 30 + true + camera + + + + + ogre2 + + + + + + + + + + + + + + 3 + /model/r2d2/odometry + + + + + diff --git a/ros2_ws/src/gazebo_simulation_scene2/LICENSE b/ros2_ws/src/gazebo_simulation_scene2/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/LICENSE @@ -0,0 +1,202 @@ + + 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/ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge.yaml b/ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge.yaml new file mode 100644 index 0000000..b3b1175 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge.yaml @@ -0,0 +1,54 @@ +--- +- ros_topic_name: "/model/r2d2/cmd_vel" + gz_topic_name: "/model/r2d2/cmd_vel" + ros_type_name: "geometry_msgs/msg/Twist" + gz_type_name: "ignition.msgs.Twist" + direction: ROS_TO_GZ + +- ros_topic_name: "/clock" + gz_topic_name: "/clock" + ros_type_name: "rosgraph_msgs/msg/Clock" + gz_type_name: "ignition.msgs.Clock" + direction: GZ_TO_ROS + +- ros_topic_name: "/model/r2d2/odometry" + gz_topic_name: "/model/r2d2/odometry" + ros_type_name: "nav_msgs/msg/Odometry" + gz_type_name: "ignition.msgs.Odometry" + direction: GZ_TO_ROS + qos: + reliability: "best_effort" # or "reliable" + durability: "transient_local" # or "volatile" + history: "keep_last" + depth: 10 + +- ros_topic_name: "/model/r2d2/joint_state" + gz_topic_name: "/world/gazebo_simulation_scene2_world/model/r2d2/joint_state" + ros_type_name: "sensor_msgs/msg/JointState" + gz_type_name: "ignition.msgs.Model" + direction: GZ_TO_ROS + +- ros_topic_name: "/model/r2d2/tf" + gz_topic_name: "/model/r2d2/tf" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "ignition.msgs.Pose_V" + direction: GZ_TO_ROS + +- ros_topic_name: "/model/r2d2/pose_static" + gz_topic_name: "/model/r2d2/pose_static" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "ignition.msgs.Pose_V" + direction: GZ_TO_ROS + +# Instead of using the following, we will use the image_bridge node from ros_gz_image package with "camera" parameter +# - ros_topic_name: "/camera" +# gz_topic_name: "/camera" +# ros_type_name: "sensor_msgs/msg/Image" +# gz_type_name: "ignition.msgs.Image" +# direction: GZ_TO_ROS + +# - ros_topic_name: "/camera_info" +# gz_topic_name: "camera_info" +# ros_type_name: "sensor_msgs/msg/CameraInfo" +# gz_type_name: "ignition.msgs.CameraInfo" +# direction: GZ_TO_ROS diff --git a/ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge_effort.yaml b/ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge_effort.yaml new file mode 100644 index 0000000..fa1a698 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/config/gazebo_bridge_effort.yaml @@ -0,0 +1,57 @@ +--- +- ros_topic_name: "/model/r2d2/cmd_vel" + gz_topic_name: "/model/r2d2/cmd_vel" + ros_type_name: "geometry_msgs/msg/Twist" + gz_type_name: "ignition.msgs.Twist" + direction: ROS_TO_GZ + qos: + reliability: "best_effort" # or "reliable" + durability: "transient_local" # or "volatile" + history: "keep_last" + depth: 10 + +- ros_topic_name: "/clock" + gz_topic_name: "/clock" + ros_type_name: "rosgraph_msgs/msg/Clock" + gz_type_name: "ignition.msgs.Clock" + direction: GZ_TO_ROS + +- ros_topic_name: "/model/r2d2/odometry" + gz_topic_name: "/model/r2d2/odometry" + ros_type_name: "nav_msgs/msg/Odometry" + gz_type_name: "ignition.msgs.Odometry" + direction: GZ_TO_ROS + qos: + reliability: "best_effort" # or "reliable" + durability: "transient_local" # or "volatile" + history: "keep_last" + depth: 10 + +- ros_topic_name: "/model/r2d2/joint_state" + gz_topic_name: "/world/gazebo_simulation_scene2_world/model/r2d2/joint_state" + ros_type_name: "sensor_msgs/msg/JointState" + gz_type_name: "ignition.msgs.Model" + direction: GZ_TO_ROS + +- ros_topic_name: "/model/r2d2/tf" + gz_topic_name: "/model/r2d2/tf" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "ignition.msgs.Pose_V" + direction: GZ_TO_ROS + +- ros_topic_name: "/model/r2d2/pose_static" + gz_topic_name: "/model/r2d2/pose_static" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "ignition.msgs.Pose_V" + direction: GZ_TO_ROS + +- ros_topic_name: "/model/r2d2/joint/head_swivel/cmd_force" + gz_topic_name: "/model/r2d2/joint/head_swivel/cmd_force" + ros_type_name: "std_msgs/msg/Float64" + gz_type_name: "ignition.msgs.Double" + direction: ROS_TO_GZ + qos: + reliability: "best_effort" # or "reliable" + durability: "transient_local" # or "volatile" + history: "keep_last" + depth: 10 \ No newline at end of file diff --git a/ros2_ws/src/gazebo_simulation_scene2/gazebo_simulation_scene2/__init__.py b/ros2_ws/src/gazebo_simulation_scene2/gazebo_simulation_scene2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ros2_ws/src/gazebo_simulation_scene2/gazebo_simulation_scene2/joy_to_twist2.py b/ros2_ws/src/gazebo_simulation_scene2/gazebo_simulation_scene2/joy_to_twist2.py new file mode 100644 index 0000000..ecbcf7d --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/gazebo_simulation_scene2/joy_to_twist2.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com) + +# 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 +# . +# 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 +from rclpy.node import Node +from sensor_msgs.msg import Joy +from geometry_msgs.msg import Twist + +class JoyToTwist(Node): + def __init__(self): + super().__init__('joy_to_twist2') + + # Setup joy topic subscription + self.joy_subscriber = self.create_subscription(Joy, '/joy', self.handle_joy_msg, 10) + + # Setup Twist Publisher + self.twist_publisher = self.create_publisher(Twist, '/model/r2d2/cmd_vel', 10) + + self.scalers = [1.4, 1.4, 1.4, -6.28, -6.28, -6.28] + + + # Initialize the latest Twist message + self.latest_twist = Twist() + + # Initialize a timer to control the publish rate + self.publish_rate = 30 # Hz + self.timer = self.create_timer(1.0 / self.publish_rate, self.publish_latest_twist) + + def handle_joy_msg(self, data): + # self.get_logger().info('Received: %s' % str(data)) + + # Start Mapping from Joy to Twist + if len(data.axes) >= 6: + self.latest_twist.angular.x = data.axes[5] * self.scalers[3] + + if len(data.axes) >= 5: + self.latest_twist.linear.z = data.axes[4] * self.scalers[2] + + if len(data.axes) >= 4: + self.latest_twist.angular.y = data.axes[3] * self.scalers[4] + + if len(data.axes) >= 3: + self.latest_twist.linear.y = data.axes[2] * self.scalers[1] + + if len(data.axes) >= 2: + self.latest_twist.angular.z = data.axes[1] * self.scalers[5] + + if len(data.axes) >= 1: + self.latest_twist.linear.x = data.axes[0] * self.scalers[0] + + def publish_latest_twist(self): + # self.get_logger().info('Publishing: %s' % str(self.latest_twist)) + self.twist_publisher.publish(self.latest_twist) + + def stop_robot(self): + msg = Twist() + self.twist_publisher.publish(msg) + self.get_logger().info('Stopping Robot') + +def main(args=None): + rclpy.init(args=args) + joy_to_twist = JoyToTwist() + + try: + rclpy.spin(joy_to_twist) + except KeyboardInterrupt: + pass + + joy_to_twist.stop_robot() + joy_to_twist.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() diff --git a/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_camera.launch.py b/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_camera.launch.py new file mode 100644 index 0000000..eaa8c64 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_camera.launch.py @@ -0,0 +1,111 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com/m.emrecakal@gmail.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch_ros.actions import Node +from launch.actions import DeclareLaunchArgument, OpaqueFunction, IncludeLaunchDescription, ExecuteProcess +from launch.substitutions import LaunchConfiguration +from launch.launch_description_sources import PythonLaunchDescriptionSource +from ament_index_python.packages import get_package_share_directory +import os +from tempfile import NamedTemporaryFile + +def generate_launch_description(): + # Declare launch arguments + urdf_file_arg = DeclareLaunchArgument('urdf_file', default_value='custom_r2d2.urdf', description='URDF file name') + bridge_config_file_arg = DeclareLaunchArgument('bridge_config_file', default_value='gazebo_bridge.yaml', description='Bridge config file name') + package_name_arg = DeclareLaunchArgument('package_name', default_value='gazebo_simulation_scene2', description='Package name containing URDF file') + gazebo_world_arg = DeclareLaunchArgument('gazebo_world', default_value='gazebo_simulation_scene2_world.sdf', description='Gazebo world file name') + + + return LaunchDescription([ + urdf_file_arg, + bridge_config_file_arg, + package_name_arg, + gazebo_world_arg, + OpaqueFunction(function=launch_setup) + ]) + +def launch_setup(context, *args, **kwargs): + urdf_file = LaunchConfiguration('urdf_file').perform(context) + bridge_config_file = LaunchConfiguration('bridge_config_file').perform(context) + gazebo_world_file = LaunchConfiguration('gazebo_world').perform(context) + package_name = LaunchConfiguration('package_name').perform(context) + + pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim') + pkg_file_server2 = get_package_share_directory('file_server2') + + urdf_file_path = os.path.join( + get_package_share_directory("file_server2"), + "urdf", + urdf_file + ) + + bridge_config_file_path = os.path.join( + get_package_share_directory(package_name), + "config", + bridge_config_file + ) + + gazebo_world_file_path = os.path.join( + get_package_share_directory(package_name), + "worlds", + gazebo_world_file + ) + + # Read the URDF file content + with open(urdf_file_path, 'r') as infp: + robot_description = infp.read() + + # Define nodes + file_server2_node = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py')), + ) + + gazebo_node = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')), + launch_arguments={'gz_args': "-r " + gazebo_world_file_path}.items() + ) + + spawn_entity = Node( + package='ros_ign_gazebo', + executable='create', + output='screen', + arguments=["-file", urdf_file_path, " -z ", "1"] + ) + + gazebo_bridge_node = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + parameters=[{ + 'config_file': bridge_config_file_path + }], + output='screen' + ) + + gazebo_camera_bridge_node = Node( + package='ros_gz_image', + executable='image_bridge', + arguments=["camera"], + output='screen' + ) + + return [ + file_server2_node, + gazebo_node, + spawn_entity, + gazebo_bridge_node, + gazebo_camera_bridge_node + ] \ No newline at end of file diff --git a/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_complete_with_UI.launch.py b/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_complete_with_UI.launch.py new file mode 100644 index 0000000..efb9911 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_complete_with_UI.launch.py @@ -0,0 +1,126 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com/m.emrecakal@gmail.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch_ros.actions import Node +from launch.actions import DeclareLaunchArgument, OpaqueFunction, IncludeLaunchDescription, ExecuteProcess +from launch.substitutions import LaunchConfiguration +from launch.launch_description_sources import PythonLaunchDescriptionSource +from ament_index_python.packages import get_package_share_directory +import os + +def generate_launch_description(): + # Declare launch arguments + urdf_file_arg = DeclareLaunchArgument('urdf_file', default_value='custom_r2d2.urdf', description='URDF file name') + bridge_config_file_arg = DeclareLaunchArgument('bridge_config_file', default_value='gazebo_bridge_effort.yaml', description='Bridge config file name') + package_name_arg = DeclareLaunchArgument('package_name', default_value='gazebo_simulation_scene2', description='Package name containing URDF file') + gazebo_world_arg = DeclareLaunchArgument('gazebo_world', default_value='gazebo_simulation_scene2_world.sdf', description='Gazebo world file name') + + + return LaunchDescription([ + urdf_file_arg, + bridge_config_file_arg, + package_name_arg, + gazebo_world_arg, + OpaqueFunction(function=launch_setup) + ]) + +def launch_setup(context, *args, **kwargs): + urdf_file = LaunchConfiguration('urdf_file').perform(context) + bridge_config_file = LaunchConfiguration('bridge_config_file').perform(context) + gazebo_world_file = LaunchConfiguration('gazebo_world').perform(context) + package_name = LaunchConfiguration('package_name').perform(context) + + pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim') + pkg_file_server2 = get_package_share_directory('file_server2') + + urdf_file_path = os.path.join( + get_package_share_directory("file_server2"), + "urdf", + urdf_file + ) + + bridge_config_file_path = os.path.join( + get_package_share_directory(package_name), + "config", + bridge_config_file + ) + + gazebo_world_file_path = os.path.join( + get_package_share_directory(package_name), + "worlds", + gazebo_world_file + ) + + # Read the URDF file content + with open(urdf_file_path, 'r') as infp: + robot_description = infp.read() + + # Define nodes + file_server2_node = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py')), + ) + + gazebo_node = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')), + launch_arguments={'gz_args': "-r " + gazebo_world_file_path}.items() + ) + + spawn_entity = Node( + package='ros_ign_gazebo', + executable='create', + output='screen', + arguments=["-file", urdf_file_path, " -z ", "1"] + ) + + gazebo_bridge_node = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + parameters=[{ + 'config_file': bridge_config_file_path + }], + output='screen' + ) + + gazebo_camera_bridge_node = Node( + package='ros_gz_image', + executable='image_bridge', + arguments=["camera"], + output='screen', + parameters=[ + {'use_sim_time': True}, + {'qos_overrides./camera/compressed.depth': 10}, + {'qos_overrides./camera/compressed.reliability': 'best_effort'}, + {'qos_overrides./camera/compressed.durability': 'volatile'}, + {'qos_overrides./camera.depth': 10}, + {'qos_overrides./camera.reliability': 'best_effort'}, + {'qos_overrides./camera.durability': 'volatile'} + ], + ) + + joy_to_twist2_node = Node( + package='gazebo_simulation_scene2', + executable='joy_to_twist2', + output='screen' + ) + + return [ + file_server2_node, + gazebo_node, + spawn_entity, + gazebo_bridge_node, + gazebo_camera_bridge_node, + joy_to_twist2_node + ] diff --git a/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_diff_drive.launch.py b/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_diff_drive.launch.py new file mode 100644 index 0000000..d5ed089 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/launch/gazebo_simulation_scene_diff_drive.launch.py @@ -0,0 +1,119 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com/m.emrecakal@gmail.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch_ros.actions import Node +from launch.actions import DeclareLaunchArgument, OpaqueFunction, IncludeLaunchDescription, ExecuteProcess +from launch.substitutions import LaunchConfiguration +from launch.launch_description_sources import PythonLaunchDescriptionSource +from ament_index_python.packages import get_package_share_directory +import os +from tempfile import NamedTemporaryFile + +def generate_launch_description(): + # Declare launch arguments + urdf_file_arg = DeclareLaunchArgument('urdf_file', default_value='custom_r2d2.urdf', description='URDF file name') + bridge_config_file_arg = DeclareLaunchArgument('bridge_config_file', default_value='gazebo_bridge.yaml', description='Bridge config file name') + package_name_arg = DeclareLaunchArgument('package_name', default_value='gazebo_simulation_scene2', description='Package name containing URDF file') + gazebo_world_arg = DeclareLaunchArgument('gazebo_world', default_value='gazebo_simulation_scene2_world.sdf', description='Gazebo world file name') + + + return LaunchDescription([ + urdf_file_arg, + bridge_config_file_arg, + package_name_arg, + gazebo_world_arg, + OpaqueFunction(function=launch_setup) + ]) + +def launch_setup(context, *args, **kwargs): + urdf_file = LaunchConfiguration('urdf_file').perform(context) + bridge_config_file = LaunchConfiguration('bridge_config_file').perform(context) + gazebo_world_file = LaunchConfiguration('gazebo_world').perform(context) + package_name = LaunchConfiguration('package_name').perform(context) + + pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim') + pkg_file_server2 = get_package_share_directory('file_server2') + + urdf_file_path = os.path.join( + get_package_share_directory("file_server2"), + "urdf", + urdf_file + ) + + bridge_config_file_path = os.path.join( + get_package_share_directory(package_name), + "config", + bridge_config_file + ) + + gazebo_world_file_path = os.path.join( + get_package_share_directory(package_name), + "worlds", + gazebo_world_file + ) + + # Read the URDF file content + with open(urdf_file_path, 'r') as infp: + robot_description = infp.read() + + # Define nodes + file_server2_node = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py')), + ) + + gazebo_node = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')), + launch_arguments={'gz_args': "-r " + gazebo_world_file_path}.items() + ) + + spawn_entity = Node( + package='ros_ign_gazebo', + executable='create', + output='screen', + arguments=["-file", urdf_file_path, " -z ", "1"] + ) + + gazebo_bridge_node = Node( + package='ros_gz_bridge', + executable='parameter_bridge', + parameters=[{ + 'config_file': bridge_config_file_path + }], + output='screen' + ) + + gazebo_camera_bridge_node = Node( + package='ros_gz_image', + executable='image_bridge', + arguments=["camera"], + output='screen' + ) + + joy_to_twist2_node = Node( + package='gazebo_simulation_scene2', + executable='joy_to_twist2', + output='screen' + ) + + return [ + file_server2_node, + gazebo_node, + spawn_entity, + gazebo_bridge_node, + gazebo_camera_bridge_node, + joy_to_twist2_node + ] + diff --git a/ros2_ws/src/gazebo_simulation_scene2/package.xml b/ros2_ws/src/gazebo_simulation_scene2/package.xml new file mode 100644 index 0000000..310be8d --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/package.xml @@ -0,0 +1,20 @@ + + + + gazebo_simulation_scene2 + 1.0.0 + Gazebo simulation example scenes + emrehp + Apache-2.0 + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + ros_ign_gazebo + robot_state_publisher + + + ament_python + + diff --git a/ros2_ws/src/gazebo_simulation_scene2/resource/gazebo_simulation_scene2 b/ros2_ws/src/gazebo_simulation_scene2/resource/gazebo_simulation_scene2 new file mode 100644 index 0000000..e69de29 diff --git a/ros2_ws/src/gazebo_simulation_scene2/setup.cfg b/ros2_ws/src/gazebo_simulation_scene2/setup.cfg new file mode 100644 index 0000000..0b68df1 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/gazebo_simulation_scene2 +[install] +install_scripts=$base/lib/gazebo_simulation_scene2 diff --git a/ros2_ws/src/gazebo_simulation_scene2/setup.py b/ros2_ws/src/gazebo_simulation_scene2/setup.py new file mode 100644 index 0000000..6f0ae97 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/setup.py @@ -0,0 +1,32 @@ +from setuptools import find_packages, setup +from glob import glob +from os import path + +package_name = 'gazebo_simulation_scene2' + +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']), + (path.join('share', package_name, 'launch'), glob('launch/*.launch.py')), + (path.join('share', package_name, 'urdf'), glob('urdf/*.urdf')), + (path.join('share', package_name, 'config'), glob('config/*.yaml')), + (path.join('share', package_name, 'worlds'), glob('worlds/*.sdf')), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='Mehmet Emre Cakal', + maintainer_email='emre.cakal@siemens.com', + description='TODO: Package description', + license='Apache-2.0', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'joy_to_twist2 = gazebo_simulation_scene2.joy_to_twist2:main', + ], + }, +) diff --git a/ros2_ws/src/gazebo_simulation_scene2/test/test_copyright.py b/ros2_ws/src/gazebo_simulation_scene2/test/test_copyright.py new file mode 100644 index 0000000..97a3919 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/test/test_copyright.py @@ -0,0 +1,25 @@ +# Copyright 2015 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 ament_copyright.main import main +import pytest + + +# Remove the `skip` decorator once the source file(s) have a copyright header +@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/ros2_ws/src/gazebo_simulation_scene2/test/test_flake8.py b/ros2_ws/src/gazebo_simulation_scene2/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 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 ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/ros2_ws/src/gazebo_simulation_scene2/test/test_pep257.py b/ros2_ws/src/gazebo_simulation_scene2/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 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 ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/ros2_ws/src/gazebo_simulation_scene2/worlds/gazebo_simulation_scene2_world.sdf b/ros2_ws/src/gazebo_simulation_scene2/worlds/gazebo_simulation_scene2_world.sdf new file mode 100644 index 0000000..83220e4 --- /dev/null +++ b/ros2_ws/src/gazebo_simulation_scene2/worlds/gazebo_simulation_scene2_world.sdf @@ -0,0 +1,296 @@ + + + + + + 0.001 + 1.0 + + + + + ogre2 + + + + + + + + 1.0 1.0 1.0 + 0.8 0.8 0.8 + true + + + + + + + + 3D View + false + docked + + + ogre2 + scene + 0.4 0.4 0.4 + 0.8 0.8 0.8 + -6 0 6 0 0.5 0 + + + + + + floating + 5 + 5 + false + + + + + false + 5 + 5 + floating + false + + + + + false + 5 + 5 + floating + false + + + + + false + 5 + 5 + floating + false + + + + + + World control + false + false + 72 + 1 + + floating + + + + + + + true + true + true + true + + + + + + + World stats + false + false + 110 + 290 + 1 + + floating + + + + + + + true + true + true + true + + + + + docked + + camera + + + + + + docked + + + + + + + docked + + + + + + true + 0 0 10 0 0 0 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + 1000 + 0.9 + 0.01 + 0.001 + + -0.5 0.1 -0.9 + + + + true + + + + + 0 0 1 + 100 100 + + + + + + + 0 0 1 + 100 100 + + + + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + + + + + + 0 -1 0.5 0 0 0 + + + + 1 + 0 + 0 + 1 + 0 + 1 + + 1.0 + + + + + 1 1 1 + + + + + + + + 1 1 1 + + + + 1 0 0 1 + 1 0 0 1 + 1 0 0 1 + + + + + + + 0 3 0.5 0 0 0.3 + + + + 1 + 0 + 0 + 1 + 0 + 1 + + 1.0 + + + + + 1 1 1 + + + + + + + + 1 1 1 + + + + 0 0 1 1 + 0 0 1 1 + 0 0 1 1 + + + + + + + true + 3 0 0.5 0 0 0 + + + + + 0.125 + + + + + + + 0.125 + + + + 0 1 0 1 + 0 1 0 1 + 0 1 0 1 + + false + + + + + \ No newline at end of file diff --git a/ros2_ws/src/kobuki_core b/ros2_ws/src/kobuki_core new file mode 160000 index 0000000..3e0652d --- /dev/null +++ b/ros2_ws/src/kobuki_core @@ -0,0 +1 @@ +Subproject commit 3e0652dc4006d8345a86298ac05d82049747bc7f diff --git a/ros2_ws/src/kobuki_ros b/ros2_ws/src/kobuki_ros new file mode 160000 index 0000000..e1fbf7b --- /dev/null +++ b/ros2_ws/src/kobuki_ros @@ -0,0 +1 @@ +Subproject commit e1fbf7bdec199411008bd7c94c6e4b7d82903347 diff --git a/ros2_ws/src/kobuki_ros_interfaces b/ros2_ws/src/kobuki_ros_interfaces new file mode 160000 index 0000000..7711d4f --- /dev/null +++ b/ros2_ws/src/kobuki_ros_interfaces @@ -0,0 +1 @@ +Subproject commit 7711d4fbec13c69bcf6477ce8e446c3ccca33113 diff --git a/ros2_ws/src/piper_ros b/ros2_ws/src/piper_ros new file mode 160000 index 0000000..4de4f69 --- /dev/null +++ b/ros2_ws/src/piper_ros @@ -0,0 +1 @@ +Subproject commit 4de4f69ca44dda6cf8dc2ff3bcab0a973524f72d diff --git a/ros2_ws/src/unity_simulation_scene2/LICENSE b/ros2_ws/src/unity_simulation_scene2/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/LICENSE @@ -0,0 +1,202 @@ + + 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/ros2_ws/src/unity_simulation_scene2/launch/unity_simulation_scene.launch.py b/ros2_ws/src/unity_simulation_scene2/launch/unity_simulation_scene.launch.py new file mode 100644 index 0000000..44f687d --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/launch/unity_simulation_scene.launch.py @@ -0,0 +1,52 @@ +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com) + +# 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 +# . +# 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 launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch_ros.actions import Node +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Define launch arguments + port_arg = DeclareLaunchArgument('port', default_value='9090', description='Port number for ROS communication') + + # Define paths + pkg_file_server2 = get_package_share_directory('file_server2') + rosbridge_server_launch_file = PathJoinSubstitution( + [pkg_file_server2, 'launch', 'ros_sharp_communication.launch.py']) + + # Include ROS Sharp Communication launch file + ros_sharp_communication_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([rosbridge_server_launch_file]), + launch_arguments=[('port', LaunchConfiguration('port'))] + ) + + + return LaunchDescription([ + port_arg, + ros_sharp_communication_launch, + Node( + package='unity_simulation_scene2', + executable='mouse_to_joy2', + output='screen' + ), + Node( + package='rqt_graph', + executable='rqt_graph', + name='rqt_graph', + output='screen' + ) + ]) + diff --git a/ros2_ws/src/unity_simulation_scene2/package.xml b/ros2_ws/src/unity_simulation_scene2/package.xml new file mode 100644 index 0000000..d06888a --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/package.xml @@ -0,0 +1,26 @@ + + + + unity_simulation_scene2 + 1.0.0 + Unity Simulation Scene Package + + Mehmet Emre Cakal + + Apache License, Version 2.0 + + launch + launch_ros + rclpy + sensor_msgs + tkinter + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/ros2_ws/src/unity_simulation_scene2/resource/unity_simulation_scene2 b/ros2_ws/src/unity_simulation_scene2/resource/unity_simulation_scene2 new file mode 100644 index 0000000..e69de29 diff --git a/ros2_ws/src/unity_simulation_scene2/setup.cfg b/ros2_ws/src/unity_simulation_scene2/setup.cfg new file mode 100644 index 0000000..a101d5d --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/unity_simulation_scene2 +[install] +install_scripts=$base/lib/unity_simulation_scene2 diff --git a/ros2_ws/src/unity_simulation_scene2/setup.py b/ros2_ws/src/unity_simulation_scene2/setup.py new file mode 100644 index 0000000..8d9f7d0 --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/setup.py @@ -0,0 +1,29 @@ +from setuptools import find_packages, setup +from glob import glob +import os + +package_name = 'unity_simulation_scene2' + +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('launch/*.launch.py')), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='Mehmet Emre Cakal', + maintainer_email='emre.cakal@siemens.com', + description='Unity Simulation Package', + license='Apache-2.0', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'mouse_to_joy2 = unity_simulation_scene2.mouse_to_joy2:main' + ], + }, +) diff --git a/ros2_ws/src/unity_simulation_scene2/test/test_copyright.py b/ros2_ws/src/unity_simulation_scene2/test/test_copyright.py new file mode 100644 index 0000000..97a3919 --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/test/test_copyright.py @@ -0,0 +1,25 @@ +# Copyright 2015 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 ament_copyright.main import main +import pytest + + +# Remove the `skip` decorator once the source file(s) have a copyright header +@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/ros2_ws/src/unity_simulation_scene2/test/test_flake8.py b/ros2_ws/src/unity_simulation_scene2/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 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 ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/ros2_ws/src/unity_simulation_scene2/test/test_pep257.py b/ros2_ws/src/unity_simulation_scene2/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 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 ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/ros2_ws/src/unity_simulation_scene2/unity_simulation_scene2/__init__.py b/ros2_ws/src/unity_simulation_scene2/unity_simulation_scene2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ros2_ws/src/unity_simulation_scene2/unity_simulation_scene2/mouse_to_joy2.py b/ros2_ws/src/unity_simulation_scene2/unity_simulation_scene2/mouse_to_joy2.py new file mode 100644 index 0000000..f572099 --- /dev/null +++ b/ros2_ws/src/unity_simulation_scene2/unity_simulation_scene2/mouse_to_joy2.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 + +# © Siemens AG, 2024 +# Author: Mehmet Emre Cakal (emre.cakal@siemens.com) + +# 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 +# . +# 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 +from rclpy.node import Node +from sensor_msgs.msg import Joy +import tkinter as tk + +class MouseToJoy(Node): + def __init__(self): + super().__init__('mouse_to_joy2') + + self.msg_period = 33 + + # Setup MouseToJoy Publisher + self.mouse_to_joy_publisher = self.create_publisher(Joy, 'joy', self.msg_period) + + # Initialize axes values + self.vel_linear = 0.0 + self.vel_angular = 0.0 + + # Initialize Tkinter window + self.root = tk.Tk() + self.root.title('Mouse to Joy') + self.root.geometry('800x800') + self.root.resizable(False, False) + + # Main frame + self.main_frame = tk.Frame(self.root, width=800, height=800, bg="#ffffff") + self.main_frame.pack_propagate(False) + self.main_frame.pack() + + # Text labels + move_label = tk.Label(self.main_frame, text='Move your cursor here!', font=('Helvetica', 22), bg="#ffffff") + move_label.place(relx=0.5, rely=0.5, anchor='center') + + ros_label = tk.Label(self.main_frame, text='ROS#', font=('Helvetica', 18), bg="#ffffff") + ros_label.place(relx=0.02, rely=0.98, anchor='sw') + + siemens_label = tk.Label(self.main_frame, text='Siemens', font=('Helvetica', 18), fg="#009999", bg="#ffffff") + siemens_label.place(relx=0.98, rely=0.98, anchor='se') + + # Canvas + self.main_frame.bind('', self.on_mouse_motion) + + # Schedule periodic callback for publishing Joy messages + self.publish_joy_message() + + # Start Tkinter main loop (thread) + self.root.mainloop() + + def on_mouse_motion(self, event): + # Convert mouse position to velocity + canvas_width = self.main_frame.winfo_width() + canvas_height = self.main_frame.winfo_height() + self.vel_linear = (event.y - canvas_height / 2) / (canvas_height / 2) + self.vel_angular = (event.x - canvas_width / 2) / (canvas_width / 2) + + def publish_joy_message(self): + # Publish Joy message based on current mouse position + msg = Joy() + msg.axes = [self.vel_linear, self.vel_angular] + msg.buttons = [] + + # Log and Publish + self.get_logger().info(f'Joy message: {msg}') + self.mouse_to_joy_publisher.publish(msg) + + # Schedule next callback + self.root.after(self.msg_period, self.publish_joy_message) + +def main(args=None): + rclpy.init(args=args) + node = MouseToJoy() + try: + rclpy.spin(node) + except KeyboardInterrupt: + pass + finally: + if node.root: + node.root.destroy() + node.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() diff --git a/ros2_ws/src/urdf_export_test/LICENSE b/ros2_ws/src/urdf_export_test/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/ros2_ws/src/urdf_export_test/LICENSE @@ -0,0 +1,202 @@ + + 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/ros2_ws/src/urdf_export_test/package.xml b/ros2_ws/src/urdf_export_test/package.xml new file mode 100644 index 0000000..c8cdd6e --- /dev/null +++ b/ros2_ws/src/urdf_export_test/package.xml @@ -0,0 +1,18 @@ + + + + urdf_export_test + 0.0.0 + TODO: Package description + dennis + Apache-2.0 + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/ros2_ws/src/urdf_export_test/resource/urdf_export_test b/ros2_ws/src/urdf_export_test/resource/urdf_export_test new file mode 100644 index 0000000..e69de29 diff --git a/ros2_ws/src/urdf_export_test/setup.cfg b/ros2_ws/src/urdf_export_test/setup.cfg new file mode 100644 index 0000000..c8e86d9 --- /dev/null +++ b/ros2_ws/src/urdf_export_test/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/urdf_export_test +[install] +install_scripts=$base/lib/urdf_export_test diff --git a/ros2_ws/src/urdf_export_test/setup.py b/ros2_ws/src/urdf_export_test/setup.py new file mode 100644 index 0000000..8f94bcb --- /dev/null +++ b/ros2_ws/src/urdf_export_test/setup.py @@ -0,0 +1,29 @@ +from setuptools import find_packages, setup + +package_name = 'urdf_export_test' + +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']), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='dennis', + maintainer_email='dennis@todo.todo', + description='TODO: Package description', + license='Apache-2.0', + extras_require={ + 'test': [ + 'pytest', + ], + }, + entry_points={ + 'console_scripts': [ + ], + }, +) diff --git a/ros2_ws/src/urdf_export_test/test/test_copyright.py b/ros2_ws/src/urdf_export_test/test/test_copyright.py new file mode 100644 index 0000000..97a3919 --- /dev/null +++ b/ros2_ws/src/urdf_export_test/test/test_copyright.py @@ -0,0 +1,25 @@ +# Copyright 2015 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 ament_copyright.main import main +import pytest + + +# Remove the `skip` decorator once the source file(s) have a copyright header +@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/ros2_ws/src/urdf_export_test/test/test_flake8.py b/ros2_ws/src/urdf_export_test/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/ros2_ws/src/urdf_export_test/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 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 ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/ros2_ws/src/urdf_export_test/test/test_pep257.py b/ros2_ws/src/urdf_export_test/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/ros2_ws/src/urdf_export_test/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 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 ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/ros2_ws/src/urdf_export_test/urdf_export_test/__init__.py b/ros2_ws/src/urdf_export_test/urdf_export_test/__init__.py new file mode 100644 index 0000000..e69de29