浏览代码

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>
/devin-main-fix
GitHub 4 年前
当前提交
f6324b5f
共有 4 个文件被更改,包括 45 次插入31 次删除
  1. 2
      tutorials/pick_and_place/2_ros_tcp.md
  2. 60
      tutorials/ros_unity_integration/server_endpoint.md
  3. 2
      tutorials/ros_unity_integration/subscriber.md
  4. 12
      tutorials/urdf_importer/urdf_appendix.md

2
tutorials/pick_and_place/2_ros_tcp.md


1. Next, the object that will hold the TCP functionality needs to be added.
Create another GameObject, name it RosConnect, and add the script `Assets/Plugins/TCPConnector/ROSConnection` to it in the same way.
Create another GameObject, name it RosConnect, and add the script `Packages/ROS TCP Connection/Runtime/TcpConnector/ROSConnection` to it in the same way.
1. Note that these components show empty member variables in the Inspector window, which need to be assigned.

60
tutorials/ros_unity_integration/server_endpoint.md


The following is an example of a server endpoint Python script that:
- Gets parameters from `rosparam`
- Creates corresponding ROS Publisher, Subscriber, and Service objects to interact with topics and services running in in ROS network
- Creates corresponding ROS Publisher, Subscriber, and Service objects to interact with topics and services running in ROS network
- Starts TCP Server process to handle incoming and outgoing connections

from robotics_demo.srv import PositionService
```
## Creating the Server
## Instantiate the ROS Node
Requires:
- The ROS node name
rospy.init_node(ros_node_name, anonymous=True)
tcp_server = TcpServer(ros_node_name, buffer_size=1024, connections=10)
## ROS Publisher
A ROS Publisher requires three components:
- Topic name
- ROS message class generated from running `catkin_make` command
- Queue size
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.
`RosPublisher('pos_rot', PosRot, queue_size=10)`
## ROS Subscriber
A ROS Subscriber requires three components:
## Source Destination Dictionary
- Topic name
- ROS message class generated from running `catkin_make` command
- The tcp server that will connect to Unity
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.
`RosSubscriber('color', UnityColor, tcp_server)`
```python
tcp_server.source_destination_dict = {
'pos_srv': RosService('position_service', PositionService),
'pos_rot': RosPublisher('pos_rot', PosRot, queue_size=10),
'color': RosSubscriber('color', Color, tcp_server),
}
```
## ROS Service
A ROS Service requires two components:

`RosService('position_service', PositionService)`
## Creating the Server
## ROS Publisher
A ROS Publisher requires three components:
Requires:
- Topic name
- ROS message class generated from running `catkin_make` command
- Queue size
- The ROS node name
`RosPublisher('pos_rot', PosRot, queue_size=10)`
```python
tcp_server = TcpServer(ros_node_name)
```
## ROS Subscriber
A ROS Subscriber requires three components:
## Source Destination Dictionary
- Topic name
- ROS message class generated from running `catkin_make` command
- The tcp server that will connect to Unity
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.
`RosSubscriber('color', UnityColor, tcp_server)`
## Instantiate the ROS Node
tcp_server.source_destination_dict = {
'pos_srv': RosService('position_service', PositionService),
'pos_rot': RosPublisher('pos_rot', PosRot, queue_size=10),
'color': RosSubscriber('color', Color, tcp_server),
}
rospy.init_node(ros_node_name, anonymous=True)
```
## Starting the Server

2
tutorials/ros_unity_integration/subscriber.md


}
```
- 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.)
- 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.)
- Change the host name and port to match the ROS IP and port variables defined when you set up ROS.
- 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.
- On a Mac, open `System Preferences > Network`. Your IP address should be listed on the active connection.

12
tutorials/urdf_importer/urdf_appendix.md


![](images/ConvexMeshComparison.png)
## Disable Collision Support
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:
1. Identify the links between which you want to ignore the collisions.
2. Add a tag in the URDF file with the format
```XML
<disable_collision link1= <name_of_link_1> link2=<name_of_link_2>>
</disable_collision>
```
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).
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.
Note: You can also manually ignore collisions in Unity using [APIs](https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html).
正在加载...
取消
保存