Repository: intel/ros2_grasp_library
Branch: master
Commit: 980b7ddd4348
Files: 139
Total size: 13.7 MB
Directory structure:
gitextract_b6simm2f/
├── .gitignore
├── CHANGELOG.rst
├── LICENSE
├── README.md
├── docker/
│ ├── Dockerfile
│ ├── README.md
│ ├── script/
│ │ ├── 00_ros2_install.sh
│ │ ├── 10_eigen_install.sh
│ │ ├── 11_libpcl_install.sh
│ │ ├── 12_opencv_install.sh
│ │ ├── 13_openvino_install.sh
│ │ ├── 20_librealsense_install.sh
│ │ ├── 30_gpg_install.sh
│ │ ├── 31_gpd_install.sh
│ │ ├── 32_ur_modern_driver_install.sh
│ │ ├── 50_ros2_deps.sh
│ │ ├── install_ros2_grasp_library.sh
│ │ ├── ros_entrypoint.sh
│ │ └── ros_env.sh
│ └── setup_docker_display.sh
├── grasp_apps/
│ ├── draw_x/
│ │ ├── CMakeLists.txt
│ │ ├── launch/
│ │ │ ├── draw_x.launch.py
│ │ │ └── draw_x.yaml
│ │ ├── package.xml
│ │ └── src/
│ │ └── draw_x.cpp
│ ├── fixed_position_pick/
│ │ ├── CMakeLists.txt
│ │ ├── launch/
│ │ │ ├── fixed_position_pick.launch.py
│ │ │ └── fixed_position_pick.yaml
│ │ ├── package.xml
│ │ └── src/
│ │ └── fixed_position_pick.cpp
│ ├── random_pick/
│ │ ├── CMakeLists.txt
│ │ ├── cfg/
│ │ │ └── random_pick.yaml
│ │ ├── package.xml
│ │ └── src/
│ │ └── random_pick.cpp
│ └── recognize_pick/
│ ├── CMakeLists.txt
│ ├── cfg/
│ │ └── recognize_pick.yaml
│ ├── package.xml
│ └── src/
│ ├── place_publisher.cpp
│ └── recognize_pick.cpp
├── grasp_msgs/
│ ├── CMakeLists.txt
│ ├── msg/
│ │ ├── CloudIndexed.msg
│ │ ├── CloudSamples.msg
│ │ ├── CloudSources.msg
│ │ ├── GraspConfig.msg
│ │ ├── GraspConfigList.msg
│ │ └── SamplesMsg.msg
│ └── package.xml
├── grasp_ros2/
│ ├── CMakeLists.txt
│ ├── cfg/
│ │ ├── grasp_ros2_params.yaml
│ │ ├── random_pick.yaml
│ │ ├── recognize_pick.yaml
│ │ └── test_grasp_ros2.yaml
│ ├── include/
│ │ └── grasp_library/
│ │ └── ros2/
│ │ ├── consts.hpp
│ │ ├── grasp_detector_base.hpp
│ │ ├── grasp_detector_gpd.hpp
│ │ ├── grasp_planner.hpp
│ │ └── ros_params.hpp
│ ├── package.xml
│ ├── src/
│ │ ├── consts.cpp
│ │ ├── grasp_composition.cpp
│ │ ├── grasp_detector_gpd.cpp
│ │ ├── grasp_planner.cpp
│ │ └── ros_params.cpp
│ └── tests/
│ ├── CMakeLists.txt
│ ├── resource/
│ │ └── table_top.pcd
│ ├── tgrasp_ros2.cpp
│ └── tgrasp_ros2.h.in
├── grasp_tutorials/
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── _static/
│ │ └── images/
│ │ └── workflow.vsdx
│ ├── conf.py
│ ├── doc/
│ │ ├── bringup_robot.rst
│ │ ├── draw_x.rst
│ │ ├── fixed_position_pick.rst
│ │ ├── getting_start.rst
│ │ ├── grasp_api.rst
│ │ ├── grasp_planner.rst
│ │ ├── grasp_ros2/
│ │ │ ├── install_gpd.md
│ │ │ ├── install_openvino.md
│ │ │ ├── tutorials_1_grasp_ros2_with_camera.md
│ │ │ ├── tutorials_2_grasp_ros2_test.md
│ │ │ └── tutorials_3_grasp_ros2_launch_options.md
│ │ ├── handeye_calibration.rst
│ │ ├── overview.rst
│ │ ├── random_pick.rst
│ │ ├── recognize_pick.rst
│ │ ├── robot_interface.rst
│ │ └── template.rst
│ ├── index.rst
│ └── package.xml
├── grasp_utils/
│ ├── handeye_dashboard/
│ │ ├── README.md
│ │ ├── config/
│ │ │ └── Default.perspective
│ │ ├── data/
│ │ │ ├── camera-robot.json
│ │ │ └── dataset.json
│ │ ├── launch/
│ │ │ └── handeye_dashboard.launch.py
│ │ ├── package.xml
│ │ ├── plugin.xml
│ │ ├── resource/
│ │ │ └── handeye_dashboard
│ │ ├── setup.py
│ │ └── src/
│ │ └── handeye_dashboard/
│ │ ├── __init__.py
│ │ ├── handeye_calibration.py
│ │ ├── main.py
│ │ └── plugin.py
│ ├── handeye_target_detection/
│ │ ├── .clang-format
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── include/
│ │ │ └── PoseEstimator.h
│ │ ├── launch/
│ │ │ ├── pose_estimation.launch.py
│ │ │ └── pose_estimation.yaml
│ │ ├── package.xml
│ │ └── src/
│ │ ├── pose_estimation_node.cpp
│ │ └── pose_estimator.cpp
│ ├── handeye_tf_service/
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── package.xml
│ │ ├── src/
│ │ │ └── handeye_tf_server.cpp
│ │ └── srv/
│ │ └── HandeyeTF.srv
│ └── robot_interface/
│ ├── CMakeLists.txt
│ ├── Doxyfile
│ ├── README.md
│ ├── include/
│ │ └── robot_interface/
│ │ ├── control_base.hpp
│ │ └── control_ur.hpp
│ ├── launch/
│ │ ├── ur_test.launch.py
│ │ └── ur_test.yaml
│ ├── package.xml
│ ├── src/
│ │ ├── control_base.cpp
│ │ └── control_ur.cpp
│ └── test/
│ ├── ur_test_move_command.cpp
│ └── ur_test_state_publish.cpp
└── moveit_msgs_light/
├── CMakeLists.txt
├── README.md
├── msg/
│ ├── CollisionObject.msg
│ ├── Grasp.msg
│ ├── GripperTranslation.msg
│ ├── MoveItErrorCodes.msg
│ ├── ObjectType.msg
│ └── PlaceLocation.msg
├── package.xml
└── srv/
└── GraspPlanning.srv
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# rviz file
*.rviz
# document buid file
build
_build
# vscode file
.vscode
================================================
FILE: CHANGELOG.rst
================================================
changelog for ros2_grasp_library
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.5.0 (2019-11-06)
------------------
* Added examples for advanced industrial robot applications
* draw X
* fixed position pick and place
* random picking with OpenVINO grasp planning
* recognition picking with OpenVINO grasp planning and OpenVINO mask-rcnn object segmentation
* Support ROS2 hand-eye calibration
* Support robot interface for manipulation
* Added tutorials on how to
* Build and launch example applications
* Operate hand-eye calibration and publish the transformation
* Quickly enable robot interface on a new industrial robot
0.4.0 (2019-03-13)
------------------
* Support "service-driven" grasp detection mechanism (via configure auto_mode) to optimize CPU load for real-time processing.
* Support grasp transformation from camera frame to a specified target frame expected in the visual manipulation.
* Support launch option "grasp_approach" to specify expected approach direction in the target frame specified by 'grasp_frame_id'. Grasp Planner will return grasp poses with approach direction approximate to this parameter.
* Support launch option "device" to configure device for grasp pose inference to execute, 0 for CPU, 1 for GPU, 2 for VPU, 3 for FPGA. In case OpenVINO plug-ins are installed (tutorial), this configure deploy the CNN based deep learning inference on to the target device.
* Add tutorials for introduction to Intel DLDT toolkit and Intel OpenVINO toolkit.
* Add tutorials for launch options and customization notes.
0.3.0 (2018-12-28)
------------------
* Support grasp pose detection from RGBD point cloud.
* Support MoveIt! grasp planning service.
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# DISCONTINUATION OF PROJECT #
This project will no longer be maintained by Intel.
Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.
Intel no longer accepts patches to this project.
If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.
Contact: webadmin@linux.intel.com
# ROS2 Grasp Library
A ROS2 intelligent visual grasp solution for advanced industrial usages, with OpenVINO™ grasp detection and MoveIt Grasp Planning.
## Overview
ROS2 Grasp Library enables state-of-the-art CNN based deep learning grasp detection algorithms on ROS2 for intelligent visual grasp in industrial robot usage scenarios. This package provides ROS2 interfaces compliant with the open source [MoveIt](http://moveit.ros.org/) motion planning framework supported by most of the [robot models](https://moveit.ros.org/robots) in ROS industrial. This package delivers
* A ROS2 Grasp Planner providing grasp planning service, as an extensible capability of MoveIt ([moveit_msgs::srv::GraspPlanning](http://docs.ros.org/api/moveit_msgs/html/srv/GraspPlanning.html)), translating grasp detection results into MoveIt Interfaces ([moveit_msgs::msg::Grasp](http://docs.ros.org/api/moveit_msgs/html/msg/Grasp.html))
* A ROS2 Grasp Detctor abstracting interfaces for grasp detection results
* A ROS2 hand-eye calibration module generating transformation from camera frame to robot frame
* ROS2 example applications demonstrating how to use this ROS2 Grasp Library in advanced industrial usages for intelligent visual grasp
## Grasp Detection Algorithms
Grasp detection back-end algorithms enabled by this ROS2 Grasp Library:
- [Grasp Pose Detection](https://github.com/atenpas/gpd) detects 6-DOF grasp poses for a 2-finger grasp (e.g. a parallel jaw gripper) in 3D point clouds from RGBD sensor or PCD file. The grasp detection was enabled with Intel® [DLDT](https://github.com/opencv/dldt) toolkit and Intel® [OpenVINO™](https://software.intel.com/en-us/openvino-toolkit) toolkit.
## Tutorials
Refer to ROS2 Grasp Library [Tutorials](http://intel.github.io/ros2_grasp_library) for how to
* Install, build, and launch the ROS2 Grasp Planner and Detector
* Use launch options to customize in a new workspace
* Bring up the intelligent visual grasp solution on a new robot
* Do hand-eye calibration for a new camera setup
* Launch the example applications
## Example Applications
### Random Picking (OpenVINO Grasp Detection)
[](https://www.youtube.com/embed/b4EPvHdidOA)
### Recognition Picking (OpenVINO Grasp Detection + OpenVINO Mask-rcnn Object Segmentation)
[](https://www.youtube.com/embed/trIt0uKRXBs)
## Known Issues
* Cloud camera failed at "Invalid sizes when resizing a matrix or array" when dealing with XYZRGBA pointcloud from ROS2 Realsenes, tracked as [#6](https://github.com/atenpas/gpg/issues/6) of gpg, [patch](https://github.com/atenpas/gpg/pull/7) under review.
* 'colcon test' sometimes failed with test suite "tgrasp_ros2", due to ROS2 service request failure issue (reported ros2 examples issue [#228](https://github.com/ros2/examples/issues/228) and detailed discussed in ros2 demo issue [#304](https://github.com/ros2/demos/issues/304))
* Rviz2 failed to receive Static TF from camera due to transient_local QoS (expected in the coming ROS2 Eloquent, discussed in geometry2 issue [#183](https://github.com/ros2/geometry2/issues/183)), workaround [patch](https://github.com/intel/ros2_intel_realsense/pull/88) available till the adaption to Eloquent
## Contribute to This Project
It's welcomed to contribute to this project. Here're some recommended practices:
* When adding a new feature it's expected to add tests covering the new functionalities
```bash
colcon test --packages-select
```
* Before submitting a patch, it's recommended to pass all existing tests to avoid regression
```bash
colcon test --packages-select
```
###### *Any security issue should be reported using process at https://01.org/security*
================================================
FILE: docker/Dockerfile
================================================
########################################################
# Based on Ubuntu 18.04
########################################################
# Set the base image to ubuntu 18.04
FROM ubuntu:bionic
MAINTAINER Liu Cong "congx.liu@intel.com"
ARG DEPS_DIR=/root/deps
WORKDIR $DEPS_DIR
# install ros2 grasp library deps
COPY ./script/ $DEPS_DIR/script/
RUN bash script/install_ros2_grasp_library_deps.sh /root/deps
WORKDIR /root
ENTRYPOINT ["/root/script/ros_entrypoint.sh"]
CMD ["bash"]
================================================
FILE: docker/README.md
================================================
# Precondition
## add docker group
```
sudo groupadd docker
sudo usermod -aG docker $USER
```
## Build docker image
```
cd ros2_grasp_library/docker
docker build -t intel/ros2:ros2_grasp_library_deps .
```
If your use proxy
```
docker build -t intel/ros2:ros2_grasp_library_deps --build-arg http_proxy=: --build-arg https_proxy=: .
```
## OPTION:Please refer below command to verify image creating success
```
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
intel/ros2 ros2_grasp_library_deps b6d619a01f33 1 hours ago 6.92GB
```
# Run OpenVINO Grasp Library with RGBD Camera
## Terminal 1: Build ros2_grasp_library and launch Rviz2 to illustrate detection results.
After the project runs, there will be a pop-up x window, you need to set the operating environment first.
```
./setup_docker_display.sh
docker run -it --rm --privileged -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v /tmp/.docker.xauth:/tmp/.docker.xauth:rw -v /dev/bus/usb:/dev/bus/usb \
-v /dev:/dev:rw -e XAUTHORITY=/tmp/.docker.xauth -e DISPLAY --name ros2_grasp_library intel/ros2:ros2_grasp_library_deps bash
# cd /root/
# mkdir -p ros2_ws/src
# cd ros2_ws/src
# git clone https://github.com/intel/ros2_grasp_library.git
# git clone https://github.com/intel/ros2_intel_realsense.git -b refactor
# git clone https://github.com/intel/ros2_openvino_toolkit.git
# cd ..
# colcon build --symlink-install --packages-select grasp_msgs moveit_msgs people_msgs grasp_ros2 realsense_msgs realsense_ros realsense_node
# source ./install/local_setup.bash
# ros2 run rviz2 rviz2 -d src/ros2_grasp_library/grasp_ros2/rviz2/grasp.rviz
```
## Terminal 2: launch RGBD camera
```
docker exec -t -i ros2_grasp_library bash
# source /root/ros2_ws/install/setup.bash
# ros2 run realsense_node realsense_node
```
## Terminal 3: launch Grasp Library
```
docker exec -t -i ros2_grasp_library bash
# source /root/ros2_ws/install/setup.bash
# ros2 run grasp_ros2 grasp_ros2 __params:=src/ros2_grasp_library/grasp_ros2/cfg/grasp_ros2_params.yaml
```
Note: If you haven't already installed or want more information on how to use docker, please see the article here for more information:
https://docs.docker.com/install/
================================================
FILE: docker/script/00_ros2_install.sh
================================================
#!/bin/bash
DEPS_DIR=${DEPS_PATH}
ros2_version=dashing
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
# fix popup caused by libssl
$SUDO apt-get install -y debconf-utils \
echo 'libssl1.0.0:amd64 libraries/restart-without-asking boolean true' | $SUDO debconf-set-selections
# Authorize gpg key with apt
$SUDO apt-get update && $SUDO apt-get install -y curl gnupg2 lsb-release &&\
curl http://repo.ros2.org/repos.key | $SUDO apt-key add -
# Add the repository to sources list
$SUDO sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
# Install development tools and ROS tools
$SUDO apt-get update && $SUDO apt-get install -y \
python-rosdep \
python3-vcstool \
python3-colcon-common-extensions
# Install ROS 2 packages
echo "install $ros2_version"
$SUDO apt-get update && $SUDO apt-get install -y ros-${ros2_version}-desktop
================================================
FILE: docker/script/10_eigen_install.sh
================================================
#!/bin/bash
set -e
DEPS_DIR=${DEPS_PATH}
eigen_version=https://gitlab.com/libeigen/eigen/-/archive/3.2/eigen-3.2.tar.gz
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
cd $DEPS_DIR
$SUDO apt-get install -y gfortran
wget -t 3 -c $eigen_version
tar -xvf eigen-3.2.tar.gz
cd eigen-3.2 &&mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
$SUDO make install
$SUDO rm -rf /usr/include/eigen3/
$SUDO ln -sf /usr/local/include/eigen3 /usr/include/
$SUDO make install
================================================
FILE: docker/script/11_libpcl_install.sh
================================================
#!/bin/bash
set -e
DEPS_DIR=${DEPS_PATH}
pcl_version=https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.tar.gz
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
cd $DEPS_DIR
$SUDO apt-get install -y libhdf5-dev python3-h5py python3-pip
wget -t 3 -c $pcl_version
tar -xvf pcl-1.8.1.tar.gz
cd pcl-pcl-1.8.1 &&mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
$SUDO make install
================================================
FILE: docker/script/12_opencv_install.sh
================================================
#!/bin/bash
DEPS_DIR=${DEPS_PATH}
opencv_version=4.1.2
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
#install opencv
cd $DEPS_DIR
$SUDO apt-get update && $SUDO apt-get install -y build-essential \
libgtk2.0-dev \
pkg-config \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
python-dev \
python-numpy \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libdc1394-22-dev
git clone --depth 1 https://github.com/opencv/opencv.git -b $opencv_version
git clone --depth 1 https://github.com/opencv/opencv_contrib.git -b $opencv_version
cd $DEPS_DIR/opencv
mkdir -p build && cd build
cd $DEPS_DIR/opencv/build
cmake -D OPENCV_EXTRA_MODULES_PATH=$DEPS_DIR/opencv_contrib/modules \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_xfeatures2d=OFF \
..
make -j4
$SUDO make install
echo "/usr/local/lib" | $SUDO tee /etc/ld.so.conf.d/opencv.conf
$SUDO ldconfig
================================================
FILE: docker/script/13_openvino_install.sh
================================================
#!/bin/bash
DEPS_DIR=${DEPS_PATH}
MKL_URL=https://github.com/intel/mkl-dnn/releases/download/v0.19/mklml_lnx_2019.0.5.20190502.tgz
MKL_VERSION=mklml_lnx_2019.0.5.20190502
OPENVINO_VERSION=2019_R3.1
SUDO=$1
if [ "$SUDO" == "" ];then
SUDO="sudo"
fi
# install mkl 2019.0.5.20190502
$SUDO apt-get update && $SUDO apt-get install -y wget
cd $DEPS_DIR
wget -t 3 -c ${MKL_URL} &&\
tar -xvf ${MKL_VERSION}.tgz &&\
cd ${MKL_VERSION} &&\
$SUDO mkdir -p /usr/local/lib/mklml &&\
$SUDO cp -rf ./lib /usr/local/lib/mklml &&\
$SUDO cp -rf ./include /usr/local/lib/mklml &&\
$SUDO touch /usr/local/lib/mklml/version.info
#install opencl 19.41.14441
cd $DEPS_DIR
mkdir -p opencl && cd opencl &&\
wget -t 3 -c https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-gmmlib_19.3.2_amd64.deb &&\
wget -t 3 -c https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-core_1.0.2597_amd64.deb &&\
wget -t 3 -c https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-opencl_1.0.2597_amd64.deb &&\
wget -t 3 -c https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-opencl_19.41.14441_amd64.deb &&\
wget -t 3 -c https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-ocloc_19.41.14441_amd64.deb &&\
$SUDO dpkg -i *.deb
#install cmake 3.11
if [ $(cmake --version|grep "version"|awk '{print $3}') != "3.14.3" ];then
cd $DEPS_DIR
wget -t 3 -c https://www.cmake.org/files/v3.14/cmake-3.14.3.tar.gz && \
tar xf cmake-3.14.3.tar.gz && \
(cd cmake-3.14.3 && ./bootstrap --parallel=$(nproc --all) && make --jobs=$(nproc --all) && $SUDO make install) && \
rm -rf cmake-3.14.3 cmake-3.14.3.tar.gz
fi
#install openvino 2019_R3.1
cd $DEPS_DIR
$SUDO apt-get update && $SUDO apt-get install -y git
git clone --depth 1 https://github.com/openvinotoolkit/openvino -b ${OPENVINO_VERSION}
cd $DEPS_DIR/openvino/inference-engine
git submodule update --init --recursive &&\
chmod +x install_dependencies.sh &&\
$SUDO ./install_dependencies.sh
mkdir -p build && cd build &&\
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DGEMM=MKL -DMKLROOT=/usr/local/lib/mklml \
-DTHREADING=OMP \
-DENABLE_MKL_DNN=ON \
-DENABLE_CLDNN=ON \
-DENABLE_OPENCV=OFF \
..
cd $DEPS_DIR/openvino/inference-engine/build
make -j8
cd $DEPS_DIR/openvino/inference-engine/build
$SUDO mkdir -p /usr/share/InferenceEngine &&\
$SUDO cp InferenceEngineConfig*.cmake /usr/share/InferenceEngine &&\
$SUDO cp targets.cmake /usr/share/InferenceEngine &&\
echo `pwd`/../bin/intel64/Release/lib | $SUDO tee -a /etc/ld.so.conf.d/openvino.conf &&\
$SUDO ldconfig
$SUDO ln -sf $DEPS_DIR/openvino /opt/openvino_toolkit/openvino
================================================
FILE: docker/script/20_librealsense_install.sh
================================================
#!/bin/bash
DEPS_DIR=${DEPS_PATH}
librealsense_version=2.31.0-0~realsense0.1791
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
# install librealsense v2.34.0-0~realsense0.2251
echo "install librealsense 2.34.0-0~realsense0.2251"
cd $DEPS_DIR
if [ $http_proxy == "" ];then
$SUDO apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
else
$SUDO apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options http-proxy=$http_proxy --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
fi
$SUDO sh -c 'echo "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo `lsb_release -cs` main" > /etc/apt/sources.list.d/librealsense.list'
$SUDO apt-get update && $SUDO apt-get install -y librealsense2=${librealsense_version} \
librealsense2-dev=${librealsense_version} \
librealsense2-udev-rules=${librealsense_version} \
librealsense2-gl=${librealsense_version} \
librealsense2-utils=${librealsense_version} \
librealsense2-dbg=${librealsense_version} \
librealsense2-dkms
================================================
FILE: docker/script/30_gpg_install.sh
================================================
#!/bin/bash
DEPS_DIR=${DEPS_PATH}
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
# install gpg
cd $DEPS_DIR
wget -t 3 -c https://github.com/atenpas/gpg/archive/3dcd656d70f095ad1bda3d2fb597a994198466ab.zip
unzip 3dcd656d70f095ad1bda3d2fb597a994198466ab.zip
cd gpg-3dcd656d70f095ad1bda3d2fb597a994198466ab
mkdir -p build && cd build
cmake .. && make
$SUDO make install
ls /usr/local/lib/libgrasp_candidates_generator.so
================================================
FILE: docker/script/31_gpd_install.sh
================================================
#!/bin/bash
DEPS_DIR=${DEPS_PATH}
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
# install gpd
cd $DEPS_DIR
git clone --depth 1 https://github.com/sharronliu/gpd.git -b libgpd
cd gpd/src/gpd
mkdir -p build && cd build
cmake -DUSE_OPENVINO=ON .. && make
$SUDO make install
================================================
FILE: docker/script/32_ur_modern_driver_install.sh
================================================
#!/bin/bash
DEPS_DIR=${DEPS_PATH}
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
# install ur_modern_driver
cd $DEPS_DIR
git clone --depth 1 https://github.com/RoboticsYY/ur_modern_driver.git -b libur_modern_driver
cd ur_modern_driver/libur_modern_driver
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release .. && make
$SUDO make install
================================================
FILE: docker/script/50_ros2_deps.sh
================================================
#!/bin/bash
SUDO=$1
if [ "$SUDO" == "sudo" ];then
SUDO="sudo"
else
SUDO=""
fi
$SUDO apt-get install -y ros-dashing-object-msgs \
python3-scipy \
ros-dashing-eigen3-cmake-module
WORK_DIR=${DEPS_PATH}/../ros2_ws
mkdir -p $WORK_DIR/src &&cd $WORK_DIR/src
git clone --depth 1 https://github.com/RoboticsYY/ros2_ur_description.git
git clone --depth 1 https://github.com/RoboticsYY/handeye
git clone --depth 1 https://github.com/RoboticsYY/criutils.git
git clone --depth 1 https://github.com/RoboticsYY/baldor.git
git clone --depth 1 https://github.com/intel/ros2_intel_realsense.git -b refactor
git clone --depth 1 https://github.com/intel/ros2_grasp_library.git
cd $WORK_DIR
source /opt/ros/dashing/setup.sh
export InferenceEngine_DIR=/opt/openvino_toolkit/openvino/inference-engine/build/
export export CPU_EXTENSION_LIB=/opt/openvino_toolkit/openvino/inference-engine/bin/intel64/Release/lib/libcpu_extension.so
export GFLAGS_LIB=/opt/openvino_toolkit/openvino/inference-engine/bin/intel64/Release/lib/libgflags_nothreads.a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$InferenceEngine_DIR/../bin/intel64/Release/lib:/usr/local/lib/mklml/lib
colcon build --symlink-install
================================================
FILE: docker/script/install_ros2_grasp_library.sh
================================================
#!/bin/bash
set -e
deps_path=$1
if [ -z "$deps_path" ]; then
echo -e "warring:\n install_ros2_grasp_library_deps.sh "
echo -e "If you want to use'sudo' : install_ros2_grasp_library_deps.sh sudo"
exit 0
fi
shift
# mkdir deps-path
echo "DEPS_PATH = $deps_path"
mkdir -p $deps_path
export DEPS_PATH=$deps_path
CURRENT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
echo "CURRENT_DIR = ${CURRENT_DIR}"
# install ros2 dashing
bash ${CURRENT_DIR}/00_ros2_install.sh $@
# instal eigen 3.2
bash ${CURRENT_DIR}/10_eigen_install.sh $@
# install libpcl 1.8.1
bash ${CURRENT_DIR}/11_libpcl_install.sh $@
# install opencv 4.1.2
bash ${CURRENT_DIR}/12_opencv_install.sh $@
# install openvino 2019_R3.1
bash ${CURRENT_DIR}/13_openvino_install.sh $@
# install librealsense 2.31
bash ${CURRENT_DIR}/20_librealsense_install.sh $@
# install gpg
bash ${CURRENT_DIR}/30_gpg_install.sh $@
# install gpd
bash ${CURRENT_DIR}/31_gpd_install.sh $@
# install ur_modern_driver
bash ${CURRENT_DIR}/32_ur_modern_driver_install.sh $@
# build ros2 other deps
bash ${CURRENT_DIR}/50_ros2_deps.sh $@
================================================
FILE: docker/script/ros_entrypoint.sh
================================================
#!/bin/bash
set -e
# setup ros2 environment
source /opt/ros/dashing/setup.bash
source /root/ros2_ws/install/setup.bash
exec "$@"
================================================
FILE: docker/script/ros_env.sh
================================================
#!/bin/bash
ROS_PATH=$(pwd)
# setup ros2 environment
source /opt/ros/dashing/setup.bash
source ${ROS_PATH}/install/setup.bash
export ROS_DOMAIN_ID=100 # robot_group_id
export InferenceEngine_DIR=/opt/openvino_toolkit/openvino/inference-engine/build/
export export CPU_EXTENSION_LIB=/opt/openvino_toolkit/openvino/inference-engine/bin/intel64/Release/lib/libcpu_extension.so
export GFLAGS_LIB=/opt/openvino_toolkit/openvino/inference-engine/bin/intel64/Release/lib/libgflags_nothreads.a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$InferenceEngine_DIR/../bin/intel64/Release/lib:/usr/local/lib/mklml/lib
================================================
FILE: docker/setup_docker_display.sh
================================================
#!/bin/bash
set -e
# setup docker display
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
================================================
FILE: grasp_apps/draw_x/CMakeLists.txt
================================================
# Copyright (c) 2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5)
project(draw_x)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if(CMAKE_BUILD_TYPE EQUAL "RELEASE")
message(STATUS "Create Release Build.")
set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
else()
message(STATUS "Create Debug Build.")
endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(robot_interface REQUIRED)
include_directories(
include
${rclcpp_INCLUDE_DIRS}
${robot_interface_INCLUDE_DIRS}
)
# draw_x app
add_executable(${PROJECT_NAME}
src/draw_x.cpp
)
ament_target_dependencies(${PROJECT_NAME}
"rclcpp"
"robot_interface"
)
target_link_libraries(${PROJECT_NAME}
${ament_LIBRARIES}
${robot_interface_LIBRARIES}
)
# Install binaries
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
)
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)
# Install launch files.
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)
# Flags
if(UNIX OR APPLE)
# Linker flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# GCC specific flags. ICC is compatible with them.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# In Clang, -z flags are not compatible, they need to be passed to linker via -Wl.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
endif()
# Compiler flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# GCC specific flags.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector-strong")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# Clang is compatbile with some of the flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# Same as above, with exception that ICC compilation crashes with -fPIE option, even
# though it uses -pie linker option that require -fPIE during compilation. Checksec
# shows that it generates correct PIE anyway if only -pie is provided.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif()
# Generic flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security \
-Wall -fopenmp")
set( CUDA_PROPAGATE_HOST_FLAGS OFF )
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
ament_package()
================================================
FILE: grasp_apps/draw_x/launch/draw_x.launch.py
================================================
# Copyright (c) 2019 Intel Corporation. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import launch
import launch.actions
import launch.substitutions
import launch_ros.actions
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
# .yaml file for configuring the parameters
yaml = os.path.join(
get_package_share_directory('draw_x'),
'launch', 'draw_x.yaml'
)
return launch.LaunchDescription([
launch_ros.actions.Node(
package='draw_x',
node_executable='draw_x',
output='screen', arguments=['__params:='+yaml]),
])
================================================
FILE: grasp_apps/draw_x/launch/draw_x.yaml
================================================
robot_control:
ros__parameters:
host: "192.168.0.5"
shutdown_on_disconnect: true
joint_names: ["shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint", "wrist_1_joint", "wrist_2_joint", "wrist_3_joint"]
================================================
FILE: grasp_apps/draw_x/package.xml
================================================
draw_x0.5.0A demo app for draw_xYu YanYu YanApache License 2.0ament_cmakerclcpprobot_interfacerclcpprobot_interfaceament_lint_autoament_lint_commonament_cmake
================================================
FILE: grasp_apps/draw_x/src/draw_x.cpp
================================================
#include
#include
#include
/* pose in joint values*/
static const std::vector HOME = {0.87, -1.44, 1.68, -1.81, -1.56, 0};
/* pose in [x, y, z, R, P, Y]*/
static const std::vector CORNER1_POSE = { 0.1, -0.65, 0.15, 3.14, 0, -3.14};
static const std::vector CORNER2_POSE = {-0.1, -0.45, 0.15, 3.14, 0, -3.14};
static const std::vector CORNER3_POSE = {-0.1, -0.65, 0.15, 3.14, 0, -3.14};
static const std::vector CORNER4_POSE = { 0.1, -0.45, 0.15, 3.14, 0, -3.14};
int main(int argc, char **argv)
{
rclcpp::init(argc, argv);
// init robot control
auto robot = std::make_shared("robot_control",
rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true));
robot->parseArgs();
robot->startLoop();
rclcpp::sleep_for(2s);
// Move to home
robot->moveToJointValues(HOME, 1.05, 1.4);
// Move to the first corner
robot->moveToTcpPose(CORNER1_POSE[0], CORNER1_POSE[1], CORNER1_POSE[2],
CORNER1_POSE[3], CORNER1_POSE[4], CORNER1_POSE[5], 1.05, 1.4);
robot->moveToTcpPose(CORNER1_POSE[0], CORNER1_POSE[1], CORNER1_POSE[2] - 0.05,
CORNER1_POSE[3], CORNER1_POSE[4], CORNER1_POSE[5], 1.05, 1.4);
// Move to the second corner
robot->moveToTcpPose(CORNER2_POSE[0], CORNER2_POSE[1], CORNER2_POSE[2] - 0.05,
CORNER2_POSE[3], CORNER2_POSE[4], CORNER2_POSE[5], 1.05, 1.4);
robot->moveToTcpPose(CORNER2_POSE[0], CORNER2_POSE[1], CORNER2_POSE[2],
CORNER2_POSE[3], CORNER2_POSE[4], CORNER2_POSE[5], 1.05, 1.4);
// Move to the third corner
robot->moveToTcpPose(CORNER3_POSE[0], CORNER3_POSE[1], CORNER3_POSE[2],
CORNER3_POSE[3], CORNER3_POSE[4], CORNER3_POSE[5], 1.05, 1.4);
robot->moveToTcpPose(CORNER3_POSE[0], CORNER3_POSE[1], CORNER3_POSE[2] - 0.05,
CORNER3_POSE[3], CORNER3_POSE[4], CORNER3_POSE[5], 1.05, 1.4);
// Move to the fourth corner
robot->moveToTcpPose(CORNER4_POSE[0], CORNER4_POSE[1], CORNER4_POSE[2] - 0.05,
CORNER4_POSE[3], CORNER4_POSE[4], CORNER4_POSE[5], 1.05, 1.4);
robot->moveToTcpPose(CORNER4_POSE[0], CORNER4_POSE[1], CORNER4_POSE[2],
CORNER4_POSE[3], CORNER4_POSE[4], CORNER4_POSE[5], 1.05, 1.4);
// Move back to home
robot->moveToJointValues(HOME, 1.05, 1.4);
rclcpp::shutdown();
return 0;
}
================================================
FILE: grasp_apps/fixed_position_pick/CMakeLists.txt
================================================
# Copyright (c) 2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5)
project(fixed_position_pick)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if(CMAKE_BUILD_TYPE EQUAL "RELEASE")
message(STATUS "Create Release Build.")
set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
else()
message(STATUS "Create Debug Build.")
endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(robot_interface REQUIRED)
include_directories(
include
${rclcpp_INCLUDE_DIRS}
${robot_interface_INCLUDE_DIRS}
)
# draw_x app
add_executable(${PROJECT_NAME}
src/fixed_position_pick.cpp
)
ament_target_dependencies(${PROJECT_NAME}
"rclcpp"
"robot_interface"
)
target_link_libraries(${PROJECT_NAME}
${ament_LIBRARIES}
${robot_interface_LIBRARIES}
)
# Install binaries
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
)
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)
# Install launch files.
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)
# Flags
if(UNIX OR APPLE)
# Linker flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# GCC specific flags. ICC is compatible with them.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# In Clang, -z flags are not compatible, they need to be passed to linker via -Wl.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
endif()
# Compiler flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# GCC specific flags.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector-strong")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# Clang is compatbile with some of the flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# Same as above, with exception that ICC compilation crashes with -fPIE option, even
# though it uses -pie linker option that require -fPIE during compilation. Checksec
# shows that it generates correct PIE anyway if only -pie is provided.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif()
# Generic flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security \
-Wall -fopenmp")
set( CUDA_PROPAGATE_HOST_FLAGS OFF )
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
ament_package()
================================================
FILE: grasp_apps/fixed_position_pick/launch/fixed_position_pick.launch.py
================================================
# Copyright (c) 2019 Intel Corporation. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import launch
import launch.actions
import launch.substitutions
import launch_ros.actions
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
# .yaml file for configuring the parameters
yaml = os.path.join(
get_package_share_directory('fixed_position_pick'),
'launch', 'fixed_position_pick.yaml'
)
return launch.LaunchDescription([
launch_ros.actions.Node(
package='fixed_position_pick',
node_executable='fixed_position_pick',
output='screen', arguments=['__params:='+yaml]),
])
================================================
FILE: grasp_apps/fixed_position_pick/launch/fixed_position_pick.yaml
================================================
robot_control:
ros__parameters:
host: "192.168.0.5"
shutdown_on_disconnect: true
joint_names: ["shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint", "wrist_1_joint", "wrist_2_joint", "wrist_3_joint"]
================================================
FILE: grasp_apps/fixed_position_pick/package.xml
================================================
fixed_position_pick0.5.0A demo app for draw_xYu YanYu YanApache License 2.0ament_cmakerclcpprobot_interfacerclcpprobot_interfaceament_lint_autoament_lint_commonament_cmake
================================================
FILE: grasp_apps/fixed_position_pick/src/fixed_position_pick.cpp
================================================
#include
#include
#include
/* pose in joint values*/
static const std::vector HOME = {0.87, -1.44, 1.68, -1.81, -1.56, 0};
/* pose in [x, y, z, qx, qy, qz, qw]*/
static const std::vector PICK_POSE = { -0.157402, -0.679509, 0.094437, 0.190600, 0.948295, 0.239947, 0.082662};
static const std::vector PLACE_POSE = {-0.350, -0.296, 0.145, -0.311507, 0.950216, -0.004305, 0.005879};
int main(int argc, char **argv)
{
rclcpp::init(argc, argv);
// init robot control
auto robot = std::make_shared("robot_control",
rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true));
robot->parseArgs();
robot->startLoop();
rclcpp::sleep_for(2s);
// Move to home
robot->moveToJointValues(HOME, 1.05, 1.4);
// Pick
geometry_msgs::msg::PoseStamped pose_pick;
pose_pick.header.frame_id = "base";
pose_pick.header.stamp = robot->now();
pose_pick.pose.position.x = PICK_POSE[0];
pose_pick.pose.position.y = PICK_POSE[1];
pose_pick.pose.position.z = PICK_POSE[2];
pose_pick.pose.orientation.x = PICK_POSE[3];
pose_pick.pose.orientation.y = PICK_POSE[4];
pose_pick.pose.orientation.z = PICK_POSE[5];
pose_pick.pose.orientation.w = PICK_POSE[6];
robot->pick(pose_pick, 1.05, 1.4, 0.5, 0.1);
// Place
geometry_msgs::msg::PoseStamped pose_place;
pose_place.header.frame_id = "base";
pose_place.header.stamp = robot->now();
pose_place.pose.position.x = PLACE_POSE[0];
pose_place.pose.position.y = PLACE_POSE[1];
pose_place.pose.position.z = PLACE_POSE[2];
pose_place.pose.orientation.x = PLACE_POSE[3];
pose_place.pose.orientation.y = PLACE_POSE[4];
pose_place.pose.orientation.z = PLACE_POSE[5];
pose_place.pose.orientation.w = PLACE_POSE[6];
robot->place(pose_place, 1.05, 1.4, 0.5, 0.1);
// Move back to home
robot->moveToJointValues(HOME, 1.05, 1.4);
rclcpp::shutdown();
return 0;
}
================================================
FILE: grasp_apps/random_pick/CMakeLists.txt
================================================
# Copyright (c) 2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
option(BUILD_RANDOM_PICK "build random_pick app" ON)
if(NOT BUILD_RANDOM_PICK STREQUAL "ON")
return()
endif()
cmake_minimum_required(VERSION 3.5)
project(random_pick)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if(CMAKE_BUILD_TYPE EQUAL "RELEASE")
message(STATUS "Create Release Build.")
set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
else()
message(STATUS "Create Debug Build.")
endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(moveit_msgs REQUIRED)
find_package(robot_interface REQUIRED)
find_package(tf2_ros REQUIRED)
include_directories(
include
${rclcpp_INCLUDE_DIRS}
${moveit_msgs_INCLUDE_DIRS}
${robot_interface_INCLUDE_DIRS}
${tf2_ros_INCLUDE_DIRS}
)
# random_pick app
add_executable(${PROJECT_NAME}
src/random_pick.cpp
)
ament_target_dependencies(${PROJECT_NAME}
"rclcpp"
"moveit_msgs"
"robot_interface"
"tf2_ros"
)
target_link_libraries(${PROJECT_NAME}
${ament_LIBRARIES}
${robot_interface_LIBRARIES}
)
# Install binaries
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
)
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)
# Flags
if(UNIX OR APPLE)
# Linker flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# GCC specific flags. ICC is compatible with them.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# In Clang, -z flags are not compatible, they need to be passed to linker via -Wl.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
endif()
# Compiler flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# GCC specific flags.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector-strong")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# Clang is compatbile with some of the flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# Same as above, with exception that ICC compilation crashes with -fPIE option, even
# though it uses -pie linker option that require -fPIE during compilation. Checksec
# shows that it generates correct PIE anyway if only -pie is provided.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif()
# Generic flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security \
-Wall -fopenmp")
set( CUDA_PROPAGATE_HOST_FLAGS OFF )
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
ament_package()
================================================
FILE: grasp_apps/random_pick/cfg/random_pick.yaml
================================================
robot_control:
ros__parameters:
host: "192.168.1.5"
================================================
FILE: grasp_apps/random_pick/package.xml
================================================
random_pick0.5.0A demo app for grasp detection, and random pickingSharron LIUSharron LIUApache License 2.0ament_cmakerclcppmoveit_msgspeople_msgsrobot_interfacetf2_rosrclcppmoveit_msgspeople_msgsrobot_interfacetf2_rosament_lint_autoament_lint_commonament_cmake
================================================
FILE: grasp_apps/random_pick/src/random_pick.cpp
================================================
#include
#include
#include
#include
#include
#include
#include
#include
#define robot_enable
using GraspPlanning = moveit_msgs::srv::GraspPlanning;
/* pick position in [x, y, z, R, P, Y]*/
static std::vector pick_ = {0.0, -0.54, 0.145, 3.14, 0.0, 1.956};
/* place position in [x, y, z, R, P, Y]*/
static std::vector place_ = {-0.50, -0.30, 0.20, 3.14, 0.0, 1.956};
/* pre-pick position in joint values*/
static std::vector joint_values_pick = {1.065, -1.470, 1.477, -1.577, -1.556, 0};
/* place position in joint values*/
static std::vector joint_values_place = {0.385, -1.470, 1.477, -1.577, -1.556, 0};
static double vel_ = 0.9, acc_ = 0.9, vscale_ = 0.9, appr_ = 0.1;
static std::shared_ptr robot_ = nullptr;
static rclcpp::Node::SharedPtr node_ = nullptr;
static std::shared_ptr result_ = nullptr;
int main(int argc, char **argv)
{
rclcpp::init(argc, argv);
// init robot control
robot_ = std::make_shared("robot_control",
rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true));
robot_->parseArgs();
robot_->startLoop();
rclcpp::sleep_for(2s);
#ifdef robot_enable
// reset joint
robot_->moveToJointValues(joint_values_place, vel_, acc_);
#endif
// init random pick node
node_ = rclcpp::Node::make_shared("random_pick");
tf2_ros::StaticTransformBroadcaster tfb(node_);
// create client for grasp planning
auto client = node_->create_client("plan_grasps");
// wait for service
while (!client->wait_for_service(5s)) {
RCLCPP_INFO(node_->get_logger(), "Wait for service");
}
RCLCPP_INFO(node_->get_logger(), "Got service");
while(rclcpp::ok())
{
// request grasp poses
auto request = std::make_shared();
auto result_future = client->async_send_request(request);
RCLCPP_INFO(node_->get_logger(), "Request sent");
// wait for response
if (rclcpp::spin_until_future_complete(node_, result_future) !=
rclcpp::executor::FutureReturnCode::SUCCESS)
{
continue;
}
// get response
if (moveit_msgs::msg::MoveItErrorCodes::SUCCESS == result_future.get()->error_code.val) {
result_ = result_future.get();
RCLCPP_INFO(node_->get_logger(), "Response received %d", result_->error_code.val);
} else continue;
geometry_msgs::msg::PoseStamped p = result_->grasps[0].grasp_pose;
// publish grasp pose
tf2::Quaternion q(p.pose.orientation.x, p.pose.orientation.y, p.pose.orientation.z, p.pose.orientation.w);
double roll, pitch, yaw;
tf2::Matrix3x3 r;
r.setRotation(q);
r.getRPY(roll, pitch, yaw);
RCLCPP_INFO(node_->get_logger(), "**********pick pose [position %f %f %f, quat %f %f %f %f, RPY %f %f %f]",
p.pose.position.x, p.pose.position.y, p.pose.position.z,
p.pose.orientation.x, p.pose.orientation.y, p.pose.orientation.z, p.pose.orientation.w,
roll, pitch, yaw);
geometry_msgs::msg::TransformStamped tf_msg;
tf_msg.header = p.header;
tf_msg.child_frame_id = "grasp_pose";
tf_msg.transform.translation.x = p.pose.position.x;
tf_msg.transform.translation.y = p.pose.position.y;
tf_msg.transform.translation.z = p.pose.position.z;
tf_msg.transform.rotation = p.pose.orientation;
tfb.sendTransform(tf_msg);
#ifdef robot_enable
// pick
robot_->moveToJointValues(joint_values_pick, vel_, acc_);
robot_->pick(p, vel_, acc_, vscale_, appr_);
// place
robot_->moveToJointValues(joint_values_place, vel_, acc_);
robot_->place(place_[0], place_[1], place_[2], place_[3], place_[4], place_[5], vel_, acc_, vscale_, appr_);
#endif
}
rclcpp::shutdown();
return 0;
}
================================================
FILE: grasp_apps/recognize_pick/CMakeLists.txt
================================================
# Copyright (c) 2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
option(BUILD_RECOGNIZE_PICK "build recognize_pick app" OFF)
if(NOT BUILD_RECOGNIZE_PICK STREQUAL "ON")
return()
endif()
cmake_minimum_required(VERSION 3.5)
project(recognize_pick)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if(CMAKE_BUILD_TYPE EQUAL "RELEASE")
message(STATUS "Create Release Build.")
set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
else()
message(STATUS "Create Debug Build.")
endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(moveit_msgs REQUIRED)
find_package(people_msgs REQUIRED)
find_package(robot_interface REQUIRED)
find_package(tf2_ros REQUIRED)
include_directories(
include
${rclcpp_INCLUDE_DIRS}
${moveit_msgs_INCLUDE_DIRS}
${people_msgs_INCLUDE_DIRS}
${robot_interface_INCLUDE_DIRS}
${tf2_ros_INCLUDE_DIRS}
)
# recognize_pick app
add_executable(${PROJECT_NAME}
src/recognize_pick.cpp
)
ament_target_dependencies(${PROJECT_NAME}
"rclcpp"
"moveit_msgs"
"people_msgs"
"robot_interface"
"tf2_ros"
)
target_link_libraries(${PROJECT_NAME}
${ament_LIBRARIES}
${robot_interface_LIBRARIES}
)
# place publisher app
set(PLACE_PUBLISHER place_publisher)
add_executable(${PLACE_PUBLISHER}
src/place_publisher.cpp
)
ament_target_dependencies(${PLACE_PUBLISHER}
"rclcpp"
"moveit_msgs"
)
target_link_libraries(${PLACE_PUBLISHER}
${ament_LIBRARIES}
)
# Install binaries
install(TARGETS ${PROJECT_NAME} ${PLACE_PUBLISHER}
RUNTIME DESTINATION bin
)
install(TARGETS ${PROJECT_NAME} ${PLACE_PUBLISHER}
DESTINATION lib/${PROJECT_NAME}
)
# Flags
if(UNIX OR APPLE)
# Linker flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# GCC specific flags. ICC is compatible with them.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# In Clang, -z flags are not compatible, they need to be passed to linker via -Wl.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
endif()
# Compiler flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# GCC specific flags.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector-strong")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# Clang is compatbile with some of the flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# Same as above, with exception that ICC compilation crashes with -fPIE option, even
# though it uses -pie linker option that require -fPIE during compilation. Checksec
# shows that it generates correct PIE anyway if only -pie is provided.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif()
# Generic flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security \
-Wall -fopenmp")
set( CUDA_PROPAGATE_HOST_FLAGS OFF )
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
ament_package()
================================================
FILE: grasp_apps/recognize_pick/cfg/recognize_pick.yaml
================================================
robot_control:
ros__parameters:
host: "192.168.1.5"
================================================
FILE: grasp_apps/recognize_pick/package.xml
================================================
recognize_pick0.5.0A demo app for object segmentation, grasp detection, and pickingSharron LIUSharron LIUApache License 2.0ament_cmakerclcppmoveit_msgspeople_msgsrobot_interfacetf2_rosrclcppmoveit_msgspeople_msgsrobot_interfacetf2_rosament_lint_autoament_lint_commonament_cmake
================================================
FILE: grasp_apps/recognize_pick/src/place_publisher.cpp
================================================
// Copyright (c) 2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include
#include
#include
int main(int argc, char ** argv) {
std::vector args = rclcpp::init_and_remove_ros_arguments(argc, argv);
auto node = rclcpp::Node::make_shared("PlacePublisher");
auto pub = node->create_publisher("/recognize_pick/place", 10);
rclcpp::Clock clock(RCL_ROS_TIME);
moveit_msgs::msg::PlaceLocation p;
if (args.size() < 5) {
p.place_pose.pose.position.x = -0.45;
p.place_pose.pose.position.y = -0.30;
p.place_pose.pose.position.z = 0.125;
} else {
p.place_pose.pose.position.x = atof(args[2].c_str());
p.place_pose.pose.position.y = atof(args[3].c_str());
p.place_pose.pose.position.z = atof(args[4].c_str());
}
if (args.size() < 2) {
RCLCPP_INFO(node->get_logger(), "Place publisher specifying object name and place position.");
RCLCPP_INFO(node->get_logger(), "Usage: place_publisher object_name [x y z]");
RCLCPP_INFO(node->get_logger(), "Example: place_publisher sports_ball");
RCLCPP_INFO(node->get_logger(), "Example: place_publisher sports_ball -0.45 -0.30 0.125");
rclcpp::shutdown();
return 0;
} else {
p.id = args[1];
}
RCLCPP_INFO(node->get_logger(), "place publisher %s [%f %f %f]",
p.id.c_str(), p.place_pose.pose.position.x, p.place_pose.pose.position.y, p.place_pose.pose.position.z);
while (rclcpp::ok()) {
p.place_pose.header.stamp = clock.now();
p.place_pose.header.frame_id = "base";
pub->publish(p);
rclcpp::Rate(0.5).sleep();
}
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
}
================================================
FILE: grasp_apps/recognize_pick/src/recognize_pick.cpp
================================================
#include
#include
#include
#include
#include
#include
#include
#include
#define robot_enable
using GraspPlanning = moveit_msgs::srv::GraspPlanning;
/* pick position in [x, y, z, R, P, Y]*/
static std::vector pick_ = {0.0, -0.54, 0.145, 3.14, 0.0, 1.956};
/* place position in [x, y, z, R, P, Y]*/
static std::vector place_ = {-0.45, -0.30, 0.125, 3.14, 0.0, 1.956};
/* pre-pick position in joint values*/
static std::vector joint_values_pick = {1.065, -1.470, 1.477, -1.577, -1.556, 0};
/* place position in joint values*/
static std::vector joint_values_place = {0.385, -1.470, 1.477, -1.577, -1.556, 0};
static double vel_ = 0.4, acc_ = 0.4, vscale_ = 0.5, appr_ = 0.1;
static std::shared_ptr robot_ = nullptr;
static rclcpp::Node::SharedPtr node_ = nullptr;
static std::shared_ptr result_ = nullptr;
static moveit_msgs::msg::PlaceLocation::SharedPtr place_pose_ = nullptr;
static void place_callback(const moveit_msgs::msg::PlaceLocation::SharedPtr msg) {
place_pose_ = msg;
}
int main(int argc, char **argv)
{
rclcpp::init(argc, argv);
// init robot control
robot_ = std::make_shared("robot_control",
rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true));
robot_->parseArgs();
robot_->startLoop();
rclcpp::sleep_for(2s);
#ifdef robot_enable
// reset joint
robot_->moveToJointValues(joint_values_place, vel_, acc_);
#endif
// init random pick node
node_ = rclcpp::Node::make_shared("random_pick");
tf2_ros::StaticTransformBroadcaster tfb(node_);
// subscribe place callback
auto sub = node_->create_subscription(
"/recognize_pick/place", rclcpp::QoS(rclcpp::KeepLast(0)), place_callback);
// create client
auto client = node_->create_client("plan_grasps");
// wait for service
while (!client->wait_for_service(5s)) {
RCLCPP_INFO(node_->get_logger(), "Wait for service");
}
RCLCPP_INFO(node_->get_logger(), "Got service");
while(rclcpp::ok())
{
if (place_pose_ == nullptr) {
RCLCPP_INFO(node_->get_logger(), "Wait for place mission");
rclcpp::spin_some(node_);
rclcpp::sleep_for(std::chrono::seconds(2));
continue;
}
moveit_msgs::msg::PlaceLocation::SharedPtr place = place_pose_;
RCLCPP_INFO(node_->get_logger(), "Place %s", place->id.c_str());
// get grasp poses
auto request = std::make_shared();
request->target.id = place->id;
auto result_future = client->async_send_request(request);
RCLCPP_INFO(node_->get_logger(), "Request sent");
// wait for response
if (rclcpp::spin_until_future_complete(node_, result_future) !=
rclcpp::executor::FutureReturnCode::SUCCESS)
{
continue;
}
// get response
if (moveit_msgs::msg::MoveItErrorCodes::SUCCESS == result_future.get()->error_code.val) {
result_ = result_future.get();
RCLCPP_INFO(node_->get_logger(), "Response received %d", result_->error_code.val);
} else continue;
geometry_msgs::msg::PoseStamped p = result_->grasps[0].grasp_pose;
// publish grasp pose
tf2::Quaternion q(p.pose.orientation.x, p.pose.orientation.y, p.pose.orientation.z, p.pose.orientation.w);
double roll, pitch, yaw;
tf2::Matrix3x3 r;
r.setRotation(q);
r.getRPY(roll, pitch, yaw);
RCLCPP_INFO(node_->get_logger(), "**********pick pose [position %f %f %f, quat %f %f %f %f, RPY %f %f %f]",
p.pose.position.x, p.pose.position.y, p.pose.position.z,
p.pose.orientation.x, p.pose.orientation.y, p.pose.orientation.z, p.pose.orientation.w,
roll, pitch, yaw);
geometry_msgs::msg::TransformStamped tf_msg;
tf_msg.header = p.header;
tf_msg.child_frame_id = "grasp_pose";
tf_msg.transform.translation.x = p.pose.position.x;
tf_msg.transform.translation.y = p.pose.position.y;
tf_msg.transform.translation.z = p.pose.position.z;
tf_msg.transform.rotation = p.pose.orientation;
tfb.sendTransform(tf_msg);
#ifdef robot_enable
// pick
robot_->moveToJointValues(joint_values_pick, vel_, acc_);
robot_->pick(p, vel_, acc_, vscale_, appr_);
// place
robot_->moveToJointValues(joint_values_place, vel_, acc_);
robot_->place(place_[0], place_[1], place_[2], place_[3], place_[4], place_[5], vel_, acc_, vscale_, appr_);
#endif
rclcpp::spin_some(node_);
place_pose_ = nullptr;
}
rclcpp::shutdown();
return 0;
}
================================================
FILE: grasp_msgs/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.5)
project(grasp_msgs)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
set(msg_files
"msg/GraspConfig.msg"
"msg/GraspConfigList.msg"
"msg/SamplesMsg.msg"
)
rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
DEPENDENCIES builtin_interfaces std_msgs geometry_msgs
ADD_LINTER_TESTS
)
ament_export_dependencies(rosidl_default_runtime)
ament_package()
================================================
FILE: grasp_msgs/msg/CloudIndexed.msg
================================================
# This message holds a point cloud and a list of indices into the point cloud
# at which to sample grasp candidates.
# The point cloud.
gpd/CloudSources cloud_sources
# The indices into the point cloud at which to sample grasp candidates.
std_msgs/Int64[] indices
================================================
FILE: grasp_msgs/msg/CloudSamples.msg
================================================
# This message holds a point cloud and a list of samples at which the grasp
# detector should search for grasp candidates.
# The point cloud.
gpd/CloudSources cloud_sources
# The samples, as (x,y,z) points, at which to search for grasp candidates.
geometry_msgs/Point[] samples
================================================
FILE: grasp_msgs/msg/CloudSources.msg
================================================
# This message holds a point cloud that can be a combination of point clouds
# from different camera sources (at least one). For each point in the cloud,
# this message also stores the index of the camera that produced the point.
# The point cloud.
sensor_msgs/PointCloud2 cloud
# For each point in the cloud, the index of the camera that acquired the point.
std_msgs/Int64[] camera_source
# A list of camera positions at which the point cloud was acquired.
geometry_msgs/Point[] view_points
================================================
FILE: grasp_msgs/msg/GraspConfig.msg
================================================
# This message describes a 2-finger grasp configuration by its 6-DOF pose,
# consisting of a 3-DOF position and 3-DOF orientation, and the opening
# width of the robot hand.
# Position
geometry_msgs/Point bottom # centered bottom/base of the robot hand)
geometry_msgs/Point top # centered top/fingertip of the robot hand)
geometry_msgs/Point surface # centered position on object surface
# Orientation represented as three axis (R = [approach binormal axis])
geometry_msgs/Vector3 approach # The grasp approach direction
geometry_msgs/Vector3 binormal # The binormal
geometry_msgs/Vector3 axis # The hand axis
geometry_msgs/Point sample # Point at which the grasp was found
std_msgs/Float32 width # Required aperture (opening width) of the robot hand
std_msgs/Float32 score # Score assigned to the grasp by the classifier
================================================
FILE: grasp_msgs/msg/GraspConfigList.msg
================================================
# This message stores a list of grasp configurations.
# The time of acquisition, and the coordinate frame ID.
std_msgs/Header header
# The list of grasp configurations.
grasp_msgs/GraspConfig[] grasps
# Name of the known object these grasps associated to.
string object_name
================================================
FILE: grasp_msgs/msg/SamplesMsg.msg
================================================
# This message describes a set of point samples at which to detect grasps.
# Header
std_msgs/Header header
# The samples, as (x,y,z) points, at which to search for grasp candidates.
geometry_msgs/Point[] samples
================================================
FILE: grasp_msgs/package.xml
================================================
grasp_msgs0.5.0ROS2 messages definitions for grasp librarySharron LIUApache License 2.0ament_cmakerosidl_default_generatorsbuiltin_interfacesstd_msgsgeometry_msgsrosidl_default_runtimebuiltin_interfacesstd_msgsgeometry_msgsament_lint_commonrosidl_interface_packagesament_cmake
================================================
FILE: grasp_ros2/CMakeLists.txt
================================================
# Copyright (c) 2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5)
project(grasp_ros2)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if(CMAKE_BUILD_TYPE EQUAL "RELEASE")
message(STATUS "Create Release Build.")
set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
else()
message(STATUS "Create Debug Build.")
endif()
if(BUILD_RECOGNIZE_PICK EQUAL "ON")
add_definitions("-DRECOGNIZE_PICK")
endif()
find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(grasp_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(moveit_msgs)
if(BUILD_RECOGNIZE_PICK STREQUAL "ON")
find_package(people_msgs)
endif()
find_package(visualization_msgs)
find_package(tf2)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(trajectory_msgs REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(Eigen3 REQUIRED)
# GPG
find_library(gpg_LIBRARIES grasp_candidates_generator)
find_path(gpg_INCLUDE_DIRS gpg/grasp.h)
# GPD
find_library(gpd_LIBRARIES grasp_pose_detection)
find_path(gpd_INCLUDE_DIRS gpd/grasp_detector.h)
# PCL
find_package(PCL 1.8.1 EXACT)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
include_directories(
include
${rclcpp_INCLUDE_DIRS}
${builtin_interfaces_INCLUDE_DIRS}
${grasp_msgs_INCLUDE_DIRS}
${sensor_msgs_INCLUDE_DIRS}
${moveit_msgs_INCLUDE_DIRS}
if(BUILD_RECOGNIZE_PICK STREQUAL "ON")
${people_msgs_INCLUDE_DIRS}
endif
${tf2_geometry_msgs_INCLUDE_DIRS}
${trajectory_msgs_INCLUDE_DIRS}
${visualization_msgs_INCLUDE_DIRS}
${pcl_conversions_INCLUDE_DIRS}
${tf2_INCLUDE_DIRS}
${gpg_INCLUDE_DIRS}
${gpd_INCLUDE_DIRS}
)
# create ament index resource which references the libraries in the binary dir
set(node_plugins "")
# grasp detect
set(libgrasp_detect "grasp_detect")
add_library(${libgrasp_detect} SHARED
src/consts.cpp
src/ros_params.cpp
src/grasp_detector_gpd.cpp)
target_compile_definitions(${libgrasp_detect}
PRIVATE "GRASP_ROS2_BUILDING_DLL")
ament_target_dependencies(${libgrasp_detect}
"class_loader"
"rclcpp"
"rclcpp_components"
"grasp_msgs"
"sensor_msgs"
"moveit_msgs"
if(BUILD_RECOGNIZE_PICK STREQUAL "ON")
"people_msgs"
endif()
"visualization_msgs")
target_link_libraries(${libgrasp_detect}
${gpg_LIBRARIES}
${gpd_LIBRARIES}
${PCL_LIBRARIES}
)
rclcpp_components_register_nodes(${libgrasp_detect} "grasp_ros2::GraspDetectorGPD")
set(node_plugins "${node_plugins}grasp_ros2::GraspDetectorGPD;$\n")
# grasp plan
set(libgrasp_plan "grasp_plan")
add_library(${libgrasp_plan} SHARED
src/consts.cpp
src/ros_params.cpp
src/grasp_planner.cpp)
target_compile_definitions(${libgrasp_plan}
PRIVATE "GRASP_ROS2_BUILDING_DLL")
ament_target_dependencies(${libgrasp_plan}
"class_loader"
"rclcpp"
"rclcpp_components"
"grasp_msgs"
"moveit_msgs"
"tf2"
"tf2_ros"
"tf2_geometry_msgs"
"trajectory_msgs")
target_link_libraries(${libgrasp_plan}
)
rclcpp_components_register_nodes(${libgrasp_plan} "grasp_ros2::GraspPlanner")
set(node_plugins "${node_plugins}grasp_ros2::GraspPlanner;$\n")
add_executable(${PROJECT_NAME}
src/grasp_composition.cpp
)
ament_target_dependencies(${PROJECT_NAME}
"rclcpp"
"builtin_interfaces"
"grasp_msgs"
"sensor_msgs"
"moveit_msgs"
"visualization_msgs"
"tf2"
"tf2_ros"
"tf2_geometry_msgs"
"trajectory_msgs"
"pcl_conversions"
)
target_link_libraries(${PROJECT_NAME}
${ament_LIBRARIES}
${gpg_LIBRARIES}
${gpd_LIBRARIES}
${PCL_LIBRARIES}
${libgrasp_detect}
${libgrasp_plan}
)
# Install libs
install(TARGETS
${libgrasp_detect}
${libgrasp_plan}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
# Install binaries
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
)
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)
# Install header files
install(
DIRECTORY include/
DESTINATION include
)
# Flags
if(UNIX OR APPLE)
# Linker flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# GCC specific flags. ICC is compatible with them.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# In Clang, -z flags are not compatible, they need to be passed to linker via -Wl.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
endif()
# Compiler flags.
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# GCC specific flags.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector-strong")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
# Clang is compatbile with some of the flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
# Same as above, with exception that ICC compilation crashes with -fPIE option, even
# though it uses -pie linker option that require -fPIE during compilation. Checksec
# shows that it generates correct PIE anyway if only -pie is provided.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif()
# Generic flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security \
-Wall -fopenmp")
set( CUDA_PROPAGATE_HOST_FLAGS OFF )
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
add_subdirectory(tests)
endif()
ament_package()
================================================
FILE: grasp_ros2/cfg/grasp_ros2_params.yaml
================================================
GraspDetectorGPD:
ros__parameters:
cloud_topic: /camera/pointcloud
#cloud_topic: /mechmind/color_point_cloud
rviz: true
device: 0 # 0:CPU, 1:GPU, 2:VPU
auto_mode: true
plane_remove: true
# grasp workspace in camera frames
workspace: [-0.21, 0.29, -0.22, 0.15, 0.0, 1.0] # Realsense
#workspace: [-0.16, 0.34, -0.26, 0.14, 1.4, 1.8] # Mechmind
# gripper geometry parameters in metre
# finger_width: the finger thickness
# hand_outer_diameter: the maximum robot hand aperture
# hand_depth: the hand depth (the finger length)
# hand_height: the finger breadth
finger_width: 0.005
hand_outer_diameter: 0.100
hand_depth: 0.038
hand_height: 0.020
GraspPlanner:
ros__parameters:
grasp_score_threshold: 20
grasp_frame_id: "camera_color_optical_frame" # Realsense
#grasp_frame_id: "mechmind_camera" # Mechmind
grasp_offset: [0.000, 0.000, 0.0]
eef_offset: 0.174
eef_yaw_offset: 0.7854 # M_PI/4
finger_joint_names: ["panda_finger_joint1", "panda_finger_joint2"]
================================================
FILE: grasp_ros2/cfg/random_pick.yaml
================================================
GraspDetectorGPD:
ros__parameters:
#cloud_topic: /camera/pointcloud
cloud_topic: /mechmind/color_point_cloud
rviz: true
device: 0 # 0:CPU, 1:GPU, 2:VPU
auto_mode: true
plane_remove: true
# grasp workspace in camera frames
#workspace: [-0.21, 0.29, -0.22, 0.15, 0.0, 1.0] # Realsense
workspace: [-0.16, 0.28, -0.26, 0.14, 1.4, 1.65] # Mechmind
# gripper geometry parameters in metre
# finger_width: the finger thickness
# hand_outer_diameter: the maximum robot hand aperture
# hand_depth: the hand depth (the finger length)
# hand_height: the finger breadth
finger_width: 0.005
hand_outer_diameter: 0.100
hand_depth: 0.038
hand_height: 0.020
num_samples: 200
GraspPlanner:
ros__parameters:
grasp_score_threshold: 0
grasp_frame_id: "base"
grasp_approach: [0.0, 0.0, -1.0]
grasp_approach_angle: 0.523 # 1.047=PI/3 # 0.785=PI/4 # 0.523=PI/6 # 0.345=PI/9 # acceptable approaching angle
grasp_offset: [0.004, 0.000, 0.0]
# grasp boundry in grasp_frame_id
grasp_boundry: [-0.2, 0.2, -0.65, -0.30, -0.15, 0.15]
eef_offset: 0.162
eef_yaw_offset: -0.7854 # M_PI/4
finger_joint_names: ["panda_finger_joint1", "panda_finger_joint2"]
================================================
FILE: grasp_ros2/cfg/recognize_pick.yaml
================================================
GraspDetectorGPD:
ros__parameters:
cloud_topic: /camera/pointcloud
# cloud_topic: "/camera/aligned_depth_to_color/color/points"
object_topic: "/ros2_openvino_toolkit/segmented_obejcts"
rviz: true
device: 1 # 0:CPU, 1:GPU, 2:VPU
auto_mode: false
plane_remove: true
object_detect: true
# grasp workspace in camera frames
workspace: [-0.23, 0.23, -0.33, 0.05, 0.0, 1.0]
# gripper geometry parameters in metre
# finger_width: the finger thickness
# hand_outer_diameter: the maximum robot hand aperture
# hand_depth: the hand depth (the finger length)
# hand_height: the finger breadth
finger_width: 0.005
hand_outer_diameter: 0.100
hand_depth: 0.038
hand_height: 0.020
GraspPlanner:
ros__parameters:
grasp_score_threshold: 1
grasp_frame_id: "base"
grasp_approach: [0.0, 0.0, -1.0] # expect approaching in -z axis
grasp_approach_angle: 0.7 # 1.047=PI/3 # 0.785=PI/4 # 0.523=PI/6 # 0.345=PI/9 # acceptable approaching angle
grasp_offset: [0.006, -0.003, 0.000]
# grasp boundry in grasp_frame_id
grasp_boundry: [-0.2, 0.2, -0.65, -0.30, -0.15, 0.15]
eef_offset: 0.154
eef_yaw_offset: 0.7854 # M_PI/4
finger_joint_names: ["panda_finger_joint1", "panda_finger_joint2"]
================================================
FILE: grasp_ros2/cfg/test_grasp_ros2.yaml
================================================
GraspDetectorGPD:
ros__parameters:
cloud_topic: /camera/pointcloud
rviz: false
device: 0
auto_mode: false
GraspPlanner:
ros__parameters:
grasp_score_threshold: 0
grasp_frame_id: "camera_color_optical_frame"
================================================
FILE: grasp_ros2/include/grasp_library/ros2/consts.hpp
================================================
// Copyright (c) 2019 Intel Corporation. All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRASP_LIBRARY__ROS2__CONSTS_HPP_
#define GRASP_LIBRARY__ROS2__CONSTS_HPP_
#include
namespace grasp_ros2
{
/** Consts class
*
* \brief A class contains global constatnts definition for grasp library.
*
*/
class Consts
{
public:
/** Topic name of "PointCloud2" message published by an RGBD sensor.*/
static const char kTopicPointCloud2[];
/** Topic name of "detected objects" message published by Object Detector.*/
static const char kTopicDetectedObjects[];
/** Topic name of "detected grasps" message published by this Grasp Detector.*/
static const char kTopicDetectedGrasps[];
/** Topic name of "rviz grasps" message published by this Grasp Detector.*/
static const char kTopicVisualGrasps[];
/** Topic name of "tabletop pointcloud" message published by this Grasp Detector.*/
static const char kTopicTabletop[];
};
} // namespace grasp_ros2
#endif // GRASP_LIBRARY__ROS2__CONSTS_HPP_
================================================
FILE: grasp_ros2/include/grasp_library/ros2/grasp_detector_base.hpp
================================================
// Copyright (c) 2019 Intel Corporation. All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRASP_LIBRARY__ROS2__GRASP_DETECTOR_BASE_HPP_
#define GRASP_LIBRARY__ROS2__GRASP_DETECTOR_BASE_HPP_
#include
#include
namespace grasp_ros2
{
/** GraspCallback class
*
* \brief Abstract base class for grasp callback.
*
* A grasp planner inherits from this class get called back for grasp detection resutls.
*/
class GraspCallback
{
public:
/**
* \brief Callback for grasp detection results.
*
* \param msg Pointer to grasp detection results.
*/
virtual void grasp_callback(const grasp_msgs::msg::GraspConfigList::SharedPtr msg) = 0;
};
/** GraspDetectorBase class
*
* \brief A base class for detecting grasp poses from visual input.
*
* This class defines uniform interface for grasp library, regardless whichever algorithm
* is used for grasp detection.
*/
class GraspDetectorBase
{
public:
/**
* \brief Constructor.
*/
GraspDetectorBase()
: object_name_(""), grasp_cb_(nullptr)
{
}
/**
* \brief Destructor.
*/
~GraspDetectorBase()
{
}
/**
* \brief Start grasp detection.
* When this function is called, GraspDetector starts processing visual input.
* \param name Name of the object for which to detect grasps
*/
void start(std::string name = "")
{
started_ = true;
object_name_ = name;
}
/**
* \brief Stop grasp detection.
* When this function is called, GraspDetector stops processing visual input.
*/
void stop()
{
started_ = false;
}
/**
* \brief Register grasp callback function.
*
* \param cb Callback function to be registered.
*/
void add_callback(GraspCallback * cb)
{
grasp_cb_ = cb;
}
protected:
bool started_ = false;
std::string object_name_;
GraspCallback * grasp_cb_;
};
} // namespace grasp_ros2
#endif // GRASP_LIBRARY__ROS2__GRASP_DETECTOR_BASE_HPP_
================================================
FILE: grasp_ros2/include/grasp_library/ros2/grasp_detector_gpd.hpp
================================================
// Copyright (c) 2018 Intel Corporation. All Rights Reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRASP_LIBRARY__ROS2__GRASP_DETECTOR_GPD_HPP_
#define GRASP_LIBRARY__ROS2__GRASP_DETECTOR_GPD_HPP_
// ROS2
#include
#include
#ifdef RECOGNIZE_PICK
#include
#endif
#include
#include
#include
#include
// PCL
#include
#include
#include
// eigen
#include
// GPG
#include
// this project (messages)
#include
#include
#include
// system
#include
#include