Skip to content

Commit ac5bc23

Browse files
Making pick_and_place Noetic compatible (#58)
* Making pick_and_place Noetic compatible
1 parent 14605fc commit ac5bc23

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

tutorials/pick_and_place/2_ros_tcp.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,24 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
172172

173173
## The ROS side
174174

175-
> Note: This project was built using the ROS Melodic distro and Python 2.
175+
> Note: This project has been tested with Python 2 and ROS Melodic, as well as Python 3 and ROS Noetic.
176176
177177
Most of the ROS setup has been provided via the `niryo_moveit` package. This section will describe the `.launch` files and start the necessary ROS nodes for communication.
178178

179-
1. The provided files require the following packages to be installed; run the following if the packages are not already present:
179+
1. The provided files require the following packages to be installed. ROS Melodic users should run the following commands if the packages are not already present:
180180

181181
```bash
182182
sudo apt-get update && sudo apt-get upgrade
183183
sudo apt-get install python-pip ros-melodic-robot-state-publisher ros-melodic-moveit ros-melodic-rosbridge-suite ros-melodic-joy ros-melodic-ros-control ros-melodic-ros-controllers ros-melodic-tf2-web-republisher
184+
sudo -H pip install rospkg jsonpickle
184185
```
185186

187+
ROS Noetic users should run:
188+
186189
```bash
187-
sudo -H pip install rospkg jsonpickle
190+
sudo apt-get update && sudo apt-get upgrade
191+
sudo apt-get install python3-pip ros-noetic-robot-state-publisher ros-noetic-moveit ros-noetic-rosbridge-suite ros-noetic-joy ros-noetic-ros-control ros-noetic-ros-controllers
192+
sudo -H pip3 install rospkg jsonpickle
188193
```
189194

190195
> In your ROS workspace, find the directory `src/niryo_moveit/scripts`. Note the file `server_endpoint.py`. This script imports the necessary dependencies from tcp_endpoint and starts the server. `rospy.spin()` ensures the node does not exit until it is shut down.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ROS_IP: 127.0.0.1
1+
ROS_IP: 127.0.0.1

tutorials/pick_and_place/ROS/src/niryo_moveit/scripts/mover.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222

2323
joint_names = ['joint_1', 'joint_2', 'joint_3', 'joint_4', 'joint_5', 'joint_6']
2424

25+
# Between Melodic and Noetic, the return type of plan() changed. moveit_commander has no __version__ variable, so checking the python version as a proxy
26+
if sys.version_info >= (3, 0):
27+
def planCompat(plan):
28+
return plan[1]
29+
else:
30+
def planCompat(plan):
31+
return plan
32+
2533
"""
2634
Given the start angles of the robot, plan a trajectory that ends at the destination pose.
2735
"""
@@ -44,7 +52,7 @@ def plan_trajectory(move_group, destination_pose, start_joint_angles):
4452
""".format(destination_pose, destination_pose)
4553
raise Exception(exception_str)
4654

47-
return move_group.plan()
55+
return planCompat(move_group.plan())
4856

4957

5058
"""

0 commit comments

Comments
 (0)