Skip to content

Commit b5f69a9

Browse files
AIRO-388: Tutorial fixes and improvement (#90)
tutorial fixes and improvement Co-authored-by: peifeng-unity <56408141+peifeng-unity@users.noreply.github.com> Co-authored-by: LaurieCheers-unity <73140792+LaurieCheers-unity@users.noreply.github.com>
1 parent 8c87be8 commit b5f69a9

4 files changed

Lines changed: 45 additions & 31 deletions

File tree

tutorials/pick_and_place/2_ros_tcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
134134

135135
1. Next, the object that will hold the TCP functionality needs to be added.
136136

137-
Create another GameObject, name it RosConnect, and add the script `Assets/Plugins/TCPConnector/ROSConnection` to it in the same way.
137+
Create another GameObject, name it RosConnect, and add the script `Packages/ROS TCP Connection/Runtime/TcpConnector/ROSConnection` to it in the same way.
138138

139139
1. Note that these components show empty member variables in the Inspector window, which need to be assigned.
140140

tutorials/ros_unity_integration/server_endpoint.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A walkthrough of the important components of a ROS TCP endpoint script using the
55
The following is an example of a server endpoint Python script that:
66

77
- Gets parameters from `rosparam`
8-
- Creates corresponding ROS Publisher, Subscriber, and Service objects to interact with topics and services running in in ROS network
8+
- Creates corresponding ROS Publisher, Subscriber, and Service objects to interact with topics and services running in ROS network
99
- Starts TCP Server process to handle incoming and outgoing connections
1010

1111

@@ -49,29 +49,29 @@ from robotics_demo.msg import PosRot, UnityColor
4949
from robotics_demo.srv import PositionService
5050
```
5151

52+
## Creating the Server
5253

53-
## Instantiate the ROS Node
54+
Requires:
55+
56+
- The ROS node name
5457

5558
```python
56-
rospy.init_node(ros_node_name, anonymous=True)
59+
tcp_server = TcpServer(ros_node_name, buffer_size=1024, connections=10)
5760
```
5861

59-
## ROS Publisher
60-
A ROS Publisher requires three components:
61-
62-
- Topic name
63-
- ROS message class generated from running `catkin_make` command
64-
- Queue size
62+
The `ros_node_name` is required and the `buffer_size` and `connections` are optional. They are set to `1024` and `10` by default if not provided in the constructor arguments.
6563

66-
`RosPublisher('pos_rot', PosRot, queue_size=10)`
67-
## ROS Subscriber
68-
A ROS Subscriber requires three components:
64+
## Source Destination Dictionary
6965

70-
- Topic name
71-
- ROS message class generated from running `catkin_make` command
72-
- The tcp server that will connect to Unity
66+
Create a dictionary keyed by topic or service with the corresponding ROS communication class as the value. The dictionary is used by the TCP server to direct messages to and from the ROS network.
7367

74-
`RosSubscriber('color', UnityColor, tcp_server)`
68+
```python
69+
tcp_server.source_destination_dict = {
70+
'pos_srv': RosService('position_service', PositionService),
71+
'pos_rot': RosPublisher('pos_rot', PosRot, queue_size=10),
72+
'color': RosSubscriber('color', Color, tcp_server),
73+
}
74+
```
7575

7676
## ROS Service
7777
A ROS Service requires two components:
@@ -81,26 +81,28 @@ A ROS Service requires two components:
8181

8282
`RosService('position_service', PositionService)`
8383

84-
## Creating the Server
84+
## ROS Publisher
85+
A ROS Publisher requires three components:
8586

86-
Requires:
87+
- Topic name
88+
- ROS message class generated from running `catkin_make` command
89+
- Queue size
8790

88-
- The ROS node name
91+
`RosPublisher('pos_rot', PosRot, queue_size=10)`
8992

90-
```python
91-
tcp_server = TcpServer(ros_node_name)
92-
```
93+
## ROS Subscriber
94+
A ROS Subscriber requires three components:
9395

94-
## Source Destination Dictionary
96+
- Topic name
97+
- ROS message class generated from running `catkin_make` command
98+
- The tcp server that will connect to Unity
9599

96-
Create a dictionary keyed by topic or service with the corresponding ROS communication class as the value. The dictionary is used by the TCP server to direct messages to and from the ROS network.
100+
`RosSubscriber('color', UnityColor, tcp_server)`
101+
102+
## Instantiate the ROS Node
97103

98104
```python
99-
tcp_server.source_destination_dict = {
100-
'pos_srv': RosService('position_service', PositionService),
101-
'pos_rot': RosPublisher('pos_rot', PosRot, queue_size=10),
102-
'color': RosSubscriber('color', Color, tcp_server),
103-
}
105+
rospy.init_node(ros_node_name, anonymous=True)
104106
```
105107

106108
## Starting the Server

tutorials/ros_unity_integration/subscriber.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class RosSubscriberExample : MonoBehaviour
5050
}
5151
```
5252

53-
- Create an empty GameObject, name it `RosConnection` and attach the `Plugins/TcpConnector/ROSConnection` script. (Or, if you're reusing the same scene from the Publisher tutorial, you can just keep the existing RosConnection object.)
53+
- Create an empty GameObject, name it `RosConnection` and attach the `Packages/ROS TCP Connection/Runtime/TcpConnector/ROSConnection` script. (Or, if you're reusing the same scene from the Publisher tutorial, you can just keep the existing RosConnection object.)
5454
- Change the host name and port to match the ROS IP and port variables defined when you set up ROS.
5555
- The IP for Unity to listen on should be determined automatically, but if you're having trouble, you can set it manually in the `Override Unity IP` field. Finding the IP address of your local machine (the one running Unity) depends on your operating system.
5656
- On a Mac, open `System Preferences > Network`. Your IP address should be listed on the active connection.

tutorials/urdf_importer/urdf_appendix.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,18 @@ To address this predicament we have integrated another algorithm to create Conve
316316

317317
![](images/ConvexMeshComparison.png)
318318

319+
## Disable Collision Support
320+
URDF defines the robot visually using Visual Meshes, and its collision using Collision Meshes. Collision meshes define the physical volume of the links, and are used to calculate the inertia of the links and also to detect collisions between different physical objects. In Unity, rigidbodies cannot have concave collision meshes, so when importing a concave collision mesh, all concave regions are closed over to produce a convex outline. As a result, the convex shapes might intersect with each other, creating a hindrance in robot movement. To remedy this, we support a ```disable collision``` tag in URDF. To add an exception for collision detection in Unity:
321+
322+
1. Identify the links between which you want to ignore the collisions.
323+
2. Add a tag in the URDF file with the format
324+
```XML
325+
<disable_collision link1= <name_of_link_1> link2=<name_of_link_2>>
326+
</disable_collision>
327+
```
328+
An example of the tag can be seen [here](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/tutorials/pick_and_place/PickAndPlaceProject/Assets/URDF/niryo_one/niryo_one.urdf#L223).
319329

330+
The disable collision tag flags the links that need to be ignored to the URDF parser. Values of link1 and link2 attributes are the names of the two links between which the collision needs to be ignored. Make sure the names of the links match the names defined in the URDF file.
320331

332+
Note: You can also manually ignore collisions in Unity using [APIs](https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html).
321333

0 commit comments

Comments
 (0)