Skip to content

Commit 67c6461

Browse files
AIRO-1211: Pick-and-Place Updates (#319)
* AIRO-1211: P&P initial cleanup * RealSim fixes, ROS script updates * Update changelog * Pre-commit fixes * PR feedback, demo fixes * Pre-commit fixes * Tutorial updates * Updated scripts to run 0.6.0 Co-authored-by: LaurieCheers <73140792+LaurieCheers-unity@users.noreply.github.com>
1 parent b04391c commit 67c6461

30 files changed

+438
-504
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Fixed the ROS-Unity Integration tutorial `robo_demo.launch` to be up-to-date wit
1010

1111
Add the [Close Stale Issues](https://github.com/marketplace/actions/close-stale-issues) action
1212

13+
Updated Pick-and-Place scripts for style conformity, updated custom msg formats and made according script and tutorial changes.
14+
1315
### Upgrade Notes
1416

1517
### Known Issues

tutorials/pick_and_place/0_ros_setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ git clone --recurse-submodules https://github.com/Unity-Technologies/Unity-Robot
3939
1. Start the newly built Docker container:
4040

4141
```docker
42-
docker run -it --rm -p 10000:10000 -p 5005:5005 unity-robotics:pick-and-place /bin/bash
42+
docker run -it --rm -p 10000:10000 unity-robotics:pick-and-place /bin/bash
4343
```
4444

4545
When this is complete, it will print: `Successfully tagged unity-robotics:pick-and-place`. This console should open into a bash shell at the ROS workspace root, e.g. `root@8d88ed579657:/catkin_ws#`.

tutorials/pick_and_place/2_ros_tcp.md

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
4747

4848
In the ROS Message Browser window, click `Browse` next to the ROS message path. Navigate to and select the ROS directory of this cloned repository (`Unity-Robotics-Hub/tutorials/pick_and_place/ROS/`). This window will populate with all msg and srv files found in this directory.
4949

50-
In the ROS Message Browser window, type in `Scripts/RosMessages` in the text field of Build message path.
51-
5250
![](img/2_browser.png)
5351

5452
> Note: If any of these ROS directories appear to be empty, you can run the command `git submodule update --init --recursive` to download the packages via Git submodules.
@@ -87,33 +85,30 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
8785
8886
```csharp
8987
public void Publish()
90-
{
91-
NiryoMoveitJointsMsg sourceDestinationMessage = new NiryoMoveitJointsMsg();
92-
93-
sourceDestinationMessage.joint_00 = jointArticulationBodies[0].xDrive.target;
94-
sourceDestinationMessage.joint_01 = jointArticulationBodies[1].xDrive.target;
95-
sourceDestinationMessage.joint_02 = jointArticulationBodies[2].xDrive.target;
96-
sourceDestinationMessage.joint_03 = jointArticulationBodies[3].xDrive.target;
97-
sourceDestinationMessage.joint_04 = jointArticulationBodies[4].xDrive.target;
98-
sourceDestinationMessage.joint_05 = jointArticulationBodies[5].xDrive.target;
99-
100-
// Pick Pose
101-
sourceDestinationMessage.pick_pose = new PoseMsg
102-
{
103-
position = target.transform.position.To<FLU>(),
104-
// The hardcoded x/z angles assure that the gripper is always positioned above the target cube before grasping.
105-
orientation = Quaternion.Euler(90, target.transform.eulerAngles.y, 0).To<FLU>()
106-
};
107-
108-
// Place Pose
109-
sourceDestinationMessage.place_pose = new PoseMsg
110-
{
111-
position = targetPlacement.transform.position.To<FLU>(),
112-
orientation = pickOrientation.To<FLU>()
113-
};
114-
115-
// Finally send the message to server_endpoint.py running in ROS
116-
ros.Send(topicName, sourceDestinationMessage);
88+
{
89+
var sourceDestinationMessage = new NiryoMoveitJointsMsg();
90+
91+
for (var i = 0; i < k_NumRobotJoints; i++)
92+
{
93+
sourceDestinationMessage.joints[i] = m_JointArticulationBodies[i].GetPosition();
94+
}
95+
96+
// Pick Pose
97+
sourceDestinationMessage.pick_pose = new PoseMsg
98+
{
99+
position = m_Target.transform.position.To<FLU>(),
100+
orientation = Quaternion.Euler(90, m_Target.transform.eulerAngles.y, 0).To<FLU>()
101+
};
102+
103+
// Place Pose
104+
sourceDestinationMessage.place_pose = new PoseMsg
105+
{
106+
position = m_TargetPlacement.transform.position.To<FLU>(),
107+
orientation = m_PickOrientation.To<FLU>()
108+
};
109+
110+
// Finally send the message to server_endpoint.py running in ROS
111+
m_Ros.Send(m_TopicName, sourceDestinationMessage);
117112
}
118113
```
119114

tutorials/pick_and_place/3_pick_and_place.md

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

3737
// Pick Pose
3838
request.pick_pose = new PoseMsg
3939
{
40-
position = (target.transform.position + pickPoseOffset).To<FLU>(),
40+
position = (m_Target.transform.position + m_PickPoseOffset).To<FLU>(),
41+
4142
// The hardcoded x/z angles assure that the gripper is always positioned above the target cube before grasping.
42-
orientation = Quaternion.Euler(90, target.transform.eulerAngles.y, 0).To<FLU>()
43+
orientation = Quaternion.Euler(90, m_Target.transform.eulerAngles.y, 0).To<FLU>()
4344
};
4445

4546
// Place Pose
4647
request.place_pose = new PoseMsg
4748
{
48-
position = (targetPlacement.transform.position + pickPoseOffset).To<FLU>(),
49-
orientation = pickOrientation.To<FLU>()
49+
position = (m_TargetPlacement.transform.position + m_PickPoseOffset).To<FLU>(),
50+
orientation = m_PickOrientation.To<FLU>()
5051
};
5152

52-
ros.SendServiceMessage<MoverServiceResponse>(rosServiceName, request, TrajectoryResponse);
53+
m_Ros.SendServiceMessage<MoverServiceResponse>(m_RosServiceName, request, TrajectoryResponse);
5354
}
5455

5556
void TrajectoryResponse(MoverServiceResponse response)
5657
{
57-
if (response.trajectories != null)
58+
if (response.trajectories.Length > 0)
5859
{
5960
Debug.Log("Trajectory returned.");
6061
StartCoroutine(ExecuteTrajectories(response));
@@ -137,12 +138,16 @@ def plan_trajectory(move_group, destination_pose, start_joint_angles):
137138
move_group.set_start_state(moveit_robot_state)
138139

139140
move_group.set_pose_target(destination_pose)
140-
plan = move_group.go(wait=True)
141+
plan = move_group.plan()
141142

142143
if not plan:
143-
print("RAISE NO PLAN ERROR")
144+
exception_str = """
145+
Trajectory could not be planned for a destination of {} with starting joint angles {}.
146+
Please make sure target and destination are reachable by the robot.
147+
""".format(destination_pose, destination_pose)
148+
raise Exception(exception_str)
144149

145-
return move_group.plan()
150+
return planCompat(plan)
146151
```
147152

148153
> This creates a set of planned trajectories, iterating through a pre-grasp, grasp, pick up, and place set of poses. Finally, this set of trajectories is sent back to Unity.

tutorials/pick_and_place/PickAndPlaceProject/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# Ignore scripts that are expected to get copied in at some point
1717
/**/SourceDestinationPublisher.*
1818
/**/TrajectoryPlanner.*
19+
/**/RealSimPickAndPlace.*
1920

2021

2122
# MemoryCaptures can get excessive in size.

0 commit comments

Comments
 (0)