LaurieCheers
3 年前
当前提交
cfbfde57
共有 45 个文件被更改,包括 587 次插入 和 57 次删除
-
39tutorials/ros_unity_integration/publisher.md
-
4tutorials/ros_unity_integration/service.md
-
28tutorials/ros_unity_integration/setup.md
-
24tutorials/ros_unity_integration/subscriber.md
-
2tutorials/ros_unity_integration/unity_scripts/RosPublisherExample.cs
-
2tutorials/ros_unity_integration/unity_scripts/RosServiceExample.cs
-
2tutorials/ros_unity_integration/unity_scripts/RosSubscriberExample.cs
-
2tutorials/ros_unity_integration/unity_scripts/RosUnityServiceExample.cs
-
6tutorials/ros_unity_integration/unity_service.md
-
9tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/CMakeLists.txt
-
9tutorials/ros_unity_integration/images/ros2_icon.png
-
126tutorials/ros_unity_integration/images/ros2_protocol.png
-
20tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/launch/test_launcher.py
-
27tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/package.xml
-
0tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/resource/robotics_demo
-
0tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/__init__.py
-
50tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/color_publisher.py
-
34tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/position_service.py
-
36tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/server_endpoint.py
-
4tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/setup.cfg
-
31tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/setup.py
-
23tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_copyright.py
-
25tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_flake8.py
-
23tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_pep257.py
-
49tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/CMakeLists.txt
-
25tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/package.xml
-
7tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/msg/PosRot.msg
-
4tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/msg/UnityColor.msg
-
27tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/package.xml
-
3tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/srv/ObjectPoseService.srv
-
3tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/srv/PositionService.srv
-
0/tutorials/ros_unity_integration/ros_packages/unity_robotics_demo
-
0/tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/CMakeLists.txt
-
0/tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/msg
-
0/tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/srv
|
|||
from launch import LaunchDescription |
|||
from launch_ros.actions import Node |
|||
|
|||
def generate_launch_description(): |
|||
return LaunchDescription([ |
|||
Node( |
|||
package='ros2_test', |
|||
executable='position_service', |
|||
), |
|||
Node( |
|||
package='ros2_test', |
|||
executable='server_endpoint', |
|||
emulate_tty=True, |
|||
parameters=[ |
|||
{'/ROS_IP': '0.0.0.0'}, |
|||
{'/ROS_TCP_PORT': 10000}, |
|||
], |
|||
), |
|||
]) |
|||
|
|
|||
<?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_robotics_demo</name> |
|||
<version>0.0.1</version> |
|||
<description>Package for use in ROS-Unity Integration tutorials (ROS2 version)</description> |
|||
<maintainer email="unity-robotics@unity.com">Unity Robotics</maintainer> |
|||
<license>TODO: License declaration</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>rclpy</exec_depend> |
|||
<exec_depend>std_msgs</exec_depend> |
|||
<exec_depend>unity_interfaces</exec_depend> |
|||
<exec_depend>ros2_tcp_endpont</exec_depend> |
|||
|
|||
<build_depend>rosidl_default_generators</build_depend> |
|||
<exec_depend>rosidl_default_runtime</exec_depend> |
|||
<member_of_group>rosidl_interface_packages</member_of_group> |
|||
|
|||
<export> |
|||
<build_type>ament_python</build_type> |
|||
</export> |
|||
</package> |
|
|||
#!/usr/bin/env python |
|||
|
|||
import random |
|||
import rclpy |
|||
|
|||
from rclpy.node import Node |
|||
|
|||
from unity_interfaces.msg import UnityColor |
|||
|
|||
|
|||
class ColorPublisher(Node): |
|||
|
|||
def __init__(self): |
|||
super().__init__('color_publisher') |
|||
self.publisher_ = self.create_publisher(UnityColor, 'color', 10) |
|||
timer_period = 0.5 # seconds |
|||
self.timer = self.create_timer(timer_period, self.timer_callback) |
|||
self.i = 0 |
|||
self.do_publish() |
|||
|
|||
def do_publish(self): |
|||
if self.i == 0: |
|||
color = UnityColor() |
|||
color.r = random.randint(0, 255) |
|||
color.g = random.randint(0, 255) |
|||
color.b = random.randint(0, 255) |
|||
color.a = 1 |
|||
self.get_logger().info(f'Publishing: {color}') |
|||
self.publisher_.publish(color) |
|||
|
|||
self.i += 1 |
|||
|
|||
def timer_callback(self): |
|||
quit() |
|||
|
|||
|
|||
def main(args=None): |
|||
rclpy.init(args=args) |
|||
|
|||
color_pub = ColorPublisher() |
|||
|
|||
while rclpy.ok(): |
|||
rclpy.spin_once(color_pub) |
|||
|
|||
#color_pub.destroy_node() |
|||
#rclpy.shutdown() |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
main() |
|
|||
#!/usr/bin/env python |
|||
|
|||
import random |
|||
import rclpy |
|||
|
|||
#from unity_interfaces.srv import PositionService |
|||
|
|||
from rclpy.node import Node |
|||
|
|||
class PositionServiceNode(Node): |
|||
|
|||
def __init__(self): |
|||
super().__init__('position_service_node') |
|||
#self.srv = self.create_service(PositionService, 'pos_srv', self.new_position_callback) |
|||
|
|||
def new_position_callback(self, request, response): |
|||
response.output.pos_x = random.uniform(-4.0, 4.0) |
|||
response.output.pos_z = random.uniform(-4.0, 4.0) |
|||
|
|||
return response |
|||
|
|||
|
|||
def main(args=None): |
|||
rclpy.init(args=args) |
|||
|
|||
pos_service = PositionServiceNode() |
|||
|
|||
rclpy.spin(pos_service) |
|||
|
|||
rclpy.shutdown() |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
main() |
|
|||
import rclpy |
|||
|
|||
from ros2_tcp_endpoint.server import TcpServer |
|||
from ros2_tcp_endpoint.publisher import RosPublisher |
|||
from ros2_tcp_endpoint.subscriber import RosSubscriber |
|||
from ros2_tcp_endpoint.service import RosService |
|||
from ros2_tcp_endpoint.unity_service import UnityService |
|||
|
|||
#from unity_interfaces.msg import UnityColor |
|||
#from unity_interfaces.msg import PosRot, UnityColor |
|||
#from unity_interfaces.srv import PositionService, ObjectPoseService |
|||
|
|||
def main(args=None): |
|||
rclpy.init(args=args) |
|||
|
|||
ros_node_name = 'TCPServer' |
|||
buffer_size = 1024 |
|||
connections = 10 |
|||
tcp_server = TcpServer(ros_node_name, buffer_size, connections) |
|||
|
|||
tcp_server.start({ |
|||
#'pos_srv': RosService('pos_srv', PositionService), |
|||
#'pos_rot': RosPublisher('pos_rot', PosRot, queue_size=10), |
|||
#'color': RosSubscriber('color', UnityColor(), tcp_server), |
|||
#'obj_pose_srv': UnityService('obj_pose_srv', ObjectPoseService, tcp_server), |
|||
}) |
|||
|
|||
# Setup executors for nodes defined in source_destination_dict |
|||
tcp_server.setup_executor() |
|||
|
|||
# Clean up nodes defined in source_destination_dict |
|||
tcp_server.destroy_nodes() |
|||
rclpy.shutdown() |
|||
|
|||
if __name__ == '__main__': |
|||
main() |
|
|||
[develop] |
|||
script-dir=$base/lib/ros2_test |
|||
[install] |
|||
install-scripts=$base/lib/ros2_test |
|
|||
import glob |
|||
import os |
|||
|
|||
from setuptools import setup |
|||
|
|||
package_name = 'ros2_test' |
|||
|
|||
setup( |
|||
name=package_name, |
|||
version='0.0.1', |
|||
packages=[package_name], |
|||
data_files=[ |
|||
('share/ament_index/resource_index/packages', ['resource/' + package_name]), |
|||
('share/' + package_name, ['package.xml']), |
|||
(os.path.join('share', package_name), ['launch/test_launcher.py']), |
|||
], |
|||
install_requires=['setuptools'], |
|||
zip_safe=True, |
|||
maintainer='Unity Robotics', |
|||
maintainer_email='laurie.cheers@unity3d.com', |
|||
description='ROS2 Unity Integration Testing', |
|||
license='TODO: License declaration', |
|||
tests_require=['pytest'], |
|||
entry_points={ |
|||
'console_scripts': [ |
|||
'server_endpoint = ros2_test.server_endpoint:main', |
|||
'color_publisher = ros2_test.color_publisher:main', |
|||
'position_service = ros2_test.position_service:main', |
|||
], |
|||
}, |
|||
) |
|
|||
# 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 |
|||
|
|||
|
|||
@pytest.mark.copyright |
|||
@pytest.mark.linter |
|||
def test_copyright(): |
|||
rc = main(argv=['.', 'test']) |
|||
assert rc == 0, 'Found errors' |
|
|||
# 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) |
|
|||
# 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' |
|
|||
cmake_minimum_required(VERSION 3.5) |
|||
project(unity_interfaces) |
|||
|
|||
# Default to C99 |
|||
if(NOT CMAKE_C_STANDARD) |
|||
set(CMAKE_C_STANDARD 99) |
|||
endif() |
|||
|
|||
# Default to C++14 |
|||
if(NOT CMAKE_CXX_STANDARD) |
|||
set(CMAKE_CXX_STANDARD 14) |
|||
endif() |
|||
|
|||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
|||
add_compile_options(-Wall -Wextra -Wpedantic) |
|||
endif() |
|||
|
|||
# find dependencies |
|||
find_package(ament_cmake REQUIRED) |
|||
find_package(rosidl_default_generators REQUIRED) |
|||
find_package(builtin_interfaces REQUIRED) |
|||
find_package(geometry_msgs REQUIRED) |
|||
find_package(std_msgs REQUIRED) |
|||
|
|||
rosidl_generate_interfaces(${PROJECT_NAME} |
|||
"msg/PosRot.msg" |
|||
"msg/UnityColor.msg" |
|||
"srv/PositionService.srv" |
|||
"srv/ObjectPoseService.srv" |
|||
DEPENDENCIES builtin_interfaces geometry_msgs std_msgs |
|||
) |
|||
|
|||
if(BUILD_TESTING) |
|||
find_package(ament_lint_auto REQUIRED) |
|||
# the following line skips the linter which checks for copyrights |
|||
# uncomment the line when a copyright and license is not present in all source files |
|||
#set(ament_cmake_copyright_FOUND TRUE) |
|||
# the following line skips cpplint (only works in a git repo) |
|||
# uncomment the line when this package is not in a git repo |
|||
#set(ament_cmake_cpplint_FOUND TRUE) |
|||
ament_lint_auto_find_test_dependencies() |
|||
endif() |
|||
|
|||
ament_package() |
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
<?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_robotics_demo_msgs</name> |
|||
<version>0.0.1</version> |
|||
<description>Messages used by ROS-Unity Integration tutorial (ROS2 version)</description> |
|||
<maintainer email="unity-robotics@unity.com">Unity Robotics</maintainer> |
|||
<license>TODO: License declaration</license> |
|||
|
|||
<buildtool_depend>ament_cmake</buildtool_depend> |
|||
|
|||
<test_depend>ament_lint_auto</test_depend> |
|||
<test_depend>ament_lint_common</test_depend> |
|||
|
|||
<build_depend>rosidl_default_generators</build_depend> |
|||
|
|||
<exec_depend>rosidl_default_runtime</exec_depend> |
|||
|
|||
<member_of_group>rosidl_interface_packages</member_of_group> |
|||
|
|||
|
|||
<export> |
|||
<build_type>ament_cmake</build_type> |
|||
</export> |
|||
</package> |
|
|||
float32 pos_x |
|||
float32 pos_y |
|||
float32 pos_z |
|||
float32 rot_x |
|||
float32 rot_y |
|||
float32 rot_z |
|||
float32 rot_w |
|
|||
int32 r |
|||
int32 g |
|||
int32 b |
|||
int32 a |
|
|||
<?xml version="1.0"?> |
|||
<package format="2"> |
|||
<name>unity_robotics_demo</name> |
|||
<version>0.0.1</version> |
|||
<description>The robotics_demo package (ROS1 version)</description> |
|||
|
|||
<maintainer email="unity-robotics@unity3d.com">Unity Robotics</maintainer> |
|||
|
|||
|
|||
<license>Apache 2.0</license> |
|||
|
|||
<buildtool_depend>catkin</buildtool_depend> |
|||
<build_depend>message_generation</build_depend> |
|||
<build_depend>std_msgs</build_depend> |
|||
<build_export_depend>rospy</build_export_depend> |
|||
<build_export_depend>std_msgs</build_export_depend> |
|||
<exec_depend>message_runtime</exec_depend> |
|||
<exec_depend>rospy</exec_depend> |
|||
<exec_depend>std_msgs</exec_depend> |
|||
|
|||
|
|||
<!-- The export tag contains other, unspecified, tags --> |
|||
<export> |
|||
<!-- Other tools can request additional information be placed here --> |
|||
|
|||
</export> |
|||
</package> |
|
|||
string object_name |
|||
--- |
|||
geometry_msgs/Pose object_pose |
|
|||
PosRot input |
|||
--- |
|||
PosRot output |
撰写
预览
正在加载...
取消
保存
Reference in new issue