Skip to content

Commit 36cdb6a

Browse files
Updated pick & place tutorial for new message naming (#250)
1 parent 53216d8 commit 36cdb6a

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

tutorials/pick_and_place/2_ros_tcp.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
5555

5656
![](img/2_robottraj.png)
5757

58-
- One new C# script should populate the `Assets/RosMessages/Moveit/msg` directory: MRobotTrajectory. This name is the same as the message you built, with an "M" prefix (for message).
58+
- One new C# script should populate the `Assets/RosMessages/Moveit/msg` directory: RobotTrajectoryMsg.cs. This name is the same as the message you built, with an "Msg" suffix (for message).
5959

6060
1. Next, the custom message scripts for this tutorial will need to be generated.
6161

6262
Still in the ROS Message Browser window, expand `ROS/src/niryo_moveit/msg` to view the msg files listed. Next to msg, click `Build 2 msgs`.
6363

6464
![](img/2_msg.png)
6565

66-
- Two new C# scripts should populate the `Assets/RosMessages/NiryoMoveit/msg` directory: MNiryoMoveitJoints and MNiryoTrajectory. MNiryoMoveitJoints describes a value for each joint in the Niryo arm as well as poses for the target object and target goal. MNiryoTrajectory describes a list of RobotTrajectory values, which will hold the calculated trajectories for the pick-and-place task.
66+
- Two new C# scripts should populate the `Assets/RosMessages/NiryoMoveit/msg` directory: NiryoMoveitJointsMsg.cs and NiryoTrajectoryMsg.cs. The NiryoMoveitJoints message describes a value for each joint in the Niryo arm as well as poses for the target object and target goal. NiryoTrajectory describes a list of RobotTrajectory values, which will hold the calculated trajectories for the pick-and-place task.
6767

6868
> MessageGeneration generates a C# class from a ROS msg file with protections for use of C# reserved keywords and conversion to C# datatypes. Learn more about [ROS Messages](https://wiki.ros.org/Messages).
6969
@@ -73,7 +73,7 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
7373

7474
![](img/2_srv.png)
7575

76-
- Two new C# scripts should populate the `Assets/RosMessages/NiryoMoveit/srv` directory: MMoverServiceRequest and MMoverServiceResponse. These files describe the expected input and output formats for the service requests and responses when calculating trajectories.
76+
- Two new C# scripts should populate the `Assets/RosMessages/NiryoMoveit/srv` directory: MoverServiceRequest and MoverServiceResponse. These files describe the expected input and output formats for the service requests and responses when calculating trajectories.
7777

7878
> MessageGeneration generates two C# classes, a request and response, from a ROS srv file with protections for use of C# reserved keywords and conversion to C# datatypes. Learn more about [ROS Services](https://wiki.ros.org/Services).
7979
@@ -86,7 +86,7 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
8686
```csharp
8787
public void Publish()
8888
{
89-
MNiryoMoveitJoints sourceDestinationMessage = new MNiryoMoveitJoints();
89+
NiryoMoveitJointsMsg sourceDestinationMessage = new NiryoMoveitJointsMsg();
9090

9191
sourceDestinationMessage.joint_00 = jointArticulationBodies[0].xDrive.target;
9292
sourceDestinationMessage.joint_01 = jointArticulationBodies[1].xDrive.target;
@@ -96,15 +96,15 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
9696
sourceDestinationMessage.joint_05 = jointArticulationBodies[5].xDrive.target;
9797

9898
// Pick Pose
99-
sourceDestinationMessage.pick_pose = new MPose
99+
sourceDestinationMessage.pick_pose = new PoseMsg
100100
{
101101
position = target.transform.position.To<FLU>(),
102102
// The hardcoded x/z angles assure that the gripper is always positioned above the target cube before grasping.
103103
orientation = Quaternion.Euler(90, target.transform.eulerAngles.y, 0).To<FLU>()
104104
};
105105

106106
// Place Pose
107-
sourceDestinationMessage.place_pose = new MPose
107+
sourceDestinationMessage.place_pose = new PoseMsg
108108
{
109109
position = targetPlacement.transform.position.To<FLU>(),
110110
orientation = pickOrientation.To<FLU>()
@@ -117,7 +117,7 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
117117

118118
> This function first takes in the current joint target values. Then, it grabs the poses of the `target` and the `targetPlacement` objects, adds them to the newly created message `sourceDestinationMessage`, and calls `Send()` to send this information to the ROS topic `topicName` (defined as `"SourceDestination_input"`).
119119
120-
> Note: Going from Unity world space to ROS world space requires a conversion. Unity's `(x,y,z)` is equivalent to the ROS `(z,-x,y)` coordinate. These conversions are provided via the [ROSGeometry component](https://github.com/Unity-Technologies/ROS-TCP-Connector/blob/main/ROSGeometry.md) in the ROS-TCP-Connector package.
120+
> Note: Going from Unity world space to ROS world space requires a conversion. Unity's coordinate space has x Right, y Up, and z Forward (hence "RUF" coordinates); ROS has x Forward, y Left and z Up (hence "FLU"). So a Unity `(x,y,z)` coordinate is equivalent to the ROS `(z,-x,y)` coordinate. These conversions are done by the `To<FLU>` function in the ROS-TCP-Connector package's [ROSGeometry component](https://github.com/Unity-Technologies/ROS-TCP-Connector/blob/main/ROSGeometry.md).
121121
122122
1. Return to the Unity Editor. Now that the message contents have been defined and the publisher script added, it needs to be added to the Unity world to run its functionality.
123123

tutorials/pick_and_place/3_pick_and_place.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
3131
```csharp
3232
public void PublishJoints()
3333
{
34-
MMoverServiceRequest request = new MMoverServiceRequest();
34+
MoverServiceRequest request = new MoverServiceRequest();
3535
request.joints_input = CurrentJointConfig();
3636

3737
// Pick Pose
38-
request.pick_pose = new MPose
38+
request.pick_pose = new PoseMsg
3939
{
4040
position = (target.transform.position + pickPoseOffset).To<FLU>(),
4141
// The hardcoded x/z angles assure that the gripper is always positioned above the target cube before grasping.
4242
orientation = Quaternion.Euler(90, target.transform.eulerAngles.y, 0).To<FLU>()
4343
};
4444

4545
// Place Pose
46-
request.place_pose = new MPose
46+
request.place_pose = new PoseMsg
4747
{
4848
position = (targetPlacement.transform.position + pickPoseOffset).To<FLU>(),
4949
orientation = pickOrientation.To<FLU>()
5050
};
5151

52-
ros.SendServiceMessage<MMoverServiceResponse>(rosServiceName, request, TrajectoryResponse);
52+
ros.SendServiceMessage<MoverServiceResponse>(rosServiceName, request, TrajectoryResponse);
5353
}
5454

55-
void TrajectoryResponse(MMoverServiceResponse response)
55+
void TrajectoryResponse(MoverServiceResponse response)
5656
{
5757
if (response.trajectories != null)
5858
{
@@ -71,7 +71,7 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
7171
> The `response.trajectories` are received in the `TrajectoryResponse()` callback, as defined in the `ros.SendServiceMessage` parameters. These trajectories are passed to `ExecuteTrajectories()` and executed as a [coroutine](https://docs.unity3d.com/Manual/Coroutines.html):
7272
7373
```csharp
74-
private IEnumerator ExecuteTrajectories(MMoverServiceResponse response)
74+
private IEnumerator ExecuteTrajectories(MoverServiceResponse response)
7575
{
7676
if (response.trajectories != null)
7777
{

tutorials/pick_and_place/4_pick_and_place.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void Start()
265265
- The ExecuteTrajectories function has been updated to accept a single RobotTrajectory object and execute the robot poses one at a time:
266266

267267
```csharp
268-
private IEnumerator ExecuteTrajectories(RobotTrajectory trajectories)
268+
private IEnumerator ExecuteTrajectories(RobotTrajectoryMsg trajectories)
269269
{
270270
// For every robot pose in trajectory plan
271271
foreach (var point in trajectories.joint_trajectory.points)

tutorials/pick_and_place/PickAndPlaceProject/Assets/RosMessages/Unity.Robotics.RosMessages.asmdef

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"autoReferenced": true,
1313
"defineConstraints": [],
1414
"versionDefines": [],
15-
"noEngineReferences": true
15+
"noEngineReferences": false
1616
}

tutorials/pick_and_place/PickAndPlaceProject/Packages/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"com.unity.ide.rider": "2.0.7",
55
"com.unity.ide.visualstudio": "2.0.8",
66
"com.unity.ide.vscode": "1.2.3",
7-
"com.unity.robotics.ros-tcp-connector": "https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector#v0.4.0",
7+
"com.unity.robotics.ros-tcp-connector": "https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector#dev",
88
"com.unity.robotics.urdf-importer": "https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#stl-package-import-fix",
99
"com.unity.test-framework": "1.1.24",
1010
"com.unity.textmeshpro": "3.0.6",

tutorials/pick_and_place/Scripts_Part4/RealSimPickAndPlace.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void OpenGripper()
8181
/// </summary>
8282
public void PublishJoints()
8383
{
84-
MMoverServiceRequest request = new MMoverServiceRequest
84+
MoverServiceRequest request = new MoverServiceRequest
8585
{
8686
joints_input =
8787
{
@@ -92,13 +92,13 @@ public void PublishJoints()
9292
joint_04 = jointArticulationBodies[4].xDrive.target,
9393
joint_05 = jointArticulationBodies[5].xDrive.target
9494
},
95-
pick_pose = new MPose
95+
pick_pose = new PoseMsg
9696
{
9797
position = (target.transform.position + PICK_POSE_OFFSET).To<FLU>(),
9898
// The hardcoded x/z angles assure that the gripper is always positioned above the target cube before grasping.
9999
orientation = Quaternion.Euler(90, target.transform.eulerAngles.y, 0).To<FLU>()
100100
},
101-
place_pose = new MPose
101+
place_pose = new PoseMsg
102102
{
103103
position = (targetPlacement.transform.position + PICK_POSE_OFFSET).To<FLU>(),
104104
orientation = pickOrientation.To<FLU>()
@@ -146,7 +146,7 @@ void Awake()
146146

147147
void Start()
148148
{
149-
ros.Subscribe<MRobotMoveActionGoal>(rosRobotCommandsTopicName, ExecuteRobotCommands);
149+
ros.Subscribe<RobotMoveActionGoal>(rosRobotCommandsTopicName, ExecuteRobotCommands);
150150
}
151151

152152
/// <summary>
@@ -155,7 +155,7 @@ void Start()
155155
/// executed in a coroutine.
156156
/// </summary>
157157
/// <param name="robotAction"> RobotMoveActionGoal of trajectory or gripper commands</param>
158-
void ExecuteRobotCommands(MRobotMoveActionGoal robotAction)
158+
void ExecuteRobotCommands(RobotMoveActionGoal robotAction)
159159
{
160160
if (robotAction.goal.cmd.cmd_type == TRAJECTORY_COMMAND_EXECUTION)
161161
{
@@ -184,7 +184,7 @@ void ExecuteRobotCommands(MRobotMoveActionGoal robotAction)
184184
///
185185
/// </summary>
186186
/// <param name="trajectories"> The array of poses for the robot to execute</param>
187-
private IEnumerator ExecuteTrajectories(MRobotTrajectory trajectories)
187+
private IEnumerator ExecuteTrajectories(RobotTrajectoryMsg trajectories)
188188
{
189189
// For every robot pose in trajectory plan
190190
foreach (var point in trajectories.joint_trajectory.points)

0 commit comments

Comments
 (0)