Skip to content

Commit 7f238d9

Browse files
authored
Merge pull request #288 from Unity-Technologies/dev
Syncing dev to main
2 parents 7804d65 + 82e565b commit 7f238d9

File tree

8 files changed

+47
-35
lines changed

8 files changed

+47
-35
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ Changed the Pick and Place Demo's topic from SourceDestination to SourceDestinat
2020

2121
### Removed
2222

23-
### Fixed
23+
### Fixed
24+
25+
Fixed the ROS-Unity Integration tutorial to use the correct link to install ROS-TCP-Connector package
26+
27+
Fixed the Pick and Place Tutorial to use ArticulationBody jointPositions, rather than the xDrive.target, for updating the current joint angle positions
28+
29+
Fixed network.md in ROS-Unity Integration tutorial by removing the obsolete UNITY_IP

tutorials/pick_and_place/PickAndPlaceProject/Assets/Scripts/Unity.Robotics.PickAndPlace.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"rootNamespace": "",
44
"references": [
55
"GUID:204b12c73a0ba074c888ec09a2713605",
6-
"GUID:625bfc588fb96c74696858f2c467e978"
6+
"GUID:625bfc588fb96c74696858f2c467e978",
7+
"GUID:b1ef917f7a8a86a4eb639ec2352edbf8"
78
],
89
"includePlatforms": [],
910
"excludePlatforms": [],

tutorials/pick_and_place/Scripts/SourceDestinationPublisher.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnityEngine;
33
using Unity.Robotics.ROSTCPConnector;
44
using Unity.Robotics.ROSTCPConnector.ROSGeometry;
5+
using Unity.Robotics.UrdfImporter;
56
using RosMessageTypes.Geometry;
67

78
public class SourceDestinationPublisher : MonoBehaviour
@@ -19,8 +20,8 @@ public class SourceDestinationPublisher : MonoBehaviour
1920
private int numRobotJoints = 6;
2021
private readonly Quaternion pickOrientation = Quaternion.Euler(90, 90, 0);
2122

22-
// Articulation Bodies
23-
private ArticulationBody[] jointArticulationBodies;
23+
// Robot Joints
24+
private UrdfJointRevolute[] revoluteJoints;
2425

2526
/// <summary>
2627
///
@@ -30,36 +31,36 @@ void Start()
3031
// Get ROS connection static instance
3132
ros = ROSConnection.instance;
3233

33-
jointArticulationBodies = new ArticulationBody[numRobotJoints];
34+
revoluteJoints = new UrdfJointRevolute[numRobotJoints];
3435
string shoulder_link = "world/base_link/shoulder_link";
35-
jointArticulationBodies[0] = niryoOne.transform.Find(shoulder_link).GetComponent<ArticulationBody>();
36+
revoluteJoints[0] = niryoOne.transform.Find(shoulder_link).GetComponent<UrdfJointRevolute>();
3637

3738
string arm_link = shoulder_link + "/arm_link";
38-
jointArticulationBodies[1] = niryoOne.transform.Find(arm_link).GetComponent<ArticulationBody>();
39+
revoluteJoints[1] = niryoOne.transform.Find(arm_link).GetComponent<UrdfJointRevolute>();
3940

4041
string elbow_link = arm_link + "/elbow_link";
41-
jointArticulationBodies[2] = niryoOne.transform.Find(elbow_link).GetComponent<ArticulationBody>();
42+
revoluteJoints[2] = niryoOne.transform.Find(elbow_link).GetComponent<UrdfJointRevolute>();
4243

4344
string forearm_link = elbow_link + "/forearm_link";
44-
jointArticulationBodies[3] = niryoOne.transform.Find(forearm_link).GetComponent<ArticulationBody>();
45+
revoluteJoints[3] = niryoOne.transform.Find(forearm_link).GetComponent<UrdfJointRevolute>();
4546

4647
string wrist_link = forearm_link + "/wrist_link";
47-
jointArticulationBodies[4] = niryoOne.transform.Find(wrist_link).GetComponent<ArticulationBody>();
48+
revoluteJoints[4] = niryoOne.transform.Find(wrist_link).GetComponent<UrdfJointRevolute>();
4849

4950
string hand_link = wrist_link + "/hand_link";
50-
jointArticulationBodies[5] = niryoOne.transform.Find(hand_link).GetComponent<ArticulationBody>();
51+
revoluteJoints[5] = niryoOne.transform.Find(hand_link).GetComponent<UrdfJointRevolute>();
5152
}
5253

5354
public void Publish()
5455
{
5556
NiryoMoveitJointsMsg sourceDestinationMessage = new NiryoMoveitJointsMsg();
5657

57-
sourceDestinationMessage.joint_00 = jointArticulationBodies[0].xDrive.target;
58-
sourceDestinationMessage.joint_01 = jointArticulationBodies[1].xDrive.target;
59-
sourceDestinationMessage.joint_02 = jointArticulationBodies[2].xDrive.target;
60-
sourceDestinationMessage.joint_03 = jointArticulationBodies[3].xDrive.target;
61-
sourceDestinationMessage.joint_04 = jointArticulationBodies[4].xDrive.target;
62-
sourceDestinationMessage.joint_05 = jointArticulationBodies[5].xDrive.target;
58+
sourceDestinationMessage.joint_00 = revoluteJoints[0].GetPosition() * Mathf.Rad2Deg;
59+
sourceDestinationMessage.joint_01 = revoluteJoints[1].GetPosition() * Mathf.Rad2Deg;
60+
sourceDestinationMessage.joint_02 = revoluteJoints[2].GetPosition() * Mathf.Rad2Deg;
61+
sourceDestinationMessage.joint_03 = revoluteJoints[3].GetPosition() * Mathf.Rad2Deg;
62+
sourceDestinationMessage.joint_04 = revoluteJoints[4].GetPosition() * Mathf.Rad2Deg;
63+
sourceDestinationMessage.joint_05 = revoluteJoints[5].GetPosition() * Mathf.Rad2Deg;
6364

6465
// Pick Pose
6566
sourceDestinationMessage.pick_pose = new PoseMsg

tutorials/pick_and_place/Scripts/TrajectoryPlanner.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ NiryoMoveitJointsMsg CurrentJointConfig()
8282
{
8383
NiryoMoveitJointsMsg joints = new NiryoMoveitJointsMsg();
8484

85-
joints.joint_00 = jointArticulationBodies[0].xDrive.target;
86-
joints.joint_01 = jointArticulationBodies[1].xDrive.target;
87-
joints.joint_02 = jointArticulationBodies[2].xDrive.target;
88-
joints.joint_03 = jointArticulationBodies[3].xDrive.target;
89-
joints.joint_04 = jointArticulationBodies[4].xDrive.target;
90-
joints.joint_05 = jointArticulationBodies[5].xDrive.target;
85+
joints.joint_00 = jointArticulationBodies[0].jointPosition[0] * Mathf.Rad2Deg;
86+
joints.joint_01 = jointArticulationBodies[1].jointPosition[0] * Mathf.Rad2Deg;
87+
joints.joint_02 = jointArticulationBodies[2].jointPosition[0] * Mathf.Rad2Deg;
88+
joints.joint_03 = jointArticulationBodies[3].jointPosition[0] * Mathf.Rad2Deg;
89+
joints.joint_04 = jointArticulationBodies[4].jointPosition[0] * Mathf.Rad2Deg;
90+
joints.joint_05 = jointArticulationBodies[5].jointPosition[0] * Mathf.Rad2Deg;
9191

9292
return joints;
9393
}
Binary file not shown.
Loading

tutorials/ros_unity_integration/network.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
- [Definitions](#definitions)
55
- [Communicaton Minimum Requirements](#communication-minimum-requirements)
66
- [If Using Docker](#if-using-docker)
7-
- [Explicitly Setting UNITY_IP](#explicitly-setting-unity_ip)
87
- [Troubleshoooting](#troubleshooting)
98
- [Where Does Communication Break Down](#where-does-communication-break-down)
109
- [1. Can Unity send messages to ROS?](#1-can-unity-send-messages-to-ros)
@@ -34,26 +33,32 @@ The container will need to be started with the following arguments to forward th
3433

3534

3635
- On the ROS side, set `ROS_IP` to `0.0.0.0`.
36+
```bash
37+
rosparam set ROS_IP 0.0.0.0
38+
```
3739

3840
- On the Unity side, set `ROS_IP` to `127.0.0.1`.
3941

40-
![](images/troubleshoot-docker-unity.png)
42+
![](images/settings_ros_ip.png)
4143

4244
# Troubleshooting
4345

4446
## Where Does Communication Break Down
4547

4648
### 1. Can Unity send messages to ROS?
4749

48-
When play is pressed in the Editor, a handshake message is sent from Unity to ROS.
50+
When play is pressed in the Editor, Unity will establish the connection to ROS using the ROS_IP.
4951

50-
If Unity can communicate with ROS, the following message should be printed to the console screen running the `server_endpoint.py` script.
52+
If Unity can communicate with ROS, you should see a heads-up display showing the connection in Unity Editor.
5153

52-
```[UnityTcpSender]: ROS-Unity Handshake received, will connect to UNITY_IP_ADDRESS:5005```
54+
![](images/troubleshoot_hud_success.png)
5355

54-
With the corresponding response message printed to the Unity console,
56+
The icon in front of ROS IP should be blue indicating the connection between Unity and ROS is successful.
5557

56-
```ROS-Unity server listening on UNITY_IP_ADDRESS:5005```
58+
59+
On ROS side, you should see a message printed to the console screen running the `server_endpoint.py` script, something similar to the following:
60+
61+
```Connection from 172.17.0.1```
5762

5863

5964
If the previous message is not shown and either of the following errors are thrown instead:
@@ -68,25 +73,24 @@ SocketException: Connection refused
6873

6974
Confirm that:
7075

71-
- `server_endpoint` is running
76+
- `server_endpoint` is running. On ROS side, you can run ```rosrun ros_tcp_endpoint default_server_endpoint.py```
7277
- You can ping ROS machine from Unity machine
7378
- From a terminal on the Unity machine, run the following command to confirm whether the ROS machine is reachable over the network. ```ping ROS_IP```
7479

7580
If issue still persists:
7681

77-
- Confirm your IP addresses
7882
- If on Windows you may need to [open ports for the firewall](#open-port-on-windows-firewall).
7983

8084
### 2. Can ROS send messages to Unity?
8185

8286
After it is confirmed that Unity can communicate with ROS, publish a message to a ROS topic to which Unity has instantiated a subscriber.
8387

88+
You can confirm the connection status by checking the heads-up display in your Unity Scene after entering the Play mode.
89+
8490
If an error is thrown in the `server_endpoint` console then ROS cannot connect to Unity.
8591

8692
If issue still persists:
8793

88-
- Confirm your IP addresses
89-
- Explicitly set the `UNITY_IP`
9094
- If on Windows you may need to [open ports for the firewall](#open-port-on-windows-firewall).
9195

9296
## Open port on Windows Firewall

tutorials/ros_unity_integration/setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Follow these steps if using ROS2:
101101
102102
## <img src="images/unity-tab-square-white.png" alt="ros2" width="24" height="24"/> Unity Setup
103103
1. Launch Unity and create a new project. The Robotics package works best with a version of Unity no older than 2020.
104-
2. Open Package Manager and click the + button at the top left corner. Select "add package from git URL" and enter "https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector#dev" to install the [ROS-TCP-Connector](https://github.com/Unity-Technologies/ROS-TCP-Connector) package.
104+
2. Open Package Manager and click the + button at the top left corner. Select "add package from git URL" and enter "https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector" to install the [ROS-TCP-Connector](https://github.com/Unity-Technologies/ROS-TCP-Connector) package.
105105
106106
![](images/add_package.png)
107107

0 commit comments

Comments
 (0)