浏览代码

[AIRO-302] Add pick&place docker (#65)

* add dockerfile and executable

* update tutorials

* Adjusting docker image to allow building on Windows

Co-authored-by: Devin Miller <devin.miller@unity3d.com>
/fix-file-mode
GitHub 4 年前
当前提交
b393fed6
共有 7 个文件被更改,包括 95 次插入1 次删除
  1. 28
      tutorials/pick_and_place/2_ros_tcp.md
  2. 22
      tutorials/pick_and_place/3_pick_and_place.md
  3. 2
      tutorials/pick_and_place/ROS/.gitignore
  4. 21
      tutorials/pick_and_place/docker/Dockerfile
  5. 5
      tutorials/pick_and_place/docker/set-up-workspace
  6. 18
      tutorials/pick_and_place/docker/tutorial

28
tutorials/pick_and_place/2_ros_tcp.md


- Replace the `Host Name` value with the IP address of your ROS machine. Ensure that the `Host Port` is set to `10000`.
- If you are going to run ROS services with docker container introduced [below](#the-ros-side), fill `Host Name` and `Override Unity IP` with the loopback IP address `127.0.0.1`.
1. To call the `Publish()` function, a UI element will be added for user input. In the Hierarchy window, right click to add a new UI > Button. Note that this will create a new Canvas parent as well.
> Note: In the `Game` view, you will see the button appear in the bottom left corner as an overlay. In `Scene` view the button will be rendered on a canvas object that may not be visible.

> Note: This project has been tested with Python 2 and ROS Melodic, as well as Python 3 and ROS Noetic.
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.
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. Two methods are provideds to launch ROS nodes and services: either using a ROS docker container or doing it manually in your own ROS environment.
### Use Docker Container
1. [Install Docker Engine](https://docs.docker.com/engine/install/)
2. Build the ROS docker image
```bash
cd /YOUR/UNITY-ROBOTICS-HUB/REPOSITORY/tutorials/pick_and_place &&
git submodule update --init --recursive &&
docker build -t unity-robotics:pick-and-place -f docker/Dockerfile .
```
3. Run ROS in a new docker container
```bash
docker run -it --rm -p 10000:10000 -p 5005:5005 unity-robotics:pick-and-place part_2 /bin/bash
```
4. Terminate docker container
Press `Ctrl + C` or `Cmd + C` to terminate the docker container.
### Manually Setup ROS
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:

22
tutorials/pick_and_place/3_pick_and_place.md


> 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.
### Use Docker Container
1. If you are using ROS docker container and have not already build the ROS docker image. Follow the steps in [Part 2](2_ros_tcp.md) to build the `unity-robotics:pick-and-place` docker image.
### Manually Setup ROS
1. If you have not already built and sourced the ROS workspace since importing the new ROS packages, navigate to your ROS workplace, e.g. `Unity-Robotics-Hub/tutorials/pick_and_place/ROS/`, run `catkin_make && source devel/setup.bash`. Ensure there are no errors.
1. If you have not already set the ROS parameter values in the `params.yaml`, navigate to `src/niryo_moveit/config/params.yaml` and open the file for editing. Follow the steps in [Part 2](2_ros_tcp.md) to configure the values.

---
## ROS–Unity Communication
### Use Docker Container
1. If you have not already, [build the ROS docker image](2_ros_tcp.md#use-docker-container) before executing the following command lines.
2. Run ROS in a new docker container
```bash
docker run -it --rm -p 10000:10000 -p 5005:5005 unity-robotics:pick-and-place part_3 /bin/bash
```
3. Terminate docker container
Press `Ctrl + C` or `Cmd + C` to terminate the docker container.
### Manually Setup ROS
1. Open a new terminal window in the ROS workspace. Once again, source the workspace.

2
tutorials/pick_and_place/ROS/.gitignore


build
devel

21
tutorials/pick_and_place/docker/Dockerfile


FROM ros:melodic-ros-base
RUN sudo apt-get update && sudo apt-get install -y vim iputils-ping net-tools 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 dos2unix
RUN sudo -H pip install rospkg jsonpickle
ENV ROS_WORKSPACE=/catkin_ws
# Copy each directory explicitly to avoid workspace cruft
COPY ./ROS/src/moveit_msgs $ROS_WORKSPACE/src/moveit_msgs
COPY ./ROS/src/niryo_moveit $ROS_WORKSPACE/src/niryo_moveit
COPY ./ROS/src/niryo_one_ros $ROS_WORKSPACE/src/niryo_one_ros
COPY ./ROS/src/niryo_one_urdf $ROS_WORKSPACE/src/niryo_one_urdf
COPY ./ROS/src/ros_tcp_endpoint $ROS_WORKSPACE/src/ros_tcp_endpoint
COPY ./docker/set-up-workspace /setup.sh
COPY docker/tutorial /
RUN dos2unix /tutorial && dos2unix /setup.sh && chmod +x /setup.sh && /setup.sh && rm /setup.sh
ENTRYPOINT ["/tutorial"]

5
tutorials/pick_and_place/docker/set-up-workspace


#!/bin/bash
source /opt/ros/melodic/setup.bash
cd $ROS_WORKSPACE
catkin_make

18
tutorials/pick_and_place/docker/tutorial


#!/bin/bash
help()
{
echo "Syntax: $0 [part_2|part_3]"
}
source $ROS_WORKSPACE/devel/setup.bash
echo "ROS_IP: $(hostname -i)" > $ROS_WORKSPACE/src/niryo_moveit/config/params.yaml
if [ $1 == "part_2" ]; then
roslaunch niryo_moveit part_2.launch
elif [ $1 == "part_3" ]; then
roslaunch niryo_moveit part_3.launch
else
help
fi
正在加载...
取消
保存