浏览代码

Updating tutorials, work in progress

/laurie-Ros2Update
LaurieCheers 3 年前
当前提交
cfbfde57
共有 45 个文件被更改,包括 587 次插入57 次删除
  1. 39
      tutorials/ros_unity_integration/publisher.md
  2. 4
      tutorials/ros_unity_integration/service.md
  3. 28
      tutorials/ros_unity_integration/setup.md
  4. 24
      tutorials/ros_unity_integration/subscriber.md
  5. 2
      tutorials/ros_unity_integration/unity_scripts/RosPublisherExample.cs
  6. 2
      tutorials/ros_unity_integration/unity_scripts/RosServiceExample.cs
  7. 2
      tutorials/ros_unity_integration/unity_scripts/RosSubscriberExample.cs
  8. 2
      tutorials/ros_unity_integration/unity_scripts/RosUnityServiceExample.cs
  9. 6
      tutorials/ros_unity_integration/unity_service.md
  10. 9
      tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/CMakeLists.txt
  11. 9
      tutorials/ros_unity_integration/images/ros2_icon.png
  12. 126
      tutorials/ros_unity_integration/images/ros2_protocol.png
  13. 20
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/launch/test_launcher.py
  14. 27
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/package.xml
  15. 0
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/resource/robotics_demo
  16. 0
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/__init__.py
  17. 50
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/color_publisher.py
  18. 34
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/position_service.py
  19. 36
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/server_endpoint.py
  20. 4
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/setup.cfg
  21. 31
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/setup.py
  22. 23
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_copyright.py
  23. 25
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_flake8.py
  24. 23
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_pep257.py
  25. 49
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/CMakeLists.txt
  26. 25
      tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/package.xml
  27. 7
      tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/msg/PosRot.msg
  28. 4
      tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/msg/UnityColor.msg
  29. 27
      tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/package.xml
  30. 3
      tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/srv/ObjectPoseService.srv
  31. 3
      tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/srv/PositionService.srv
  32. 0
      /tutorials/ros_unity_integration/ros_packages/unity_robotics_demo
  33. 0
      /tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/CMakeLists.txt
  34. 0
      /tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/msg
  35. 0
      /tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/srv

39
tutorials/ros_unity_integration/publisher.md


## Setting Up ROS
- If using ROS (melodic or noetic), copy the `tutorials/ros_packages/robotics_demo` folder of this repo into the `src` folder in your Catkin workspace.
- If using ROS (melodic or noetic), copy the contents of `tutorials/ros_unity_integration/ros_packages` from this repo into the `src` folder in your Catkin workspace. (If using ROS2, instead go to the [Setting Up ROS2](publisher.md#setting-up-ros2) section.)
- Follow the [ROS–Unity Initial Setup](setup.md) guide.

source devel/setup.bash
rosrun robotics_demo server_endpoint.py
rosrun unity_robotics_demo server_endpoint.py
```
Once the server_endpoint has started, it will print something similar to `[INFO] [1603488341.950794]: Starting server on 192.168.50.149:10000`.

rostopic echo pos_rot
```
- Now proceed to [Setting Up Unity Scene](publisher.md#setting-up-unity-scene).
- If using ROS2, copy the `tutorials/ros2_packages/robotics_demo` folder of this repo into the `src` folder in your Colcon workspace.
- <img src="images/ros2_icon.png" alt="ros2" width="16" height="16"/> If using ROS2, copy the contents of `tutorials/ros_unity_integration/ros2_packages` from this repo into the `src` folder in your Colcon workspace.
- The `server_endpoint` script we'll be using has a parameter ROS_IP. You will need to know the IP address of your ROS machine; the command `hostname -I` can be used to find it. Or, if you're using Docker, the IP address to use is `0.0.0.0`.
ros2 run robotics_demo server_endpoint.py
ros2 run unity_robotics_demo server_endpoint --ros-args -p ROS_IP:=127.0.0.1
Once the server_endpoint has started, it will print something similar to `[INFO] [1603488341.950794]: Starting server on 192.168.50.149:10000`.
Or if you need the server to listen on a port that's different from the default 10000, you can set the ROS_TCP_PORT parameter too:
```bash
ros2 run unity_robotics_demo server_endpoint --ros-args -p ROS_IP:=127.0.0.1 -p ROS_TCP_PORT:=10000
```
Once the server_endpoint has started, if everything worked ok, it will print something similar to `[INFO] [1622239914.040931500] [TCPServer]: Starting server on 127.0.0.1:10000`.
- Open another new terminal window, navigate to your ROS workspace, and run the following commands:
```bash

## Setting Up Unity Scene
- In the menu bar, find and select `Robotics` -> `Generate ROS Messages...`
- Set the ROS message path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_packages/robotics_demo`.
- Expand the robotics_demo subfolder and click "Build 2 msgs" to generate new C# scripts from the ROS .msg files.
- Set the ROS message path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs`.(The version in the ros2_packages folder is equivalent; Ros2 users can feel free to use it, or not.)
- In the message browser, expand the unity_robotics_demo_msgs subfolder and click "Build 2 msgs" to generate new C# scripts from the ROS .msg files.
- The generated files will be saved in the default directory `Assets/RosMessages/RoboticsDemo/msg`.
- The generated files will be saved in the default directory `Assets/RosMessages/UnityRoboticsDemo/msg`.
- **Note** Script can be found at `tutorials/ros_unity_integration/unity_scripts`
- (Alternatively, you can copy the script file from `tutorials/ros_unity_integration/unity_scripts/RosPublisherExample.cs`)
using RosMessageTypes.RoboticsDemo;
using RosMessageTypes.UnityRoboticsDemo;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;

- Add a plane and a cube to the empty Unity scene
- Move the cube a little ways up so it is hovering above the plane
- In the main menu bar, open `Robotics/ROS Settings`.
- Set the ROS IP address and port to match the ROS IP and port variables defined when you set up ROS.
- If using ROS2, switch to the ROS2 protocol.
- Set the ROS IP address and port to match the ROS IP and port variables defined when you started the ROS endpoint.
- If using ROS2, select the ROS2 protocol.
![](images/ros2_protocol.png)
- Pressing play in the Editor should publish a message to the terminal running the `rostopic echo pos_rot` command every 0.5 seconds
- Pressing play in the Editor should publish a message every 0.5 seconds to the terminal running the `echo` command.
> Please reference [networking troubleshooting](network.md) doc if any errors are thrown.

4
tutorials/ros_unity_integration/service.md


(Skip to [Start the Position service](service.md#start-the-position-service) if you already did the [ROS–Unity Integration Publisher](publisher.md) or [Subscriber](subscriber.md) tutorials.)
- Copy the `tutorials/ros_packages/robotics_demo` folder of this repo into the `src` folder in your Catkin workspace.
- Copy the `tutorials/ros_unity_integration/ros_packages/unity_robotics_demo` folder of this repo into the `src` folder in your Catkin workspace.
- Follow the [ROS–Unity Initial Setup](setup.md) guide.

## Setting Up Unity Scene
- Generate the C# code for `PositionService`'s messages by going to `Robotics` -> `Generate ROS Messages...`
- Set the input file path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_packages/robotics_demo`, expand the robotics_demo folder and click `Build 2 srvs`.
- Set the input file path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_unity_integration/ros_packages/robotics_demo`, expand the robotics_demo folder and click `Build 2 srvs`.
![](images/generate_messages_2.png)

28
tutorials/ros_unity_integration/setup.md


1. Download and copy the [TCP Endpoint](https://github.com/Unity-Technologies/ROS-TCP-Endpoint) package to the `src` folder in your Catkin workspace.
1. Navigate to your Catkin workspace and run `catkin_make && source devel/setup.bash`. Ensure there are no errors.
1. Navigate to your Catkin workspace and run `catkin_make`, then `source devel/setup.bash`. Ensure there are no errors.
1. Open a new terminal, navigate to your Catkin workspace, and run:

```
Once ROS Core has started, it will print `started core service [/rosout]` to the terminal window.
Once ROS Core has started, it will print `started core service [/rosout]` to the terminal window.
1. Note that in the `server_endpoint`, the script fetches parameters for the TCP connection. You will need to know the IP address of your ROS machine, which should be the same value as the one set as `Host Name` on the RosConnect component in Unity.
1. The `server_endpoint` script we'll be using will require the ros parameter ROS_IP to be defined. You will need to know the IP address of your ROS machine; the command `hostname -I` can be used to find it. Or, if you're using Docker, the IP address to use is `0.0.0.0`.
1. The ROS parameter values can be set using a YAML file. Create a `params.yaml` file in your package, e.g. `./config/params.yaml`. Open the file for editing.
1. Set the ros parameter using the command `rosparam set ROS_IP 127.0.0.1`, replacing this IP address with the appropriate IP address or hostname.
1. Update the `ROS_IP` below with the appropriate address and copy the contents into the `params.yaml` file.
1. By default, the server_endpoint will listen on port 10000, but this is also controlled by a parameter. If you need to change it, you can run the command `rosparam set ROS_IP 10000`, replacing 10000 with the desired port number.
1. (Optional) If you're going through this process often, you may find it useful to set the ROS parameter values using a YAML file. To do this, create a `params.yaml` file in your package, e.g. `./config/params.yaml`. Open the file for editing.
Update the `ROS_IP` below with the appropriate address and copy the contents into the `params.yaml` file.
```yaml
ROS_IP: <your ROS IP>

ROS_TCP_PORT: 10000
```
Ensure that the `ROS_TCP_PORT` is set to 10000.
1. Set these newly defined parameters by running `rosparam load`, e.g.:
Set these newly defined parameters by running `rosparam load`, e.g.:
```bash
rosparam load PATH/TO/config/params.yaml

1. Download the [ROS2 TCP Endpoint](https://github.com/Unity-Technologies/ROS2-TCP-Endpoint) repository and copy the folders `ROS2_packages/ros2_tcp_endpoint` and `ROS2_packages/unity_interfaces` into the `src` folder in your Colcon workspace.
1. Navigate to your Colcon workspace and run `colcon build && source install/setup.bash`. Ensure there are no errors.
1. Note that in the `server_endpoint`, the script fetches parameters for the TCP connection. You will need to know the IP address of your ROS2 machine - this should be the same value as the one set as `Host Name` on the RosConnect component in Unity.
1. Navigate to your Colcon workspace and run the following commands
```bash
colcon build
source install/setup.bash
```
Ensure there are no errors.
## Unity Scene
1. Launch Unity and create a new scene.

24
tutorials/ros_unity_integration/subscriber.md


(Skip to [Setting Up Unity Scene](subscriber.md#setting-up-unity-scene) if you already did the [Publisher](publisher.md) tutorial.)
- Copy the `tutorials/ros_packages/robotics_demo` folder of this repo into the `src` folder in your Catkin workspace.
- Copy the `tutorials/ros_unity_integration/ros_packages/robotics_demo` folder of this repo into the `src` folder in your Catkin workspace.
- Follow the [ROS–Unity Initial Setup](setup.md) guide.

Once the server_endpoint has started, it will print something similar to `[INFO] [1603488341.950794]: Starting server on 192.168.50.149:10000`.
- In Unity, we need to generate the C# code for the `UnityColor` message. Open `Robotics` -> `Generate ROS Messages...`.
- Set the ROS message path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_packages/robotics_demo/`, expand the robotics_demo subfolder and click `Build 2 msgs`.
![](images/generate_messages_1.png)
- The generated files will be saved in the default directory `Assets/RosMessages/RoboticsDemo/msg`.
- Copy the `tutorials/ros2_packages/robotics_demo` folder of this repo into the `src` folder in your Colcon workspace.
- Copy the `tutorials/ros_unity_integration/ros2_packages/robotics_demo` folder of this repo into the `src` folder in your Colcon workspace.
- Follow the [ROS–Unity Initial Setup](setup.md) guide.

Once the server_endpoint has started, it will print something similar to `[INFO] [1603488341.950794]: Starting server on 192.168.50.149:10000`.
## Setting Up Unity Scene
- Set the ROS message path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_packages/robotics_demo/`, expand the robotics_demo subfolder and click `Build 2 msgs`.
- Set the ROS message path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_unity_integration/ros_packages/robotics_demo/`, expand the robotics_demo subfolder and click `Build 2 msgs`.
## Setting Up Unity Scene
- **Note** Script can be found at `tutorials/ros_unity_integration/unity_scripts`
- Alternatively, copy the script file from `tutorials/ros_unity_integration/unity_scripts/RosSubscriberExample.cs`
using RosColor = RosMessageTypes.RoboticsDemo.UnityColorMsg;
using RosColor = RosMessageTypes.UnityRoboticsDemo.UnityColorMsg;
public class RosSubscriberExample : MonoBehaviour
{

- Press play in the editor
### In ROS Terminal Window
- After the scene has entered Play mode, run the following command: `rosrun robotics_demo color_publisher.py` to change the color of the cube GameObject in Unity to a random color
- After the scene has entered Play mode, run the following command: `rosrun robotics_demo color_publisher.py` to change the color of the cube GameObject in Unity to a random color.
- In ROS2, instead run `ros2 run robotics_demo color_publisher.py`.
- In ROS2, instead run `ros2 run unity_robotics_demo color_publisher`.
> Please reference [networking troubleshooting](network.md) doc if any errors are thrown.

2
tutorials/ros_unity_integration/unity_scripts/RosPublisherExample.cs


using RosMessageTypes.RoboticsDemo;
using RosMessageTypes.UnityRoboticsDemo;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;

2
tutorials/ros_unity_integration/unity_scripts/RosServiceExample.cs


using RosMessageTypes.RoboticsDemo;
using RosMessageTypes.UnityRoboticsDemo;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;

2
tutorials/ros_unity_integration/unity_scripts/RosSubscriberExample.cs


using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
using RosColor = RosMessageTypes.RoboticsDemo.UnityColorMsg;
using RosColor = RosMessageTypes.UnityRoboticsDemo.UnityColorMsg;
public class RosSubscriberExample : MonoBehaviour
{

2
tutorials/ros_unity_integration/unity_scripts/RosUnityServiceExample.cs


using RosMessageTypes.RoboticsDemo;
using RosMessageTypes.UnityRoboticsDemo;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
using Unity.Robotics.ROSTCPConnector.ROSGeometry;

6
tutorials/ros_unity_integration/unity_service.md


# ROS–Unity Integration: UnityService
Create a simple Unity scene which create a [Service](http://wiki.ros.org/Services) in Unity that takes a request with a GameObject's name and responds with the GameObject's pose (position and orientation) in the ROS coordinate system.
Create a simple Unity scene which runs a [Service](http://wiki.ros.org/Services) in Unity that takes a request with a GameObject's name and responds with the GameObject's pose (position and orientation) in the ROS coordinate system.
- Copy the `tutorials/ros_packages/robotics_demo` folder of this repo into the `src` folder in your Catkin workspace.
- Copy the `tutorials/ros_unity_integration/ros_packages/robotics_demo` folder of this repo into the `src` folder in your Catkin workspace.
- Follow the [ROS–Unity Initial Setup](setup.md) guide.

## Setting Up the Unity Scene
- Generate the C# code for `ObjectPoseService`'s messages by going to `Robotics` -> `Generate ROS Messages...`
- Set the input file path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_packages/robotics_demo`, expand the robotics_demo folder and click `Build 2 srvs` (Note that you may skip this step if you have already done it in the previous tutorial).
- Set the input file path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_unity_integration/ros_packages/robotics_demo`, expand the robotics_demo folder and click `Build 2 srvs` (Note that you may skip this step if you have already done it in the previous tutorial).
![](images/generate_messages_2.png)

9
tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/CMakeLists.txt


rospy
std_msgs
geometry_msgs
ros_tcp_endpoint
message_generation
)

catkin_package(CATKIN_DEPENDS
ros_tcp_endpoint
message_runtime)
catkin_install_python(PROGRAMS
scripts/server_endpoint.py
scripts/position_service.py
scripts/color_publisher.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
#############
## Testing ##

9
tutorials/ros_unity_integration/images/ros2_icon.png

之前 之后
宽度: 64  |  高度: 64  |  大小: 851 B

126
tutorials/ros_unity_integration/images/ros2_protocol.png

之前 之后
宽度: 632  |  高度: 337  |  大小: 38 KiB

20
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/launch/test_launcher.py


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},
],
),
])

27
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/package.xml


<?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>

0
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/resource/robotics_demo

0
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/__init__.py

50
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/color_publisher.py


#!/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()

34
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/position_service.py


#!/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()

36
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/robotics_demo/server_endpoint.py


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()

4
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/setup.cfg


[develop]
script-dir=$base/lib/ros2_test
[install]
install-scripts=$base/lib/ros2_test

31
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/setup.py


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',
],
},
)

23
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_copyright.py


# 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'

25
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_flake8.py


# 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)

23
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo/test/test_pep257.py


# 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'

49
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/CMakeLists.txt


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()

25
tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/package.xml


<?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>

7
tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/msg/PosRot.msg


float32 pos_x
float32 pos_y
float32 pos_z
float32 rot_x
float32 rot_y
float32 rot_z
float32 rot_w

4
tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/msg/UnityColor.msg


int32 r
int32 g
int32 b
int32 a

27
tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/package.xml


<?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>

3
tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/srv/ObjectPoseService.srv


string object_name
---
geometry_msgs/Pose object_pose

3
tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/srv/PositionService.srv


PosRot input
---
PosRot output

/tutorials/ros_unity_integration/ros_packages/robotics_demo → /tutorials/ros_unity_integration/ros_packages/unity_robotics_demo

/tutorials/ros_unity_integration/ros2_packages/robotics_demo/CMakeLists.txt → /tutorials/ros_unity_integration/ros_packages/unity_robotics_demo_msgs/CMakeLists.txt

/tutorials/ros_unity_integration/ros2_packages/robotics_demo/msg → /tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/msg

/tutorials/ros_unity_integration/ros2_packages/robotics_demo/srv → /tutorials/ros_unity_integration/ros2_packages/unity_robotics_demo_msgs/srv

正在加载...
取消
保存