Added ROS2 packages (without submodule references)
This commit is contained in:
Submodule
+1
Submodule ros2_ws/src/cmd_vel_mux added at bf9f4ce6eb
Submodule
+1
Submodule ros2_ws/src/ecl_core added at 7bcdf80423
Submodule
+1
Submodule ros2_ws/src/ecl_lite added at f9b8aa04c9
@@ -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()
|
||||
@@ -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.
|
||||
@@ -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
|
||||
])
|
||||
@@ -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
|
||||
# <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 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
|
||||
])
|
||||
|
||||
@@ -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
|
||||
])
|
||||
@@ -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
|
||||
# <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 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
|
||||
])
|
||||
|
||||
@@ -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
|
||||
# <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 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
|
||||
])
|
||||
|
||||
@@ -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
|
||||
# <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 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'
|
||||
)
|
||||
|
||||
])
|
||||
|
||||
@@ -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
|
||||
# <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 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
|
||||
]
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<package format="3">
|
||||
<name>file_server2</name>
|
||||
<version>1.0.0</version>
|
||||
<description>The file server package</description>
|
||||
|
||||
<maintainer email="emre.cakal@siemens.com">Mehmet Emre Cakal</maintainer>
|
||||
|
||||
<license>Apache License, Version 2.0</license>
|
||||
|
||||
<!-- No URL tags included -->
|
||||
|
||||
<author email="martin.bischoff@siemens.com">Martin Bischoff</author>
|
||||
<author email="emre.cakal@siemens.com">Mehmet Emre Cakal</author>
|
||||
|
||||
<!-- Dependencies -->
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
<buildtool_depend>rosidl_default_generators</buildtool_depend>
|
||||
|
||||
<build_depend>std_msgs</build_depend>
|
||||
<build_depend>rclcpp</build_depend>
|
||||
|
||||
<member_of_group>rosidl_interface_packages</member_of_group>
|
||||
|
||||
<exec_depend>rosidl_default_runtime</exec_depend>
|
||||
<exec_depend>rclcpp</exec_depend>
|
||||
<exec_depend>std_msgs</exec_depend>
|
||||
|
||||
<!-- export tags -->
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
|
||||
</package>
|
||||
@@ -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: <Fixed 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: <Fixed 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
|
||||
@@ -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
|
||||
<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.
|
||||
|
||||
- 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 <rclcpp/rclcpp.hpp>
|
||||
#include <ament_index_cpp/get_package_share_directory.hpp>
|
||||
#include "file_server2/srv/get_binary_file.hpp"
|
||||
#include "file_server2/srv/save_binary_file.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
class FileServerNode : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
FileServerNode() : Node("file_server")
|
||||
{
|
||||
get_file_service_ = this->create_service<file_server2::srv::GetBinaryFile>(
|
||||
"/file_server/get_file",
|
||||
std::bind(&FileServerNode::get_file_callback, this, _1, _2));
|
||||
|
||||
save_file_service_ = this->create_service<file_server2::srv::SaveBinaryFile>(
|
||||
"/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<file_server2::srv::GetBinaryFile::Request> request,
|
||||
std::shared_ptr<file_server2::srv::GetBinaryFile::Response> 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<char>(inputfile),
|
||||
std::istreambuf_iterator<char>());
|
||||
|
||||
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 = "<?xml version=\"1.0\"?>\n<package format=\"2\">\n <name>" + packageName + "</name>\n <version>0.0.0</version>\n <description>The " + packageName + " package</description>\n\n <maintainer email=\"ros-sharp.ct@siemens.com\">Ros#</maintainer>\n\n <license>Apache 2.0</license>\n\n <buildtool_depend>ament_cmake</buildtool_depend>\n <build_depend>rclcpp</build_depend>\n <exec_depend>rclcpp</exec_depend>\n\n <export>\n </export>\n</package>";
|
||||
|
||||
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<file_server2::srv::SaveBinaryFile::Request> request,
|
||||
std::shared_ptr<file_server2::srv::SaveBinaryFile::Response> response)
|
||||
{
|
||||
std::lock_guard<std::mutex> 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<const char*>(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<file_server2::srv::GetBinaryFile>::SharedPtr get_file_service_;
|
||||
rclcpp::Service<file_server2::srv::SaveBinaryFile>::SharedPtr save_file_service_;
|
||||
std::mutex save_file_mutex_;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
|
||||
auto node = std::make_shared<FileServerNode>();
|
||||
rclcpp::executors::MultiThreadedExecutor executor;
|
||||
executor.add_node(node);
|
||||
executor.spin();
|
||||
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
string name
|
||||
---
|
||||
uint8[] value
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
string name
|
||||
uint8[] value
|
||||
---
|
||||
string name
|
||||
@@ -0,0 +1,513 @@
|
||||
<?xml version="1.0"?>
|
||||
<robot name="r2d2">
|
||||
|
||||
<material name="blue">
|
||||
<color rgba="0 0 0.8 1"/>
|
||||
</material>
|
||||
<material name="black">
|
||||
<color rgba="0 0 0 1"/>
|
||||
</material>
|
||||
<material name="white">
|
||||
<color rgba="1 1 1 1"/>
|
||||
</material>
|
||||
|
||||
<link name="base_link">
|
||||
<visual>
|
||||
<geometry>
|
||||
<cylinder length="0.6" radius="0.2"/>
|
||||
</geometry>
|
||||
<material name="blue"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<cylinder length="0.6" radius="0.2"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="5"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<link name="right_leg">
|
||||
<visual>
|
||||
<geometry>
|
||||
<box size="0.6 0.1 0.2"/>
|
||||
</geometry>
|
||||
<origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
|
||||
<material name="white"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<box size="0.6 0.1 0.2"/>
|
||||
</geometry>
|
||||
<origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="1"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
<joint name="base_to_right_leg" type="fixed">
|
||||
<parent link="base_link"/>
|
||||
<child link="right_leg"/>
|
||||
<origin xyz="0 -0.22 0.25"/>
|
||||
</joint>z
|
||||
|
||||
<link name="right_base">
|
||||
<visual>
|
||||
<geometry>
|
||||
<box size="0.4 0.1 0.1"/>
|
||||
</geometry>
|
||||
<material name="white"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<box size="0.4 0.1 0.1"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="1"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="right_base_joint" type="fixed">
|
||||
<parent link="right_leg"/>
|
||||
<child link="right_base"/>
|
||||
<origin xyz="0 0 -0.6"/>
|
||||
</joint>
|
||||
|
||||
<link name="right_front_wheel">
|
||||
<visual>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
<material name="black"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.5"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="right_front_wheel_joint" type="continuous">
|
||||
<axis rpy="0 0 0" xyz="0 1 0"/>
|
||||
<parent link="right_base"/>
|
||||
<child link="right_front_wheel"/>
|
||||
<origin rpy="0 0 0" xyz="0.133333333333 0 -0.085"/>
|
||||
</joint>
|
||||
|
||||
<link name="right_back_wheel">
|
||||
<visual>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
<material name="black"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.5"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="right_back_wheel_joint" type="continuous">
|
||||
<axis rpy="0 0 0" xyz="0 1 0"/>
|
||||
<parent link="right_base"/>
|
||||
<child link="right_back_wheel"/>
|
||||
<origin rpy="0 0 0" xyz="-0.133333333333 0 -0.085"/>
|
||||
</joint>
|
||||
|
||||
<link name="left_leg">
|
||||
<visual>
|
||||
<geometry>
|
||||
<box size="0.6 0.1 0.2"/>
|
||||
</geometry>
|
||||
<origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
|
||||
<material name="white"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<box size="0.6 0.1 0.2"/>
|
||||
</geometry>
|
||||
<origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="1"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="base_to_left_leg" type="fixed">
|
||||
<parent link="base_link"/>
|
||||
<child link="left_leg"/>
|
||||
<origin xyz="0 0.22 0.25"/>
|
||||
</joint>
|
||||
|
||||
<link name="left_base">
|
||||
<visual>
|
||||
<geometry>
|
||||
<box size="0.4 0.1 0.1"/>
|
||||
</geometry>
|
||||
<material name="white"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<box size="0.4 0.1 0.1"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="1"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="left_base_joint" type="fixed">
|
||||
<parent link="left_leg"/>
|
||||
<child link="left_base"/>
|
||||
<origin xyz="0 0 -0.6"/>
|
||||
</joint>
|
||||
|
||||
<link name="left_front_wheel">
|
||||
<visual>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
<material name="black"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.5"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="left_front_wheel_joint" type="continuous">
|
||||
<axis rpy="0 0 0" xyz="0 1 0"/>
|
||||
<parent link="left_base"/>
|
||||
<child link="left_front_wheel"/>
|
||||
<origin rpy="0 0 0" xyz="0.133333333333 0 -0.085"/>
|
||||
</joint>
|
||||
|
||||
<link name="left_back_wheel">
|
||||
<visual>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
<material name="black"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<origin rpy="1.57075 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<cylinder length="0.06" radius="0.035"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.5"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="left_back_wheel_joint" type="continuous">
|
||||
<axis rpy="0 0 0" xyz="0 1 0"/>
|
||||
<parent link="left_base"/>
|
||||
<child link="left_back_wheel"/>
|
||||
<origin rpy="0 0 0" xyz="-0.133333333333 0 -0.085"/>
|
||||
</joint>
|
||||
|
||||
<joint name="gripper_extension" type="fixed">
|
||||
<!-- This joint is fixed for tutorial purposes. -->
|
||||
<parent link="base_link"/>
|
||||
<child link="gripper_pole"/>
|
||||
<!-- <limit effort="1000.0" lower="-0.38" upper="0" velocity="0.5"/> -->
|
||||
<origin rpy="0 0 0" xyz="0.19 0 0.2"/>
|
||||
</joint>
|
||||
|
||||
<link name="gripper_pole">
|
||||
<visual>
|
||||
<geometry>
|
||||
<cylinder length="0.2" radius="0.01"/>
|
||||
</geometry>
|
||||
<origin rpy="0 1.57075 0 " xyz="0.1 0 0"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<cylinder length="0.2" radius="0.01"/>
|
||||
</geometry>
|
||||
<origin rpy="0 1.57075 0 " xyz="0.1 0 0"/>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.05"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="left_gripper_joint" type="revolute">
|
||||
<axis xyz="0 0 1"/>
|
||||
<limit effort="1000.0" lower="0.0" upper="0.548" velocity="0.5"/>
|
||||
<origin rpy="0 0 0" xyz="0.2 0.01 0"/>
|
||||
<parent link="gripper_pole"/>
|
||||
<child link="left_gripper"/>
|
||||
</joint>
|
||||
|
||||
<link name="left_gripper">
|
||||
<visual>
|
||||
<origin rpy="0.0 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
|
||||
</geometry>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
|
||||
</geometry>
|
||||
<origin rpy="0.0 0 0" xyz="0 0 0"/>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.05"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="left_tip_joint" type="fixed">
|
||||
<parent link="left_gripper"/>
|
||||
<child link="left_tip"/>
|
||||
</joint>
|
||||
|
||||
<link name="left_tip">
|
||||
<visual>
|
||||
<origin rpy="0.0 0 0" xyz="0.09137 0.00495 0"/>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
|
||||
</geometry>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
|
||||
</geometry>
|
||||
<origin rpy="0.0 0 0" xyz="0.09137 0.00495 0"/>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.05"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="right_gripper_joint" type="revolute">
|
||||
<axis xyz="0 0 -1"/>
|
||||
<limit effort="1000.0" lower="0.0" upper="0.548" velocity="0.5"/>
|
||||
<origin rpy="0 0 0" xyz="0.2 -0.01 0"/>
|
||||
<parent link="gripper_pole"/>
|
||||
<child link="right_gripper"/>
|
||||
</joint>
|
||||
|
||||
<link name="right_gripper">
|
||||
<visual>
|
||||
<origin rpy="-3.1415 0 0" xyz="0 0 0"/>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
|
||||
</geometry>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
|
||||
</geometry>
|
||||
<origin rpy="-3.1415 0 0" xyz="0 0 0"/>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.05"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="right_tip_joint" type="fixed">
|
||||
<parent link="right_gripper"/>
|
||||
<child link="right_tip"/>
|
||||
</joint>
|
||||
|
||||
<link name="right_tip">
|
||||
<visual>
|
||||
<origin rpy="-3.1415 0 0" xyz="0.09137 0.00495 0"/>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
|
||||
</geometry>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
|
||||
</geometry>
|
||||
<origin rpy="-3.1415 0 0" xyz="0.09137 0.00495 0"/>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.05"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<link name="head">
|
||||
<visual>
|
||||
<geometry>
|
||||
<sphere radius="0.2"/>
|
||||
</geometry>
|
||||
<material name="white"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<sphere radius="0.2"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="1"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="head_swivel" type="continuous">
|
||||
<parent link="base_link"/>
|
||||
<child link="head"/>
|
||||
<axis xyz="0 0 1"/>
|
||||
<origin xyz="0 0 0.3"/>
|
||||
|
||||
<dynamics damping="0.1" friction="0.1"/>
|
||||
|
||||
<gazebo>
|
||||
<plugin
|
||||
filename="gz-sim-apply-joint-force-system"
|
||||
name="gz::sim::systems::ApplyJointForce">
|
||||
<joint_name>head_swivel</joint_name>
|
||||
</plugin>
|
||||
</gazebo>
|
||||
|
||||
</joint>
|
||||
|
||||
<link name="box">
|
||||
<visual>
|
||||
<geometry>
|
||||
<box size="0.08 0.08 0.08"/>
|
||||
</geometry>
|
||||
<material name="blue"/>
|
||||
<origin xyz="-0.04 0 0"/>
|
||||
</visual>
|
||||
<collision>
|
||||
<geometry>
|
||||
<box size="0.08 0.08 0.08"/>
|
||||
</geometry>
|
||||
</collision>
|
||||
<inertial>
|
||||
<mass value="0.1"/>
|
||||
<inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
|
||||
</inertial>
|
||||
</link>
|
||||
|
||||
<joint name="tobox" type="fixed">
|
||||
<parent link="head"/>
|
||||
<child link="box"/>
|
||||
<origin xyz="0.1814 0 0.1414"/>
|
||||
</joint>
|
||||
|
||||
<gazebo>
|
||||
<plugin
|
||||
filename="gz-sim-diff-drive-system"
|
||||
name="gz::sim::systems::DiffDrive">
|
||||
|
||||
<left_joint>left_front_wheel_joint</left_joint>
|
||||
<left_joint>left_back_wheel_joint</left_joint>
|
||||
<right_joint>right_front_wheel_joint</right_joint>
|
||||
<right_joint>right_back_wheel_joint</right_joint>
|
||||
<wheel_separation>0.44</wheel_separation>
|
||||
<wheel_radius>0.035</wheel_radius>
|
||||
<max_linear_acceleration>1</max_linear_acceleration>
|
||||
<min_linear_acceleration>-1</min_linear_acceleration>
|
||||
<max_angular_acceleration>2</max_angular_acceleration>
|
||||
<min_angular_acceleration>-2</min_angular_acceleration>
|
||||
<max_linear_velocity>10</max_linear_velocity>
|
||||
<min_linear_velocity>-10</min_linear_velocity>
|
||||
<max_angular_velocity>10</max_angular_velocity>
|
||||
<min_angular_velocity>-10</min_angular_velocity>
|
||||
<odom_topic>/model/r2d2/odometry_estimate_dont_use</odom_topic>
|
||||
</plugin>
|
||||
</gazebo>
|
||||
|
||||
|
||||
<gazebo>
|
||||
<plugin
|
||||
filename="gz-sim-apply-joint-force-system"
|
||||
name="gz::sim::systems::ApplyJointForce">
|
||||
<joint_name>head_swivel</joint_name>
|
||||
</plugin>
|
||||
</gazebo>
|
||||
|
||||
|
||||
<gazebo reference="box">
|
||||
<sensor name="camera" type="camera">
|
||||
<camera>
|
||||
<horizontal_fov>1.547</horizontal_fov>
|
||||
<image>
|
||||
<width>320</width>
|
||||
<height>240</height>
|
||||
</image>
|
||||
<clip>
|
||||
<near>0.1</near>
|
||||
<far>100</far>
|
||||
</clip>
|
||||
</camera>
|
||||
<always_on>1</always_on>
|
||||
<update_rate>30</update_rate>
|
||||
<visualize>true</visualize>
|
||||
<topic>camera</topic>
|
||||
</sensor>
|
||||
<plugin
|
||||
filename="gz-sim-physics-system"
|
||||
name="gz::sim::systems::Physics">
|
||||
</plugin>
|
||||
<plugin
|
||||
filename="gz-sim-sensors-system"
|
||||
name="gz::sim::systems::Sensors">
|
||||
<render_engine>ogre2</render_engine>
|
||||
</plugin>
|
||||
<plugin
|
||||
filename="gz-sim-user-commands-system"
|
||||
name="gz::sim::systems::UserCommands">
|
||||
</plugin>
|
||||
<plugin
|
||||
filename="gz-sim-scene-broadcaster-system"
|
||||
name="gz::sim::systems::SceneBroadcaster">
|
||||
</plugin>
|
||||
</gazebo>
|
||||
|
||||
<gazebo>
|
||||
<plugin filename="ignition-gazebo-joint-state-publisher-system" name="ignition::gazebo::systems::JointStatePublisher"/>
|
||||
</gazebo>
|
||||
|
||||
<gazebo>
|
||||
<plugin
|
||||
filename="ignition-gazebo-odometry-publisher-system"
|
||||
name="ignition::gazebo::systems::OdometryPublisher">
|
||||
<dimensions>3</dimensions>
|
||||
<odom_topic>/model/r2d2/odometry</odom_topic>
|
||||
</plugin>
|
||||
</gazebo>
|
||||
|
||||
|
||||
</robot>
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
# <http://www.apache.org/licenses/LICENSE-2.0>.
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import rclpy
|
||||
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()
|
||||
@@ -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
|
||||
# <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 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
|
||||
]
|
||||
+126
@@ -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
|
||||
# <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 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
|
||||
]
|
||||
+119
@@ -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
|
||||
# <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 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
|
||||
]
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>gazebo_simulation_scene2</name>
|
||||
<version>1.0.0</version>
|
||||
<description>Gazebo simulation example scenes</description>
|
||||
<maintainer email="emre.cakal@siemens.com">emrehp</maintainer>
|
||||
<license>Apache-2.0</license>
|
||||
|
||||
<test_depend>ament_copyright</test_depend>
|
||||
<test_depend>ament_flake8</test_depend>
|
||||
<test_depend>ament_pep257</test_depend>
|
||||
<test_depend>python3-pytest</test_depend>
|
||||
<exec_depend>ros_ign_gazebo</exec_depend>
|
||||
<exec_depend>robot_state_publisher</exec_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_python</build_type>
|
||||
</export>
|
||||
</package>
|
||||
@@ -0,0 +1,4 @@
|
||||
[develop]
|
||||
script_dir=$base/lib/gazebo_simulation_scene2
|
||||
[install]
|
||||
install_scripts=$base/lib/gazebo_simulation_scene2
|
||||
@@ -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',
|
||||
],
|
||||
},
|
||||
)
|
||||
@@ -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'
|
||||
@@ -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)
|
||||
@@ -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'
|
||||
@@ -0,0 +1,296 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<sdf version="1.6">
|
||||
<world name="gazebo_simulation_scene2_world">
|
||||
<physics name="1ms" type="ignored">
|
||||
<max_step_size>0.001</max_step_size>
|
||||
<real_time_factor>1.0</real_time_factor>
|
||||
</physics>
|
||||
<plugin
|
||||
filename="gz-sim-physics-system"
|
||||
name="gz::sim::systems::Physics">
|
||||
</plugin>
|
||||
<plugin
|
||||
filename="gz-sim-sensors-system"
|
||||
name="gz::sim::systems::Sensors">
|
||||
<render_engine>ogre2</render_engine>
|
||||
</plugin>
|
||||
<plugin
|
||||
filename="gz-sim-user-commands-system"
|
||||
name="gz::sim::systems::UserCommands">
|
||||
</plugin>
|
||||
<plugin
|
||||
filename="gz-sim-scene-broadcaster-system"
|
||||
name="gz::sim::systems::SceneBroadcaster">
|
||||
</plugin>
|
||||
|
||||
<scene>
|
||||
<ambient>1.0 1.0 1.0</ambient>
|
||||
<background>0.8 0.8 0.8</background>
|
||||
<grid>true</grid>
|
||||
</scene>
|
||||
|
||||
<gui fullscreen="0">
|
||||
|
||||
<!-- 3D scene -->
|
||||
<plugin filename="MinimalScene" name="3D View">
|
||||
<gz-gui>
|
||||
<title>3D View</title>
|
||||
<property type="bool" key="showTitleBar">false</property>
|
||||
<property type="string" key="state">docked</property>
|
||||
</gz-gui>
|
||||
|
||||
<engine>ogre2</engine>
|
||||
<scene>scene</scene>
|
||||
<ambient_light>0.4 0.4 0.4</ambient_light>
|
||||
<background_color>0.8 0.8 0.8</background_color>
|
||||
<camera_pose>-6 0 6 0 0.5 0</camera_pose>
|
||||
</plugin>
|
||||
|
||||
<!-- Plugins that add functionality to the scene -->
|
||||
<plugin filename="EntityContextMenuPlugin" name="Entity context menu">
|
||||
<gz-gui>
|
||||
<property key="state" type="string">floating</property>
|
||||
<property key="width" type="double">5</property>
|
||||
<property key="height" type="double">5</property>
|
||||
<property key="showTitleBar" type="bool">false</property>
|
||||
</gz-gui>
|
||||
</plugin>
|
||||
<plugin filename="GzSceneManager" name="Scene Manager">
|
||||
<gz-gui>
|
||||
<property key="resizable" type="bool">false</property>
|
||||
<property key="width" type="double">5</property>
|
||||
<property key="height" type="double">5</property>
|
||||
<property key="state" type="string">floating</property>
|
||||
<property key="showTitleBar" type="bool">false</property>
|
||||
</gz-gui>
|
||||
</plugin>
|
||||
<plugin filename="InteractiveViewControl" name="Interactive view control">
|
||||
<gz-gui>
|
||||
<property key="resizable" type="bool">false</property>
|
||||
<property key="width" type="double">5</property>
|
||||
<property key="height" type="double">5</property>
|
||||
<property key="state" type="string">floating</property>
|
||||
<property key="showTitleBar" type="bool">false</property>
|
||||
</gz-gui>
|
||||
</plugin>
|
||||
<plugin filename="CameraTracking" name="Camera Tracking">
|
||||
<gz-gui>
|
||||
<property key="resizable" type="bool">false</property>
|
||||
<property key="width" type="double">5</property>
|
||||
<property key="height" type="double">5</property>
|
||||
<property key="state" type="string">floating</property>
|
||||
<property key="showTitleBar" type="bool">false</property>
|
||||
</gz-gui>
|
||||
</plugin>
|
||||
<!-- World control -->
|
||||
<plugin filename="WorldControl" name="World control">
|
||||
<gz-gui>
|
||||
<title>World control</title>
|
||||
<property type="bool" key="showTitleBar">false</property>
|
||||
<property type="bool" key="resizable">false</property>
|
||||
<property type="double" key="height">72</property>
|
||||
<property type="double" key="z">1</property>
|
||||
|
||||
<property type="string" key="state">floating</property>
|
||||
<anchors target="3D View">
|
||||
<line own="left" target="left"/>
|
||||
<line own="bottom" target="bottom"/>
|
||||
</anchors>
|
||||
</gz-gui>
|
||||
|
||||
<play_pause>true</play_pause>
|
||||
<step>true</step>
|
||||
<start_paused>true</start_paused>
|
||||
<use_event>true</use_event>
|
||||
|
||||
</plugin>
|
||||
|
||||
<!-- World statistics -->
|
||||
<plugin filename="WorldStats" name="World stats">
|
||||
<gz-gui>
|
||||
<title>World stats</title>
|
||||
<property type="bool" key="showTitleBar">false</property>
|
||||
<property type="bool" key="resizable">false</property>
|
||||
<property type="double" key="height">110</property>
|
||||
<property type="double" key="width">290</property>
|
||||
<property type="double" key="z">1</property>
|
||||
|
||||
<property type="string" key="state">floating</property>
|
||||
<anchors target="3D View">
|
||||
<line own="right" target="right"/>
|
||||
<line own="bottom" target="bottom"/>
|
||||
</anchors>
|
||||
</gz-gui>
|
||||
|
||||
<sim_time>true</sim_time>
|
||||
<real_time>true</real_time>
|
||||
<real_time_factor>true</real_time_factor>
|
||||
<iterations>true</iterations>
|
||||
</plugin>
|
||||
|
||||
<plugin filename="ImageDisplay" name="Image Display">
|
||||
<gz-gui>
|
||||
<property key="state" type="string">docked</property>
|
||||
</gz-gui>
|
||||
<topic>camera</topic>
|
||||
</plugin>
|
||||
|
||||
<!-- Inspector -->
|
||||
<plugin filename="ComponentInspector" name="Component inspector">
|
||||
<gz-gui>
|
||||
<property type="string" key="state">docked</property>
|
||||
</gz-gui>
|
||||
</plugin>
|
||||
|
||||
<!-- Entity tree -->
|
||||
<plugin filename="EntityTree" name="Entity tree">
|
||||
<gz-gui>
|
||||
<property type="string" key="state">docked</property>
|
||||
</gz-gui>
|
||||
</plugin>
|
||||
</gui>
|
||||
|
||||
<light type="directional" name="sun">
|
||||
<cast_shadows>true</cast_shadows>
|
||||
<pose>0 0 10 0 0 0</pose>
|
||||
<diffuse>0.8 0.8 0.8 1</diffuse>
|
||||
<specular>0.8 0.8 0.8 1</specular>
|
||||
<attenuation>
|
||||
<range>1000</range>
|
||||
<constant>0.9</constant>
|
||||
<linear>0.01</linear>
|
||||
<quadratic>0.001</quadratic>
|
||||
</attenuation>
|
||||
<direction>-0.5 0.1 -0.9</direction>
|
||||
</light>
|
||||
|
||||
<model name="ground_plane">
|
||||
<static>true</static>
|
||||
<link name="link">
|
||||
<collision name="collision">
|
||||
<geometry>
|
||||
<plane>
|
||||
<normal>0 0 1</normal>
|
||||
<size>100 100</size>
|
||||
</plane>
|
||||
</geometry>
|
||||
</collision>
|
||||
<visual name="visual">
|
||||
<geometry>
|
||||
<plane>
|
||||
<normal>0 0 1</normal>
|
||||
<size>100 100</size>
|
||||
</plane>
|
||||
</geometry>
|
||||
<material>
|
||||
<ambient>0.8 0.8 0.8 1</ambient>
|
||||
<diffuse>0.8 0.8 0.8 1</diffuse>
|
||||
<specular>0.8 0.8 0.8 1</specular>
|
||||
</material>
|
||||
</visual>
|
||||
</link>
|
||||
</model>
|
||||
|
||||
<model name="box">
|
||||
<pose>0 -1 0.5 0 0 0</pose>
|
||||
<link name="box_link">
|
||||
<inertial>
|
||||
<inertia>
|
||||
<ixx>1</ixx>
|
||||
<ixy>0</ixy>
|
||||
<ixz>0</ixz>
|
||||
<iyy>1</iyy>
|
||||
<iyz>0</iyz>
|
||||
<izz>1</izz>
|
||||
</inertia>
|
||||
<mass>1.0</mass>
|
||||
</inertial>
|
||||
<collision name="box_collision">
|
||||
<geometry>
|
||||
<box>
|
||||
<size>1 1 1</size>
|
||||
</box>
|
||||
</geometry>
|
||||
</collision>
|
||||
|
||||
<visual name="box_visual">
|
||||
<geometry>
|
||||
<box>
|
||||
<size>1 1 1</size>
|
||||
</box>
|
||||
</geometry>
|
||||
<material>
|
||||
<ambient>1 0 0 1</ambient>
|
||||
<diffuse>1 0 0 1</diffuse>
|
||||
<specular>1 0 0 1</specular>
|
||||
</material>
|
||||
</visual>
|
||||
</link>
|
||||
</model>
|
||||
|
||||
<model name="box_blue">
|
||||
<pose>0 3 0.5 0 0 0.3</pose>
|
||||
<link name="box_blue_link">
|
||||
<inertial>
|
||||
<inertia>
|
||||
<ixx>1</ixx>
|
||||
<ixy>0</ixy>
|
||||
<ixz>0</ixz>
|
||||
<iyy>1</iyy>
|
||||
<iyz>0</iyz>
|
||||
<izz>1</izz>
|
||||
</inertia>
|
||||
<mass>1.0</mass>
|
||||
</inertial>
|
||||
<collision name="box_blue_collision">
|
||||
<geometry>
|
||||
<box>
|
||||
<size>1 1 1</size>
|
||||
</box>
|
||||
</geometry>
|
||||
</collision>
|
||||
|
||||
<visual name="box_blue_visual">
|
||||
<geometry>
|
||||
<box>
|
||||
<size>1 1 1</size>
|
||||
</box>
|
||||
</geometry>
|
||||
<material>
|
||||
<ambient>0 0 1 1</ambient>
|
||||
<diffuse>0 0 1 1</diffuse>
|
||||
<specular>0 0 1 1</specular>
|
||||
</material>
|
||||
</visual>
|
||||
</link>
|
||||
</model>
|
||||
|
||||
<model name="sphere">
|
||||
<static>true</static>
|
||||
<pose>3 0 0.5 0 0 0</pose>
|
||||
<link name="sphere_link">
|
||||
<collision name="sphere_collision">
|
||||
<geometry>
|
||||
<sphere>
|
||||
<radius>0.125</radius>
|
||||
</sphere>
|
||||
</geometry>
|
||||
</collision>
|
||||
<visual name="sphere_visual">
|
||||
<geometry>
|
||||
<sphere>
|
||||
<radius>0.125</radius>
|
||||
</sphere>
|
||||
</geometry>
|
||||
<material>
|
||||
<ambient>0 1 0 1</ambient>
|
||||
<diffuse>0 1 0 1</diffuse>
|
||||
<specular>0 1 0 1</specular>
|
||||
</material>
|
||||
<cast_shadows>false</cast_shadows>
|
||||
</visual>
|
||||
</link>
|
||||
</model>
|
||||
</world>
|
||||
</sdf>
|
||||
Submodule
+1
Submodule ros2_ws/src/kobuki_core added at 3e0652dc40
Submodule
+1
Submodule ros2_ws/src/kobuki_ros added at e1fbf7bdec
Submodule
+1
Submodule ros2_ws/src/kobuki_ros_interfaces added at 7711d4fbec
Submodule
+1
Submodule ros2_ws/src/piper_ros added at 4de4f69ca4
@@ -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.
|
||||
@@ -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
|
||||
# <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 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'
|
||||
)
|
||||
])
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>unity_simulation_scene2</name>
|
||||
<version>1.0.0</version>
|
||||
<description>Unity Simulation Scene Package</description>
|
||||
|
||||
<maintainer email="emre.cakal@siemens.com">Mehmet Emre Cakal</maintainer>
|
||||
|
||||
<license>Apache License, Version 2.0</license>
|
||||
|
||||
<depend>launch</depend>
|
||||
<depend>launch_ros</depend>
|
||||
<depend>rclpy</depend>
|
||||
<depend>sensor_msgs</depend>
|
||||
<depend>tkinter</depend>
|
||||
|
||||
<test_depend>ament_copyright</test_depend>
|
||||
<test_depend>ament_flake8</test_depend>
|
||||
<test_depend>ament_pep257</test_depend>
|
||||
<test_depend>python3-pytest</test_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_python</build_type>
|
||||
</export>
|
||||
</package>
|
||||
@@ -0,0 +1,4 @@
|
||||
[develop]
|
||||
script_dir=$base/lib/unity_simulation_scene2
|
||||
[install]
|
||||
install_scripts=$base/lib/unity_simulation_scene2
|
||||
@@ -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'
|
||||
],
|
||||
},
|
||||
)
|
||||
@@ -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'
|
||||
@@ -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)
|
||||
@@ -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'
|
||||
@@ -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
|
||||
# <http://www.apache.org/licenses/LICENSE-2.0>.
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import rclpy
|
||||
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('<Motion>', 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()
|
||||
@@ -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.
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>urdf_export_test</name>
|
||||
<version>0.0.0</version>
|
||||
<description>TODO: Package description</description>
|
||||
<maintainer email="dennis@todo.todo">dennis</maintainer>
|
||||
<license>Apache-2.0</license>
|
||||
|
||||
<test_depend>ament_copyright</test_depend>
|
||||
<test_depend>ament_flake8</test_depend>
|
||||
<test_depend>ament_pep257</test_depend>
|
||||
<test_depend>python3-pytest</test_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_python</build_type>
|
||||
</export>
|
||||
</package>
|
||||
@@ -0,0 +1,4 @@
|
||||
[develop]
|
||||
script_dir=$base/lib/urdf_export_test
|
||||
[install]
|
||||
install_scripts=$base/lib/urdf_export_test
|
||||
@@ -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': [
|
||||
],
|
||||
},
|
||||
)
|
||||
@@ -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'
|
||||
@@ -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)
|
||||
@@ -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'
|
||||
Reference in New Issue
Block a user