Merge Dev to Main for release 0.4.0 (#241)

* Fixing issue with Demo.cs not working with new URDF Importer co-routine

* remove unused import (#163)

* update package import urls for tcp connector and urdf importer (#166)

* Update urdf_tutorial.md (#168)

* Added M prefixes to docs (#167)

* Adding Editor version to Ros Integration Readme

* Updating package dependencies to proper versions

Pick and place tutorial was failing to compile its scripts because
the package manifest was pointing to an older version of
ROS-TCP-Connector.  Updated the manifest and also pulled latest changes
for ros_tcp_endpoint.

Tested by running DemoScene

* Updating Contribution Content (#186)

* Contributing content

* PR feedback

* Adding PR template (#191)

* fixing typo in ros-unity service tutorial (#198)

* Unity service example (#199)

* added example of implementing a UnityService

* adding tutorial for unity service

* added a couple comments to the example code

* typos and code standard fixes

* consistency: changing the service name for position_service to pos_srv

* updating the tutorial to match the corresponding script

* Update the list of new physics features (#204)

* add new sections for the released new physics features

Co-authored-by: Amanda <31416491+at669@users.noreply.github.com>

* Update to 0.3.0 (#207)

* Removing old version tags from git URLs in quick_setup

Addressing user issue #209. Our quick_setup guide was still recommending users check out v.0.2.0 of our packages. Removed the reference to a specific package version and instead included a note that users can explicitly declare a package version if desired.

Tested by making the change locally in the package manifest.

* Adding network troubleshooting doc. (#195)

* Adding network troubleshooting doc.

* Updating tutorials to the glorious new world (#211)

* add changelog (#218)

add changelog

* Forum links to README, config.yml (#219)

* Add linter (#227)

* Add linter and pre-commit hooks

* Formatting

* Remove setting up ruby

* Resolve conflicts 2 (#233)

* Merging dev branch into main (#78)

* Reverting params.yaml and updating code in server_endpoint.md
* TcpServer class was renamed
* convert all files with dos2unix (#76)
* Minor tutorial tweaks, update version numbers

Co-authored-by: Devin Miller <devin.miller@unity3d.com>
Co-authored-by: Peifeng Jing <peifeng.jing@unity3d.com>

* Updating instructions for URDF repository  (#71)

* 1. Adding images for URDF tutorial 2. Adding instructions highlighting Disable Collison tag

* Adding link to example of disable collision tag in the niryo_one URDF file

* Sarah/readme update (#112)

* Adding physics roadmap and minor formatting changes

* formatting nits

* Calling out feature requests

* Update for ROS-TCP-Connector namespace changes

* Mpinol/simrealrebased (#107)

* Adding sim and real pnp files.

* Update with new instructions (#147)

* Update tutorial text (#148)

* AIRO-405 Adding Yamato boilerplate to Robotics Hub (#144)

* Adding testing boilerplate

* Adding tests to run after message generation

* Tweaks to ensure run works in Bokken image

* Enabling audio by default, but disabling it in yamato config

* Hotfix: Remove DemoScripts asmdef

The DemoScripts.asmdef was a bit of experimental cruft that snuck in via
my Yamato changes. This causes Demo.cs to compile as an Editor script,
which  means it can no longer be instantiated in the scene hierarchy
(this breaks the demo).  Removing the asmdef puts things back to normal.

Tested by running the demo.

* Use latest main

* Fixing issue with Demo.cs not working with new URDF Importer co-routine

* remove unused import (#163)

* update package import urls for tcp connector and urdf importer (#166)

* Update urdf_tutorial.md (#168)

* Added M prefixes to docs (#167)

* Adding Editor version to Ros Integration Readme

* Updating package dependencies to proper versions

Pick and place tutorial was failing to compile its scripts because
the package manifest was pointing to an older version of
ROS-TCP-Connector.  Updated the manifest and also pulled latest changes
for ros_tcp_endpoint.

Tested by running DemoScene

* Updating Contribution Content (#186)

* Contributing content

* PR feedback

* Adding PR template (#191)

* Unity service example (#199)

* added example of implementing a UnityService

* adding tutorial for unity service

* added a couple comments to the example code

* typos and code standard fixes

* consistency: changing the service name for position_service to pos_srv

* updating the tutorial to match the corresponding script

* Update the list of new physics features (#204)

* add new sections for the released new physics features

Co-authored-by: Amanda <31416491+at669@users.noreply.github.com>

* Update to 0.3.0 (#207)

* Removing old version tags from git URLs in quick_setup

Addressing user issue #209. Our quick_setup guide was still recommending users check out v.0.2.0 of our packages. Removed the reference to a specific package version and instead included a note that users can explicitly declare a package version if desired.

Tested by making the change locally in the package manifest.

* Updating tutorials to the glorious new world (#211)

* add changelog (#218)

add changelog

* Forum links to README, config.yml (#219)

* Add linter (#227)

* Add linter and pre-commit hooks

* Formatting

* Remove setting up ruby

* Fixing issue with Demo.cs not working with new URDF Importer co-routine (#162)

Co-authored-by: Devin Miller <devin.miller@unity3d.com>

* Readme: New Link (#172)

* Fixing issue with Demo.cs not working with new URDF Importer co-routine

* remove unused import (#163)

* README update

* PR feedback

* Blog post link update

Co-authored-by: Devin Miller <devin.miller@unity3d.com>
Co-authored-by: peifeng-unity <peifeng.jing@unity3d.com>

* Added newsletter link (#175)

* remove stale merge

* Minor formmating

* Fix README and git sub module

* Revert unintentional change in urdf_appendix.md

* Add back tutorials/pick_and_place/ROS/src/ros_tcp_endpoint

Co-authored-by: LaurieCheers-unity <73140792+LaurieCheers-unity@users.noreply.github.com>
Co-authored-by: Devin Miller <devin.miller@unity3d.com>
Co-authored-by: Peifeng Jing <peifeng.jing@unity3d.com>
Co-authored-by: vidurvij-Unity <60901103+vidurvij-Unity@users.noreply.github.com>
Co-authored-by: sarah-gibson <72100462+sarah-gibson@users.noreply.github.com>
Co-authored-by: Devin Miller (Unity) <mrpropellers@users.noreply.github.com>
Co-authored-by: peifeng-unity <56408141+peifeng-unity@users.noreply.github.com>
Co-authored-by: Amanda <31416491+at669@users.noreply.github.com>
Co-authored-by: Hamid Younesy <hyounesy@users.noreply.github.com>

* Update Demo (#235)

* Update Demo

* Minor fix

* Update tutorial manifest to use v0.4.0

* Update ros_tcp_endpoint module

* Update quick_setup version

* Update tutorial manifest

* added chmod to make sure the python scripts are executable (#239)

* Minor update in README.md

* minor fix

Co-authored-by: Devin Miller <devin.miller@unity3d.com>
Co-authored-by: peifeng-unity <56408141+peifeng-unity@users.noreply.github.com>
Co-authored-by: vidurvij-Unity <60901103+vidurvij-Unity@users.noreply.github.com>
Co-authored-by: LaurieCheers-unity <73140792+LaurieCheers-unity@users.noreply.github.com>
Co-authored-by: Devin Miller (Unity) <mrpropellers@users.noreply.github.com>
Co-authored-by: Amanda <31416491+at669@users.noreply.github.com>
Co-authored-by: Hamid Younesy <hyounesy@users.noreply.github.com>
Co-authored-by: Peifeng Jing <peifeng.jing@unity3d.com>
Co-authored-by: sarah-gibson <72100462+sarah-gibson@users.noreply.github.com>
This commit is contained in:
Shuo Diao 2021-06-01 15:00:16 -07:00 коммит произвёл GitHub
Родитель b7763a5fb2
Коммит 0b08f4f754
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
50 изменённых файлов: 548 добавлений и 282 удалений

75
.editorconfig Normal file
Просмотреть файл

@ -0,0 +1,75 @@
; see http://editorconfig.org/ for docs on this file
; See https://github.com/dotnet/format for dotnet format
root = true
[*]
ignore_if_in_header = This code was generated by a tool|<auto-generated>
indent_style = space
indent_size = 4
; uncomment to help with sharing files across os's (i.e. network share or through local vm)
#end_of_line = lf
; avoid a bom, which causes endless problems with naive text tooling
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
; keeping auto-format enabled helps avoid merge hell for projects without CI-based format validation
#disable_auto_format = true
[*.cs]
; uncomment to enable full formatting of c# files
formatters = generic, uncrustify
[*.asmdef]
scrape_api = true
[**/Tests/**.asmdef]
scrape_api = false
[*.Tests.asmdef]
scrape_api = false
[*.md]
indent_size = 2
; trailing whitespace is unfortunately significant in markdown
trim_trailing_whitespace = false
; uncomment to enable basic formatting of markdown files
#formatters = generic
[{Makefile,makefile}]
; tab characters are part of the Makefile format
indent_style = tab
[*.asmdef]
indent_size = 4
[*.json]
indent_size = 2
[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}]
end_of_line = crlf
; this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited.
; the settings are meant to closely match what VS does to minimize unnecessary diffs.
[*.{vcxproj,vcxproj.filters}]
indent_style = space
indent_size = 2
end_of_line = crlf
charset = utf-8-bom
trim_trailing_whitespace = true
insert_final_newline = false
; must be broken out because of 51-char bug (https://github.com/editorconfig/editorconfig-visualstudio/issues/21)
[*.{csproj,pyproj,props,targets}]
indent_style = space
indent_size = 2
end_of_line = crlf
charset = utf-8-bom
trim_trailing_whitespace = true
insert_final_newline = false
[*.{sln,sln.template}]
indent_style = tab
indent_size = 4
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

5
.github/ISSUE_TEMPLATE/config.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Unity Robotics Forum
url: https://forum.unity.com/forums/robotics.623/
about: Discussions and questions about Unity Robotics tools, demos, or integrations.

7
.github/PULL_REQUEST_TEMPLATE.md поставляемый
Просмотреть файл

@ -16,7 +16,7 @@ Provide any relevant links here.
## Testing and Verification
Please describe the tests that you ran to verify your changes. Please also provide instructions, ROS packages, and Unity project files as appropriate so we can reproduce the test environment.
Please describe the tests that you ran to verify your changes. Please also provide instructions, ROS packages, and Unity project files as appropriate so we can reproduce the test environment.
### Test Configuration:
- Unity Version: [e.g. Unity 2020.2.0f1]
@ -27,8 +27,9 @@ Please describe the tests that you ran to verify your changes. Please also provi
## Checklist
- [ ] Ensured this PR is up-to-date with the `dev` branch
- [ ] Created this PR to target the `dev` branch
- [ ] Followed the style guidelines as described in the [Contribution Guidelines](../CONTRIBUTING.md)
- [ ] Followed the style guidelines as described in the [Contribution Guidelines](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/CONTRIBUTING.md)
- [ ] Added tests that prove my fix is effective or that my feature works
- [ ] Updated the [Changelog](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/dev/CHANGELOG.md) and described changes in the [Unreleased section](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/dev/CHANGELOG.md#unreleased)
- [ ] Updated the documentation as appropriate
## Other comments
## Other comments

19
.github/workflows/pre-commit.yaml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,19 @@
name: pre-commit
on:
pull_request:
push:
branches: [dev]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7.x
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- uses: pre-commit/action@v2.0.0

2
.gitignore поставляемый
Просмотреть файл

@ -2,4 +2,4 @@
.swp
.idea
.vscode/
tutorials/pick_and_place/PickAndPlaceProject/Packages/packages-lock.json
tutorials/pick_and_place/PickAndPlaceProject/Packages/packages-lock.json

32
.pre-commit-config.yaml Normal file
Просмотреть файл

@ -0,0 +1,32 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: mixed-line-ending
exclude: >
(?x)^(
.*cs.meta|
.*.css|
.*.meta|
.*.mat|
.*.preset|
.*.lighting|
.*.dae
)$
args: [--fix=lf]
- id: trailing-whitespace
name: trailing-whitespace-markdown
types: [markdown]
- id: check-merge-conflict
args: [--assume-in-merge]
- id: check-yaml
# Won't handle the templating in yamato
exclude: \.yamato/.*
- repo: https://github.com/dotnet/format
rev: "7e343070a0355c86f72bdee226b5e19ffcbac931"
hooks:
- id: dotnet-format
args: [--folder, --include]

21
CHANGELOG.md Normal file
Просмотреть файл

@ -0,0 +1,21 @@
# Changelog
All notable changes to this repository will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased
### Upgrade Notes
### Known Issues
### Added
### Changed
### Deprecated
### Removed
### Fixed

Просмотреть файл

@ -1,7 +1,7 @@
# Contribution Guidelines
Thank you for your interest in contributing to Unity Robotics! To facilitate your
contributions, we've outlined a brief set of guidelines to ensure that your extensions
Thank you for your interest in contributing to Unity Robotics! To facilitate your
contributions, we've outlined a brief set of guidelines to ensure that your extensions
can be easily integrated.
## Communication
@ -40,10 +40,10 @@ We run continuous integration on all PRs; all tests must be passing before the P
All Python code should follow the [PEP 8 style guidelines](https://pep8.org/).
All C# code should follow the [Microsoft C# Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions).
Additionally, the [Unity Coding package](https://docs.unity3d.com/Packages/com.unity.coding@0.1/manual/index.html)
can be used to format, encode, and lint your code according to the standard Unity
development conventions. Be aware that these Unity conventions will supersede the
All C# code should follow the [Microsoft C# Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions).
Additionally, the [Unity Coding package](https://docs.unity3d.com/Packages/com.unity.coding@0.1/manual/index.html)
can be used to format, encode, and lint your code according to the standard Unity
development conventions. Be aware that these Unity conventions will supersede the
Microsoft C# Coding Conventions where applicable.
Please note that even if the code you are changing does not adhere to these guidelines,
@ -60,5 +60,5 @@ email us at [unity-robotics@unity3d.com](mailto:unity-robotics@unity3d.com).
## Contribution review
Once you have a change ready following the above ground rules, simply make a
Once you have a change ready following the above ground rules, simply make a
pull request in GitHub.

Просмотреть файл

@ -33,8 +33,7 @@ A robot simulation demonstrating Unity's new physics solver (no ROS dependency).
| Tutorial | Description |
|---|---|
| [ROS–Unity Integration](tutorials/ros_unity_integration/README.md) | A set of component-level tutorials showing how to set up communication between ROS and Unity |
| [URDF Importer](tutorials/urdf_importer/urdf_tutorial.md) | Steps on using the Unity package for loading [URDF](http://wiki.ros.org/urdf) files |
| [URDF Importer](tutorials/urdf_importer/urdf_tutorial.md) | Steps on using the Unity package for loading [URDF](http://wiki.ros.org/urdf) files |
## Component Repos
@ -57,7 +56,7 @@ Unite Now 2020: Simulating Robots with ROS and Unity [video](https://resources.u
- (August 26, 2020)
Announcing Unity Robotic Simulation [blog post](https://unity.com/solutions/automotive-transportation-manufacturing/robotics)
- (May 20, 2020)
Use articulation bodies to easily prototype industrial designs with realistic motion and behavior [blog post](https://blogs.unity3d.com/2020/05/20/use-articulation-bodies-to-easily-prototype-industrial-designs-with-realistic-motion-and-behavior/)
Use articulation bodies to easily prototype industrial designs with realistic motion and behavior [blog post](https://blogs.unity3d.com/2020/05/20/use-articulation-bodies-to-easily-prototype-industrial-designs-with-realistic-motion-and-behavior/)
### More from Unity
@ -85,19 +84,20 @@ Interested in early access to ROS 2 integration? Email [unity-robotics@unity3d.c
## Community and Feedback
The Unity Robotics projects are open-source and we encourage and welcome contributions.
If you wish to contribute, be sure to review our [contribution guidelines](CONTRIBUTING.md)
The Unity Robotics projects are open-source and we encourage and welcome contributions.
If you wish to contribute, be sure to review our [contribution guidelines](CONTRIBUTING.md)
and [code of conduct](CODE_OF_CONDUCT.md).
## Support
For general questions, feedback, or feature requests, connect directly with the
For questions or discussions about Unity Robotics package installations or how to best set up and integrate your robotics projects, please create a new thread on the [Unity Robotics forum](https://forum.unity.com/forums/robotics.623/) and make sure to include as much detail as possible.
For feature requests, bugs, or other issues, please file a [GitHub issue](https://github.com/Unity-Technologies/Unity-Robotics-Hub/issues) using the provided templates and the Robotics team will investigate as soon as possible.
For any other questions or feedback, connect directly with the
Robotics team at [unity-robotics@unity3d.com](mailto:unity-robotics@unity3d.com).
For bugs or other issues, please file a GitHub issue and the Robotics team will
investigate the issue as soon as possible.
## Newsletter
To get notified about new updates and features, [sign up for our newsletter](https://create.unity3d.com/robotics-simulation-newsletter-sign-up)!
## License

13
faq.md
Просмотреть файл

@ -7,9 +7,7 @@
- [How can I install the Unity Packages without starting from a template project?](#how-can-i-install-the-unity-packages-without-starting-from-a-template-project)
- [ROS-TCP Endpoint/Connector](#ros-tcp-endpointconnector)
- [How does the TCP Endpoint compare to Rosbridge Server?](#how-does-the-tcp-endpoint-compare-to-rosbridge-server)
- [I receive a `Starting server on ...` message in my ROS terminal, but see a `SocketException: A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond.` in my Unity console.](#i-receive-a-starting-server-on--message-in-my-ros-terminal-but-see-a-socketexception-a-connection-attempt-failed-because-the-connected-party-did-not-respond-after-a-period-of-time-or-established-connection-failed-because-connected-host-has-failed-to-respond-in-my-unity-console)
- [I'm getting the error: `...failed because unknown error handler name 'rosmsg'`.](#im-getting-the-error-failed-because-unknown-error-handler-name-rosmsg)
- [Unity can't connect to ROS!](#unity-cant-connect-to-ros)
- [URDF-Importer](#urdf-importer)
- [I don't see an option to Import Robot from URDF, or I have compile errors upon importing the URDF-Importer.](#i-dont-see-an-option-to-import-robot-from-urdf-or-i-have-compile-errors-upon-importing-the-urdf-importer)
- [Can't find what you're looking for?](#cant-find-what-youre-looking-for)
@ -23,7 +21,7 @@ How does your Unity integration compare to ROS#?
---
Two of the Unity Robotics repos (URDF Importer and TCP Connector) have been forked from the [Siemens ROS# repo](https://github.com/siemens/ros-sharp).
In the URDF Importer we have added the functionality to instantiate a robot from URDF into a Unity scene with [Articulation Body](https://docs.unity3d.com/2020.2/Documentation/Manual/class-ArticulationBody.html) components on their corresponding joints.
In the URDF Importer we have added the functionality to instantiate a robot from URDF into a Unity scene with [Articulation Body](https://docs.unity3d.com/2020.2/Documentation/Manual/class-ArticulationBody.html) components on their corresponding joints.
Aside from facilitating communication with the TCP Endpoint, the TCP Connector contains the `MessageGeneration` code from ROS#. We added the extra functionality that when generating a C# class from a ROS message, functions are also generated that will serialize and deserialize the messages as ROS would internally.
@ -58,23 +56,16 @@ The time was logged when the message was sent from Unity before being serialized
- ROS# with ROS Bridge Suite took ~2 seconds
- TCP Connector with TCP Endpoint took ~0.17 seconds
I receive a `Starting server on ...` message in my ROS terminal, but see a `SocketException: A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond.` in my Unity console.
---
This is likely an issue with how your network adapters are set up if you are using a virtual machine. You may need to do some troubleshooting to ensure that your guest OS can talk to your host OS and vice versa. One simple way to do this is to set up a "Host-Only" style network, but this varies based on what virtualization software you're using. Try to ensure that you can `ping` your host OS's IP from inside the guest, and can `ping` the guest from the host, then try this last step again.
I'm getting the error: `...failed because unknown error handler name 'rosmsg'`.
---
This is due to a bug in an outdated package version. Try running `sudo apt-get update && sudo apt-get upgrade` to upgrade.
Unity can't connect to ROS!
---
Ensure that the ROS IP address is entered correctly as the `Host Name` in the RosConnect component in Unity, and if you are using a `params.yaml` file, that the appropriate IP addresses are filled in.
# URDF-Importer
I don't see an option to Import Robot from URDF, or I have compile errors upon importing the URDF-Importer.
---
The [ArticulationBody](https://docs.unity3d.com/2020.2/Documentation/Manual/class-ArticulationBody.html) has dependencies on Unity Editor versions [2020.2.0](https://unity3d.com/unity/whats-new/2020.2.0)+. Try updating your project to the latest 2020.2 release.
# Can't find what you're looking for?
Connect directly with the Robotics team at [unity-robotics@unity3d.com](mailto:unity-robotics@unity3d.com)!

Просмотреть файл

@ -1,7 +1,7 @@
# Pick-and-Place Tutorial: Part 0
This part provides two options for setting up your ROS workspace: using Docker, or manually setting up a catkin workspace.
**Table of Contents**
- [Option A: Use Docker](#option-a-use-docker)
- [Option B: Manual Setup](#option-b-manual-setup)
@ -34,15 +34,15 @@ git clone --recurse-submodules https://github.com/Unity-Technologies/Unity-Robot
docker build -t unity-robotics:pick-and-place -f docker/Dockerfile .
```
> Note: The provided Dockerfile uses the [ROS Melodic base Image](https://hub.docker.com/_/ros/). Building the image will install the necessary packages, copy the [provided ROS packages and submodules](ROS/) to the container, and build the catkin workspace.
1. Start the newly built Docker container:
> Note: The provided Dockerfile uses the [ROS Melodic base Image](https://hub.docker.com/_/ros/). Building the image will install the necessary packages, copy the [provided ROS packages and submodules](ROS/) to the container, and build the catkin workspace.
1. Start the newly built Docker container:
```docker
docker run -it --rm -p 10000:10000 -p 5005:5005 unity-robotics:pick-and-place /bin/bash
```
When this is complete, it will print: `Successfully tagged unity-robotics:pick-and-place`. This console should open into a bash shell at the ROS workspace root, e.g. `root@8d88ed579657:/catkin_ws#`.
When this is complete, it will print: `Successfully tagged unity-robotics:pick-and-place`. This console should open into a bash shell at the ROS workspace root, e.g. `root@8d88ed579657:/catkin_ws#`.
The ROS workspace is now ready to accept commands!
@ -50,12 +50,12 @@ The ROS workspace is now ready to accept commands!
## Option B: Manual Setup
1. Navigate to the `/PATH/TO/Unity-Robotics-Hub/tutorials/pick_and_place/ROS` directory of this downloaded repo.
1. Navigate to the `/PATH/TO/Unity-Robotics-Hub/tutorials/pick_and_place/ROS` directory of this downloaded repo.
- This directory will be used as the [ROS catkin workspace](http://wiki.ros.org/catkin/Tutorials/using_a_workspace).
- If you cloned the project and forgot to use `--recurse-submodules`, or if any submodule in this directory doesn't have content, you can run the command `git submodule update --init --recursive` to download packages for Git submodules.
- If you cloned the project and forgot to use `--recurse-submodules`, or if any submodule in this directory doesn't have content, you can run the command `git submodule update --init --recursive` to download packages for Git submodules.
- Copy or download this directory to your ROS operating system if you are doing ROS operations in another machine, VM, or container.
> Note: This contains the ROS packages for the pick-and-place task, including [ROS TCP Endpoint](https://github.com/Unity-Technologies/ROS-TCP-Endpoint), [Niryo One ROS stack](https://github.com/NiryoRobotics/niryo_one_ros), [MoveIt Msgs](https://github.com/ros-planning/moveit_msgs), `niryo_moveit`, and `niryo_one_urdf`.
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:
```bash
@ -75,7 +75,7 @@ The ROS workspace is now ready to accept commands!
1. If you have not already built and sourced the ROS workspace since importing the new ROS packages, navigate to your ROS workplace, and run `catkin_make && source devel/setup.bash`. Ensure there are no errors.
1. The ROS parameters will need to be set to your configuration in order to allow the server endpoint to fetch values for the TCP connection, stored in `src/niryo_moveit/config/params.yaml`. From your ROS workspace, assign the ROS IP in this `yaml` file:
```bash
echo "ROS_IP: $(hostname -I)" > src/niryo_moveit/config/params.yaml
```
@ -85,7 +85,7 @@ The ROS workspace is now ready to accept commands!
```yaml
ROS_IP: <your ROS IP>
```
e.g.
```yaml
@ -98,9 +98,9 @@ The ROS workspace is now ready to accept commands!
## Troubleshooting
- Building the Docker image may throw an `Could not find a package configuration file provided by...` exception if one or more of the directories in ROS/ appears empty. Try downloading the submodules again via `git submodule update --init --recursive`.
- `...failed because unknown error handler name 'rosmsg'` This is due to a bug in an outdated package version. Try running `sudo apt-get update && sudo apt-get upgrade` to upgrade packages.
- If the ROS TCP handshake fails (e.g. `ROS-Unity server listening...` printed on the Unity side but no `ROS-Unity Handshake received` on the ROS side), the ROS IP may not have been set correctly in the params.yaml file. Try running `echo "ROS_IP: $(hostname -I)" > src/niryo_moveit/config/params.yaml` in a terminal from your ROS workspace.
---
@ -108,7 +108,7 @@ The ROS workspace is now ready to accept commands!
## Resources
- [Getting started with Docker](https://docs.docker.com/get-started/)
- Setting up a ROS workspace:
> Note: this tutorial has been tested with ROS Melodic as well as ROS Noetic.
- http://wiki.ros.org/ROS/Installation
- http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment

Просмотреть файл

@ -21,9 +21,9 @@ This part includes downloading and installing the Unity Editor, setting up a bas
```
1. Install [Unity Hub](https://unity3d.com/get-unity/download).
1. Go to the [Unity 2020.2 Beta website](https://unity3d.com/unity/beta/2020.2.0b9) to install this project's version of Unity: **2020.2.0b9**.
1. Go to the [Unity 2020.2 Beta website](https://unity3d.com/unity/beta/2020.2.0b9) to install this project's version of Unity: **2020.2.0b9**.
1. Click the "Add" button in the top right of the "Projects" tab on Unity Hub, and navigate to and select the PickAndPlaceProject directory within this cloned repository (`/PATH/TO/Unity-Robotics-Hub/tutorials/pick_and_place/PickAndPlaceProject/`) to add the tutorial project to your Hub.
![](img/hub_addproject.png)
@ -40,14 +40,14 @@ This part includes downloading and installing the Unity Editor, setting up a bas
1. In the Unity Project window, navigate to `Assets/Prefabs`. Select the Table prefab, and click and drag it into the Hierarchy window. The table should appear in the Scene view. Then, select and drag the Target into the Hierarchy window, as well as the TargetPlacement. They should appear to sit on the table.
![](img/1_cube.png)
![](img/1_cube.png)
1. Select the `Main Camera` in the Hierarchy. Move the camera to a more convenient location for viewing the robot by assigning the `Main Camera`'s Position to `(0, 1.4, -0.7)`, and the Rotation to `(45, 0, 0)` in the Inspector, which can be found in the Transform component.
![](img/1_camera.png)
## Setting Up the Robot
## Setting Up the Robot
> Note: Presumably when you opened this project, the Package Manager automatically checked out and built the URDF-Importer package for you. You can double-check this now by looking for `Packages/URDF-Importer` in the Project window or by opening the Package Manager window. See the [Quick Setup](../quick_setup.md) steps for adding this package to your own project.
@ -57,9 +57,9 @@ This part includes downloading and installing the Unity Editor, setting up a bas
1. Find and select the URDF file in the Project window (`Assets/URDF/niryo_one/niryo_one.urdf`). From the menu, click `Assets -> Import Robot from URDF`, or in the Project window, right click on the selected file and click `Import Robot from URDF`.
> Note: The file extension may not appear in the Project window. The niryo_one.urdf file will appear in the root of the `Assets/URDF/niryo_one` directory.
1. Keep the default Y Axis type and VHACD mesh decomposer in the Import menu and click `Import URDF`.
> Note: Default mesh orientation is Y-up, which is supported by Unity, but some packages often use Z-up and X-up configuration.
> Note: VHACD algorithm produces higher quality convex hull for collision detection than the default algorithm.
@ -78,9 +78,9 @@ This part includes downloading and installing the Unity Editor, setting up a bas
1. Select the newly imported `niryo_one` object in the Scene Hierarchy, and from the Inspector window, find the Controller (Script) component. Set the Stiffness to `10000`, the Damping to `100` and `Force Limit` to `1000`. Set the Speed to `30` and the Acceleration to `10`.
> Note: You can find information on how these parameters are used in calculations by articulation bodies by referencing [this](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/master/tutorials/urdf_importer/urdf_appendix.md#guide-to-write-your-own-controller) technical guide for writing a custom controller. For our purposes, these settings will allow the robot to stay in position without the joints slipping.
![](img/1_controller.png)
1. In the Hierarchy window, click the arrow to the left of the name to expand the GameObject tree, down to `niryo_one/world/base_link`. Toggle on `Immovable` for the `base_link`.
![](img/1_base.png)
@ -88,7 +88,7 @@ This part includes downloading and installing the Unity Editor, setting up a bas
> Note: A controller is pre-built in the Unity URDF Importer to help showcase the movement of the Niryo. The Controller script is added to the imported URDF by default. This will add FKrobot and Joint Control components at runtime. The Controller script can be found in the project at `Assets/Packages/URDF Importer/Runtime/Controller/Controller.cs`.
1. Press the Play button at the top of the Unity Editor to enter Play Mode. If everything imported correctly, no errors should appear in the Console window. The robot arm should stay “mounted” to the table, and nothing should fall through the floor.
Using the Controller, joints can be selected using the arrow keys. Use the left/right arrow keys to navigate through the joints, where the selected index will be highlighted in red. Use the up/down arrow keys to control the selected joint movement. The Controller script on the niryo_one object will describe the actively `Selected Index` as well as the `Joint Name`.
![](img/1_end.gif)
@ -96,7 +96,7 @@ This part includes downloading and installing the Unity Editor, setting up a bas
---
## Troubleshooting
- If you are not seeing `Import Robot from URDF` in the `Assets` menu, check the console for compile errors. The project must compile correctly before the editor tools become available.
- If you are not seeing `Import Robot from URDF` in the `Assets` menu, check the console for compile errors. The project must compile correctly before the editor tools become available.
- If the robot appears loose/wiggly or is not moving with no console errors, ensure that the Stiffness and Damping values on the Controller script of the `niryo_one` object are set to `10000` and `100`, respectively.
---

Просмотреть файл

@ -25,7 +25,7 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
## The Unity Side
1. If you have not already completed the steps in [Part 0](0_ros_setup.md) to set up your ROS workspace and [Part 1](1_urdf.md) to set up the Unity project, do so now.
1. If you have not already completed the steps in [Part 0](0_ros_setup.md) to set up your ROS workspace and [Part 1](1_urdf.md) to set up the Unity project, do so now.
1. If the PickAndPlaceProject Unity project is not already open, select and open it from the Unity Hub.
@ -45,36 +45,36 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
![](img/2_menu.png)
In the ROS Message Browser window, click `Browse` next to the ROS message path. Navigate to and select the ROS directory of this cloned repository (`Unity-Robotics-Hub/tutorials/pick_and_place/ROS/`). This window will populate with all msg and srv files found in this directory.
In the ROS Message Browser window, click `Browse` next to the ROS message path. Navigate to and select the ROS directory of this cloned repository (`Unity-Robotics-Hub/tutorials/pick_and_place/ROS/`). This window will populate with all msg and srv files found in this directory.
![](img/2_browser.png)
> Note: If any of these ROS directories appear to be empty, you can run the command `git submodule update --init --recursive` to download the packages via Git submodules.
Under `ROS/src/moveit_msgs/msg`, scroll to `RobotTrajectory.msg`, and click its `Build msg` button. The button text will change to "Rebuild msg" when it has finished building.
![](img/2_robottraj.png)
- One new C# script should populate the `Assets/RosMessages/Moveit/msg` directory: MRobotTrajectory. This name is the same as the message you built, with an "M" prefix (for message).
1. Next, the custom message scripts for this tutorial will need to be generated.
1. Next, the custom message scripts for this tutorial will need to be generated.
Still in the ROS Message Browser window, expand `ROS/src/niryo_moveit/msg` to view the msg files listed. Next to msg, click `Build 2 msgs`.
![](img/2_msg.png)
- Two new C# scripts should populate the `Assets/RosMessages/NiryoMoveit/msg` directory: MNiryoMoveitJoints and MNiryoTrajectory. MNiryoMoveitJoints describes a value for each joint in the Niryo arm as well as poses for the target object and target goal. MNiryoTrajectory describes a list of RobotTrajectory values, which will hold the calculated trajectories for the pick-and-place task.
> MessageGeneration generates a C# class from a ROS msg file with protections for use of C# reserved keywords and conversion to C# datatypes. Learn more about [ROS Messages](https://wiki.ros.org/Messages).
1. Finally, now that the messages have been generated, we will create the service for moving the robot.
1. Finally, now that the messages have been generated, we will create the service for moving the robot.
Still in the ROS Message Browser window, expand `ROS/src/niryo_moveit/srv` to view the srv file listed. Next to srv, click `Build 1 srv`.
Still in the ROS Message Browser window, expand `ROS/src/niryo_moveit/srv` to view the srv file listed. Next to srv, click `Build 1 srv`.
![](img/2_srv.png)
- Two new C# scripts should populate the `Assets/RosMessages/NiryoMoveit/srv` directory: MMoverServiceRequest and MMoverServiceResponse. These files describe the expected input and output formats for the service requests and responses when calculating trajectories.
- Two new C# scripts should populate the `Assets/RosMessages/NiryoMoveit/srv` directory: MMoverServiceRequest and MMoverServiceResponse. These files describe the expected input and output formats for the service requests and responses when calculating trajectories.
> MessageGeneration generates two C# classes, a request and response, from a ROS srv file with protections for use of C# reserved keywords and conversion to C# datatypes. Learn more about [ROS Services](https://wiki.ros.org/Services).
You can now close the ROS Message Browser window.
@ -115,24 +115,24 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
}
```
> This function first takes in the current joint target values. Then, it grabs the poses of the `target` and the `targetPlacement` objects, adds them to the newly created message `sourceDestinationMessage`, and calls `Send()` to send this information to the ROS topic `topicName` (defined as `"SourceDestination_input"`).
> This function first takes in the current joint target values. Then, it grabs the poses of the `target` and the `targetPlacement` objects, adds them to the newly created message `sourceDestinationMessage`, and calls `Send()` to send this information to the ROS topic `topicName` (defined as `"SourceDestination_input"`).
> Note: Going from Unity world space to ROS world space requires a conversion. Unity's `(x,y,z)` is equivalent to the ROS `(z,-x,y)` coordinate. These conversions are provided via the [ROSGeometry component](https://github.com/Unity-Technologies/ROS-TCP-Connector/blob/main/ROSGeometry.md) in the ROS-TCP-Connector package.
1. Return to the Unity Editor. Now that the message contents have been defined and the publisher script added, it needs to be added to the Unity world to run its functionality.
1. Return to the Unity Editor. Now that the message contents have been defined and the publisher script added, it needs to be added to the Unity world to run its functionality.
Right click in the Hierarchy window and select "Create Empty" to add a new empty GameObject. Name it `Publisher`. Add the newly created SourceDestinationPublisher component to the Publisher GameObject by selecting the Publisher object. Click "Add Component" in the Inspector, and begin typing "SourceDestinationPublisher." Select the component when it appears.
Right click in the Hierarchy window and select "Create Empty" to add a new empty GameObject. Name it `Publisher`. Add the newly created SourceDestinationPublisher component to the Publisher GameObject by selecting the Publisher object. Click "Add Component" in the Inspector, and begin typing "SourceDestinationPublisher." Select the component when it appears.
> Note: Alternatively, you can drag the script from the Project window onto the Publisher object in the Hierarchy window.
![](img/2_sourcedest.gif)
1. Note that this component shows empty member variables in the Inspector window, which need to be assigned.
1. Note that this component shows empty member variables in the Inspector window, which need to be assigned.
Select the Target object in the Hierarchy and assign it to the `Target` field in the Publisher. Similarly, assign the TargetPlacement object to the `TargetPlacement` field. Assign the niryo_one robot to the `Niryo One` field.
![](img/2_target.gif)
1. Next, the ROS TCP connection needs to be created. Select `Robotics -> ROS Settings` from the top menu bar.
1. Next, the ROS TCP connection needs to be created. Select `Robotics -> ROS Settings` from the top menu bar.
In the ROS Settings window, the `ROS IP Address` should be the IP address of your ROS machine (*not* the one running Unity).
@ -140,19 +140,19 @@ To enable communication between Unity and ROS, a TCP endpoint running as a ROS n
- If you are **not** running ROS services in a Docker container, replace the `ROS IP Address` value with the IP address of your ROS machine. Ensure that the `Host Port` is set to `10000`.
- If you **are** running ROS services in a Docker container, fill `ROS IP Address` and `Override Unity IP Address` with the loopback IP address `127.0.0.1`. Otherwise, leave the `Override Unity IP Address` field empty.
- If you **are** running ROS services in a Docker container, fill `ROS IP Address` with the loopback IP address `127.0.0.1` and the `Override Unity IP Address` as your local machine's IP address. Otherwise, leave the `Override Unity IP Address` field empty.
![](img/2_settings.png)
Opening the ROS Settings has created a ROSConnectionPrefab in `Assets/Resources` with the user-input settings. When the static `ROSConnection.instance` is referenced in a script, if a `ROSConnection` instance is not already present, the prefab will be instantiated in the Unity scene, and the connection will begin.
> Note: While using the ROS Settings menu is the suggested workflow as of this version, you may still manually create a GameObject with an attached ROSConnection component.
1. Next, we will add a UI element that will allow user input to trigger the `Publish()` function. In the Hierarchy window, right click to add a new UI > Button. Note that this will create a new Canvas parent as well.
1. Next, we will add a UI element that will allow user input to trigger the `Publish()` function. 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: In case the Button does not start in the bottom left, it can be moved by setting the `Pos X` and `Pos Y` values in its Rect Transform component. For example, setting its Position to `(-200, -200, 0)` would set its position to the bottom right area of the screen.
> Note: In case the Button does not start in the bottom left, it can be moved by setting the `Pos X` and `Pos Y` values in its Rect Transform component. For example, setting its Position to `(-200, -200, 0)` would set its position to the bottom right area of the screen.
1. Select the newly made Button object, and scroll to see the Button component in the Inspector. Click the `+` button under the empty `OnClick()` header to add a new event. Select the `Publisher` object in the Hierarchy window and drag it into the new OnClick() event, where it says `None (Object)`. Click the dropdown where it says `No Function`. Select SourceDestinationPublisher > `Publish()`.
![](img/2_onclick.png)
@ -175,7 +175,7 @@ Most of the ROS setup has been provided via the `niryo_moveit` package. This sec
roslaunch niryo_moveit part_2.launch
```
> Note: Running `roslaunch` automatically starts [ROS Core](http://wiki.ros.org/roscore) if it is not already running.
> Note: Running `roslaunch` automatically starts [ROS Core](http://wiki.ros.org/roscore) if it is not already running.
> Note: This launch file has been copied below for reference. The server_endpoint and trajectory_subscriber nodes are launched from this file, and the ROS params (set up in [Part 0](0_ros_setup.md)) are loaded from this command. The launch files for this project are available in the package's `launch` directory, i.e. `src/niryo_moveit/launch/`.
@ -187,12 +187,12 @@ Most of the ROS setup has been provided via the `niryo_moveit` package. This sec
</launch>
```
This launch will print various messages to the console, including the set parameters and the nodes launched.
This launch will print various messages to the console, including the set parameters and the nodes launched.
Ensure that the `process[server_endpoint]` and `process[trajectory_subscriber]` were successfully started, and that a message similar to `[INFO] [1603488341.950794]: Starting server on 192.168.50.149:10000` is printed.
1. Return to Unity, and press Play. Click the UI Button in the Game view to call SourceDestinationPublisher's `Publish()` function, publishing the associated data to the ROS topic. View the terminal in which the `roslaunch` command is running. It should now print `I heard:` with the data.
ROS and Unity have now successfully connected!
![](img/2_echo.png)
@ -203,8 +203,8 @@ ROS and Unity have now successfully connected!
- If the error `[rosrun] Found the following, but they're either not files, or not executable: server_endpoint.py` appears, the Python script may need to be marked as executable via `chmod +x Unity-Robotics-Hub/tutorials/pick_and_place/ROS/src/niryo_moveit/scripts/server_endpoint.py`.
- `...failed because unknown error handler name 'rosmsg'` This is due to a bug in an outdated package version. Try running `sudo apt-get update && sudo apt-get upgrade` to upgrade.
- If Unity fails to find a network connection, ensure that the ROS IP address is entered correctly as the ROS IP Address in the RosConnect in Unity, and that the `src/niryo_moveit/config/params.yaml` values are set correctly.
- If Unity fails to find a network connection, ensure that the ROS IP address is entered correctly as the ROS IP Address in the RosConnect in Unity, and that the `src/niryo_moveit/config/params.yaml` values are set correctly.
- If the ROS TCP handshake fails (e.g. `ROS-Unity server listening...` printed on the Unity side but no `ROS-Unity Handshake received` on the ROS side), the ROS IP may not have been set correctly in the params.yaml file. Try running `echo "ROS_IP: $(hostname -I)" > src/niryo_moveit/config/params.yaml` in a terminal from your ROS workspace.
@ -218,7 +218,7 @@ ROS and Unity have now successfully connected!
- [TCP Endpoint](https://github.com/Unity-Technologies/ROS-TCP-Endpoint) package
- [Niryo One ROS stack](https://github.com/NiryoRobotics/niryo_one_ros)
- [MoveIt Msgs](https://github.com/ros-planning/moveit_msgs)
---
#### Proceed to [Part 3](3_pick_and_place.md).
#### Proceed to [Part 3](3_pick_and_place.md).

Просмотреть файл

@ -20,7 +20,7 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
## The Unity Side
1. If you have not already completed the steps in [Part 1](1_urdf.md) to set up the Unity project and [Part 2](2_ros_tcp.md) to integrate ROS with Unity, do so now.
1. If you have not already completed the steps in [Part 1](1_urdf.md) to set up the Unity project and [Part 2](2_ros_tcp.md) to integrate ROS with Unity, do so now.
1. If the PickAndPlaceProject Unity project is not already open, select and open it from the Unity Hub.
@ -33,7 +33,7 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
{
MMoverServiceRequest request = new MMoverServiceRequest();
request.joints_input = CurrentJointConfig();
// Pick Pose
request.pick_pose = new MPose
{
@ -81,7 +81,7 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
{
var jointPositions = response.trajectories[poseIndex].joint_trajectory.points[jointConfigIndex].positions;
float[] result = jointPositions.Select(r=> (float)r * Mathf.Rad2Deg).ToArray();
for (int joint = 0; joint < jointArticulationBodies.Length; joint++)
{
var joint1XDrive = jointArticulationBodies[joint].xDrive;
@ -93,7 +93,7 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
if (poseIndex == (int)Poses.Grasp)
CloseGripper();
yield return new WaitForSeconds(poseAssignmentWait);
}
// Open Gripper at end of sequence
@ -106,9 +106,9 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
1. Return to Unity. Select the Publisher GameObject and add the `TrajectoryPlanner` script as a component.
1. Note that the TrajectoryPlanner component shows its member variables in the Inspector window, which need to be assigned.
1. Note that the TrajectoryPlanner component shows its member variables in the Inspector window, which need to be assigned.
Once again, drag and drop the `Target` and `TargetPlacement` objects onto the Target and Target Placement Inspector fields, respectively. Assign the `niryo_one` robot to the Niryo One field.
Once again, drag and drop the `Target` and `TargetPlacement` objects onto the Target and Target Placement Inspector fields, respectively. Assign the `niryo_one` robot to the Niryo One field.
![](img/3_target.gif)
@ -127,7 +127,7 @@ Steps covered in this tutorial includes invoking a motion planning service in RO
> Note the file `src/niryo_moveit/scripts/mover.py`. This script holds the ROS-side logic for the MoverService. When the service is called, the function `plan_pick_and_place()` runs. This calls `plan_trajectory` on the current joint configurations (sent from Unity) to a destination pose (dependent on the phase of the pick-and-place task).
```python
def plan_trajectory(move_group, destination_pose, start_joint_angles):
def plan_trajectory(move_group, destination_pose, start_joint_angles):
current_joint_state = JointState()
current_joint_state.name = joint_names
current_joint_state.position = start_joint_angles
@ -149,11 +149,11 @@ def plan_trajectory(move_group, destination_pose, start_joint_angles):
## ROS–Unity Communication
1. If you have not already completed the steps in [Part 0](0_ros_setup.md) to set up your ROS workspace, do so now.
1. If you have not already completed the steps in [Part 0](0_ros_setup.md) to set up your ROS workspace, do so now.
1. Open a new terminal window in the ROS workspace. Once again, source the workspace.
1. Open a new terminal window in the ROS workspace. Once again, source the workspace.
Then, run the following `roslaunch` in order to start roscore, set the ROS parameters, start the server endpoint, start the Mover Service node, and launch MoveIt.
Then, run the following `roslaunch` in order to start roscore, set the ROS parameters, start the server endpoint, start the Mover Service node, and launch MoveIt.
```bash
roslaunch niryo_moveit part_3.launch
@ -165,9 +165,9 @@ def plan_trajectory(move_group, destination_pose, start_joint_angles):
> Note: This may print out various error messages such as `Failed to find 3D sensor plugin`. These messages are safe to ignore as long as the final message to the console is `You can start planning now!`.
1. Return to the Unity Editor and press Play. Press the UI Button to send the joint configurations to ROS, and watch the robot arm pick up and place the cube!
- The target object and placement positions can be moved around during runtime for different trajectory calculations.
1. Return to the Unity Editor and press Play. Press the UI Button to send the joint configurations to ROS, and watch the robot arm pick up and place the cube!
- The target object and placement positions can be moved around during runtime for different trajectory calculations.
![](img/0_pick_place.gif)
---
@ -184,12 +184,12 @@ def plan_trajectory(move_group, destination_pose, start_joint_angles):
### Errors and Warnings
- If the motion planning script throws a `RuntimeError: Unable to connect to move_group action server 'move_group' within allotted time (5s)`, ensure the `roslaunch niryo_moveit part_3.launch` process launched correctly and has printed `You can start planning now!`.
- `...failed because unknown error handler name 'rosmsg'` This is due to a bug in an outdated package version. Try running `sudo apt-get update && sudo apt-get upgrade` to upgrade.
### Hangs, Timeouts, and Freezes
- If Unity fails to find a network connection, ensure that the ROS IP address is entered correctly as the `ROS IP Address` in the RosConnect in Unity, and that the `src/niryo_moveit/config/params.yaml` values are set correctly.
- If Unity fails to find a network connection, ensure that the ROS IP address is entered correctly as the `ROS IP Address` in the RosConnect in Unity, and that the `src/niryo_moveit/config/params.yaml` values are set correctly.
### Miscellaneous Issues

Просмотреть файл

@ -16,7 +16,7 @@ This part is going to be a little different than the previous tutorials in that
- [Add niryo_moveit Package](#add-niryo_moveit-package)
- [Execution](#execution)
# Niryo One Information
The best source of information for the Niryo One is the [User Manual](https://niryo.com/docs/niryo-one/user-manual/complete-user-manual/). It contains a lot of general information about the Niryo One, such as how to connect it to a network, how to log in to it, and how to use the Niryo One Studio desktop application.
@ -115,7 +115,7 @@ command_list:
```
From here we see that the `RobotMoveGoal.RobotMoveCommand.ToolCommand.cmd_type` variable will need to be `2` to close the gripper and `1` to open it.
From here we see that the `RobotMoveGoal.RobotMoveCommand.ToolCommand.cmd_type` variable will need to be `2` to close the gripper and `1` to open it.
# Differences From Part 3
@ -173,20 +173,20 @@ We will also make use of the `sim_and_real_pnp.py` script. It is very similar to
```python
def send_trajectory_goal(client, trajectory):
# Build the goal
goal = RobotMoveGoal()
goal.cmd.Trajectory = trajectory
goal.cmd.cmd_type = TRAJECTORY_COMMAND_ID
client.send_goal(goal)
client.wait_for_result()
return
```
- To send a gripper command:
```python
def send_tool_goal(client, gripper_command):
tool_command = ToolCommand()
@ -194,35 +194,35 @@ We will also make use of the `sim_and_real_pnp.py` script. It is very similar to
tool_command.cmd_type = gripper_command
tool_command.gripper_open_speed = GRIPPER_SPEED
tool_command.gripper_close_speed = GRIPPER_SPEED
goal = RobotMoveGoal()
goal.cmd.tool_cmd = tool_command
goal.cmd.cmd_type = TOOL_COMMAND_ID
client.send_goal(goal)
client.wait_for_result()
return
```
- The `pick_and_place` function has been updated to call the two previous functions instead of appending the trajectory or gripper command to a list.
- Example from `mover.py`
```python
previous_ending_joint_angles = grasp_pose.joint_trajectory.points[-1].positions
response.trajectories.append(grasp_pose)
```
- Updated code in `sim_real_pnp.py`
```python
previous_ending_joint_angles = grasp_pose.trajectory.joint_trajectory.points[-1].positions
send_trajectory_goal(client, grasp_pose)
```
# The Unity Side
Using the same scene from [Part 3](3_pick_and_place.md), we are going to use a new script, `RealSimPickAndPlace.cs`, that mirrors a lot of the functionality of the `TrajectoryPlanner.cs` script.
Using the same scene from [Part 3](3_pick_and_place.md), we are going to use a new script, `RealSimPickAndPlace.cs`, that mirrors a lot of the functionality of the `TrajectoryPlanner.cs` script.
## Key Differences
@ -272,7 +272,7 @@ void Start()
{
var jointPositions = point.positions;
float[] result = jointPositions.Select(r=> (float)r * Mathf.Rad2Deg).ToArray();
// Set the joint values for every joint
for (int joint = 0; joint < jointArticulationBodies.Length; joint++)
{
@ -303,9 +303,9 @@ void Start()
1. Select the Publisher GameObject and add the `RealSimPickAndPlace` script as a component.
1. Note that the RealSimPickAndPlace component shows its member variables in the Inspector window, which need to be assigned.
1. Note that the RealSimPickAndPlace component shows its member variables in the Inspector window, which need to be assigned.
Once again, drag and drop the `Target` and `TargetPlacement` objects onto the Target and Target Placement Inspector fields, respectively. Assign the `niryo_one` robot to the Niryo One field.
Once again, drag and drop the `Target` and `TargetPlacement` objects onto the Target and Target Placement Inspector fields, respectively. Assign the `niryo_one` robot to the Niryo One field.
![](img/4_script.png)
@ -325,7 +325,7 @@ void Start()
- The two files that will need to be updated are `niryo_one.urdf.xacro` and `without_mesh_niryo_one.urdf.xacro` located in the `/home/niryo/catkin_ws/src/niryo_one_description/urdf/v2` directory.
- Look for the joint named `joint_world` and update the `origin`'s `xyz` to `0 0 0.63` to reflect that the simulated Niryo is placed at `0.63` on the Z axis.
```xml
<joint name="joint_world" type="fixed">
<parent link="world" />

Просмотреть файл

@ -8,8 +8,8 @@ using System.Reflection;
using System.Text;
using RosSharp;
using RosSharp.Control;
using RosSharp.Urdf;
using RosSharp.Urdf.Editor;
using Unity.EditorCoroutines.Editor;
using UnityEditor;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
@ -167,12 +167,8 @@ public class Demo : MonoBehaviour
// Create RosConnect
GameObject rosConnect = new GameObject(rosConnectName);
rosConnection = rosConnect.AddComponent<ROSConnection>();
rosConnection.rosIPAddress = hostIP;
rosConnection.rosPort = hostPort;
rosConnection.overrideUnityIP = overrideUnityIP;
rosConnection.unityPort = unityPort;
rosConnection.awaitDataMaxRetries = awaitDataMaxRetries;
rosConnection.awaitDataSleepSeconds = awaitDataSleepSeconds;
rosConnection.RosIPAddress = hostIP;
rosConnection.RosPort = hostPort;
}
private void ImportRobot()
@ -186,7 +182,7 @@ public class Demo : MonoBehaviour
string urdfFilepath = Path.Combine(Application.dataPath, urdfRelativeFilepath);
// Create is a coroutine that would usually run only in EditMode, so we need to force its execution here
var robotImporter = UrdfRobotExtensions.Create(urdfFilepath, urdfImportSettings, false);
while (robotImporter.MoveNext()) {}
while (robotImporter.MoveNext()) { }
// Adjust robot parameters
Controller controller = GameObject.Find(niryoOneName).GetComponent<Controller>();
controller.stiffness = controllerStiffness;
@ -211,9 +207,9 @@ public class Demo : MonoBehaviour
parameters.GenerateExecutable = false;
string[] texts = new string[filepaths.Length];
for (int i = 0; i < filepaths.Length; i ++)
for (int i = 0; i < filepaths.Length; i++)
{
texts[i] = File.ReadAllText(filepaths[i]);
texts[i] = File.ReadAllText(filepaths[i]);
}
CompilerResults results = provider.CompileAssemblyFromSource(parameters, texts);
checkCompileErrors(results);

Просмотреть файл

@ -18,7 +18,7 @@ public class PickAndPlaceMessageGenerationTests
{
yield return new TestCaseData(Path.Combine(k_ROSDirectory, "moveit_msgs", "msg", "RobotTrajectory.msg"));
}
// Define directories of message files to be generated here
static IEnumerable<TestCaseData> MessageDirectories()
{
@ -46,7 +46,7 @@ public class PickAndPlaceMessageGenerationTests
MessageAutoGen.GenerateDirectoryMessages(directoryToBuild, m_MessageGenOutputPath);
AssetDatabase.Refresh();
}
[Test]
[TestCaseSource(nameof(ServiceDirectories))]
public void TestServiceBuildDirectory_ThrowsNoExceptions(string directoryToBuild)

Просмотреть файл

@ -2,7 +2,7 @@
This package contains URDF file and meshes (collada + stl) for Niryo One.
**Note** : 3D visualization is not available on the Niryo One Raspberry Pi image. To use the following commands, you must have installed ROS on your computer and downloaded the Niryo One ROS packages.
**Note** : 3D visualization is not available on the Niryo One Raspberry Pi image. To use the following commands, you must have installed ROS on your computer and downloaded the Niryo One ROS packages.
* To display Niryo One on Rviz :

Просмотреть файл

@ -4,9 +4,8 @@
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.3",
"com.unity.ide.vscode": "1.2.2",
"com.unity.robotics.ros-tcp-connector":
"https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector#v0.3.0",
"com.unity.robotics.urdf-importer": "https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#v0.3.0",
"com.unity.robotics.ros-tcp-connector": "https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector#v0.4.0",
"com.unity.robotics.urdf-importer": "https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#v0.4.0",
"com.unity.test-framework": "1.1.18",
"com.unity.textmeshpro": "3.0.1",
"com.unity.timeline": "1.4.3",

Просмотреть файл

@ -2,7 +2,7 @@
# Pick-and-Place Tutorial
Unity's tools for robotic simulation enable users to integrate Unity with ROS-based workflows. [ROS](http://wiki.ros.org/ROS/Introduction) (Robot Operating System) provides services such as message-passing, package management, low-level device control, and hardware abstraction. Unity's robotics tools are able to support **importing URDF files** and **sending and receiving messages between ROS and Unity**. This tutorial will go through the steps necessary to integrate ROS with Unity, from installing the Unity Editor to creating a scene with an imported URDF to completing a pick-and-place task with known poses using [MoveIt](https://moveit.ros.org/) trajectory planning.
Unity's tools for robotic simulation enable users to integrate Unity with ROS-based workflows. [ROS](http://wiki.ros.org/ROS/Introduction) (Robot Operating System) provides services such as message-passing, package management, low-level device control, and hardware abstraction. Unity's robotics tools are able to support **importing URDF files** and **sending and receiving messages between ROS and Unity**. This tutorial will go through the steps necessary to integrate ROS with Unity, from installing the Unity Editor to creating a scene with an imported URDF to completing a pick-and-place task with known poses using [MoveIt](https://moveit.ros.org/) trajectory planning.
This tutorial is designed such that you do not need prior experience with Unity or C# in order to follow the scene setup steps, and you do not need prior robotics experience to get started with ROS integration. The tutorial is divided into high-level phases, from basic Unity and ROS initial setup through executing a pick-and-place task.
@ -31,11 +31,11 @@ This repository provides project files for the pick-and-place tutorial, includin
This part provides two options for setting up your ROS workspace: using Docker, or manually setting up a catkin workspace.
## [Part 1: Create Unity scene with imported URDF](1_urdf.md)
## [Part 1: Create Unity scene with imported URDF](1_urdf.md)
<img src="img/1_end.gif" width="400"/>
This part includes downloading and installing the Unity Editor, setting up a basic Unity scene, and importing a robot--the [Niryo One](https://niryo.com/niryo-one/)--using the URDF Importer.
This part includes downloading and installing the Unity Editor, setting up a basic Unity scene, and importing a robot--the [Niryo One](https://niryo.com/niryo-one/)--using the URDF Importer.
## [Part 2: ROS–Unity Integration](2_ros_tcp.md)
@ -44,7 +44,7 @@ This part includes downloading and installing the Unity Editor, setting up a bas
This part covers creating a TCP connection between Unity and ROS, generating C# scripts from a ROS msg and srv files, and publishing to a ROS topic.
## [Part 3: Pick-and-Place In Unity](3_pick_and_place.md)
<img src="img/0_pick_place.gif" width="400"/>
This part includes the preparation and setup necessary to run a pick-and-place task with known poses using MoveIt. Steps covered include creating and invoking a motion planning service in ROS, moving a Unity Articulation Body based on a calculated trajectory, and controlling a gripping tool to successfully grasp and drop an object.

Просмотреть файл

@ -1,8 +1,8 @@
### Prerequisites
### Prerequisites
Ensure physics solver is set to `Temporal Gauss Seidel` in [Physics Manager](https://docs.unity3d.com/Manual/class-PhysicsManager.html)
### ROS & Simulated Arm Only
### ROS & Simulated Arm Only
--
**Terminal 1**
@ -46,7 +46,7 @@ niryo_one_msgs/ShiftPose shift
niryo_one_msgs/TrajectoryPlan Trajectory
geometry_msgs/Pose pose_quat
string saved_position_name
int32 saved_trajectory_id
int32 saved_trajectory_id
```
**TrajectoryPlan.msg**

Просмотреть файл

Просмотреть файл

@ -2,7 +2,7 @@
This package contains URDF file and meshes (collada + stl) for Niryo One.
**Note** : 3D visualization is not available on the Niryo One Raspberry Pi image. To use the following commands, you must have installed ROS on your computer and downloaded the Niryo One ROS packages.
**Note** : 3D visualization is not available on the Niryo One Raspberry Pi image. To use the following commands, you must have installed ROS on your computer and downloaded the Niryo One ROS packages.
* To display Niryo One on Rviz :

@ -1 +1 @@
Subproject commit a5e0fd1ce1a711f557fe67e73657c74f92482fbe
Subproject commit 18612dcb5f8ce662e691926930aa6469714d82aa

Просмотреть файл

@ -8,20 +8,20 @@ public class SourceDestinationPublisher : MonoBehaviour
{
// ROS Connector
private ROSConnection ros;
// Variables required for ROS communication
public string topicName = "SourceDestination_input";
public GameObject niryoOne;
public GameObject target;
public GameObject targetPlacement;
private int numRobotJoints = 6;
private readonly Quaternion pickOrientation = Quaternion.Euler(90, 90, 0);
// Articulation Bodies
private ArticulationBody[] jointArticulationBodies;
/// <summary>
///
/// </summary>
@ -36,16 +36,16 @@ public class SourceDestinationPublisher : MonoBehaviour
string arm_link = shoulder_link + "/arm_link";
jointArticulationBodies[1] = niryoOne.transform.Find(arm_link).GetComponent<ArticulationBody>();
string elbow_link = arm_link + "/elbow_link";
jointArticulationBodies[2] = niryoOne.transform.Find(elbow_link).GetComponent<ArticulationBody>();
string forearm_link = elbow_link + "/forearm_link";
jointArticulationBodies[3] = niryoOne.transform.Find(forearm_link).GetComponent<ArticulationBody>();
string wrist_link = forearm_link + "/wrist_link";
jointArticulationBodies[4] = niryoOne.transform.Find(wrist_link).GetComponent<ArticulationBody>();
string hand_link = wrist_link + "/hand_link";
jointArticulationBodies[5] = niryoOne.transform.Find(hand_link).GetComponent<ArticulationBody>();
}

Просмотреть файл

@ -16,7 +16,7 @@ public class TrajectoryPlanner : MonoBehaviour
private readonly float jointAssignmentWait = 0.1f;
private readonly float poseAssignmentWait = 0.5f;
private readonly Vector3 pickPoseOffset = Vector3.up * 0.1f;
// Assures that the gripper is always positioned above the target cube before grasping.
private readonly Quaternion pickOrientation = Quaternion.Euler(90, 90, 0);
@ -43,7 +43,7 @@ public class TrajectoryPlanner : MonoBehaviour
PickUp,
Place
};
/// <summary>
/// Close the gripper
/// </summary>
@ -81,7 +81,7 @@ public class TrajectoryPlanner : MonoBehaviour
MNiryoMoveitJoints CurrentJointConfig()
{
MNiryoMoveitJoints joints = new MNiryoMoveitJoints();
joints.joint_00 = jointArticulationBodies[0].xDrive.target;
joints.joint_01 = jointArticulationBodies[1].xDrive.target;
joints.joint_02 = jointArticulationBodies[2].xDrive.target;
@ -103,7 +103,7 @@ public class TrajectoryPlanner : MonoBehaviour
{
MMoverServiceRequest request = new MMoverServiceRequest();
request.joints_input = CurrentJointConfig();
// Pick Pose
request.pick_pose = new MPose
{
@ -154,18 +154,18 @@ public class TrajectoryPlanner : MonoBehaviour
if (response.trajectories != null)
{
// For every trajectory plan returned
for (int poseIndex = 0 ; poseIndex < response.trajectories.Length; poseIndex++)
for (int poseIndex = 0; poseIndex < response.trajectories.Length; poseIndex++)
{
// For every robot pose in trajectory plan
for (int jointConfigIndex = 0 ; jointConfigIndex < response.trajectories[poseIndex].joint_trajectory.points.Length; jointConfigIndex++)
for (int jointConfigIndex = 0; jointConfigIndex < response.trajectories[poseIndex].joint_trajectory.points.Length; jointConfigIndex++)
{
var jointPositions = response.trajectories[poseIndex].joint_trajectory.points[jointConfigIndex].positions;
float[] result = jointPositions.Select(r=> (float)r * Mathf.Rad2Deg).ToArray();
float[] result = jointPositions.Select(r => (float)r * Mathf.Rad2Deg).ToArray();
// Set the joint values for every joint
for (int joint = 0; joint < jointArticulationBodies.Length; joint++)
{
var joint1XDrive = jointArticulationBodies[joint].xDrive;
var joint1XDrive = jointArticulationBodies[joint].xDrive;
joint1XDrive.target = result[joint];
jointArticulationBodies[joint].xDrive = joint1XDrive;
}
@ -176,7 +176,7 @@ public class TrajectoryPlanner : MonoBehaviour
// Close the gripper if completed executing the trajectory for the Grasp pose
if (poseIndex == (int)Poses.Grasp)
CloseGripper();
// Wait for the robot to achieve the final pose from joint assignment
yield return new WaitForSeconds(poseAssignmentWait);
}
@ -200,16 +200,16 @@ public class TrajectoryPlanner : MonoBehaviour
string arm_link = shoulder_link + "/arm_link";
jointArticulationBodies[1] = niryoOne.transform.Find(arm_link).GetComponent<ArticulationBody>();
string elbow_link = arm_link + "/elbow_link";
jointArticulationBodies[2] = niryoOne.transform.Find(elbow_link).GetComponent<ArticulationBody>();
string forearm_link = elbow_link + "/forearm_link";
jointArticulationBodies[3] = niryoOne.transform.Find(forearm_link).GetComponent<ArticulationBody>();
string wrist_link = forearm_link + "/wrist_link";
jointArticulationBodies[4] = niryoOne.transform.Find(wrist_link).GetComponent<ArticulationBody>();
string hand_link = wrist_link + "/hand_link";
jointArticulationBodies[5] = niryoOne.transform.Find(hand_link).GetComponent<ArticulationBody>();
@ -225,4 +225,4 @@ public class TrajectoryPlanner : MonoBehaviour
rightGripper = rightGripperGameObject.GetComponent<ArticulationBody>();
leftGripper = leftGripperGameObject.GetComponent<ArticulationBody>();
}
}
}

Просмотреть файл

@ -14,14 +14,14 @@ public class RealSimPickAndPlace : MonoBehaviour
private const int CLOSE_GRIPPER = 2;
private const int TOOL_COMMAND_EXECUTION = 6;
private const int TRAJECTORY_COMMAND_EXECUTION = 7;
private ROSConnection ros;
private const int NUM_ROBOT_JOINTS = 6;
// Hardcoded variables
private const float JOINT_ASSIGNMENT_WAIT = 0.038f;
private readonly Vector3 PICK_POSE_OFFSET = Vector3.up * 0.15f;
// Assures that the gripper is always positioned above the target cube before grasping.
private readonly Quaternion pickOrientation = Quaternion.Euler(90, 90, 0);
@ -104,10 +104,10 @@ public class RealSimPickAndPlace : MonoBehaviour
orientation = pickOrientation.To<FLU>()
}
};
ros.Send(rosJointPublishTopicName, request);
}
/// <summary>
/// Find all robot joints in Awake() and add them to the jointArticulationBodies array.
/// Find left and right finger joints and assign them to their respective articulation body objects.
@ -120,16 +120,16 @@ public class RealSimPickAndPlace : MonoBehaviour
string armLink = shoulder_link + "/arm_link";
jointArticulationBodies[1] = niryoOne.transform.Find(armLink).GetComponent<ArticulationBody>();
string elbowLink = armLink + "/elbow_link";
jointArticulationBodies[2] = niryoOne.transform.Find(elbowLink).GetComponent<ArticulationBody>();
string forearmLink = elbowLink + "/forearm_link";
jointArticulationBodies[3] = niryoOne.transform.Find(forearmLink).GetComponent<ArticulationBody>();
string wristLink = forearmLink + "/wrist_link";
jointArticulationBodies[4] = niryoOne.transform.Find(wristLink).GetComponent<ArticulationBody>();
string handLink = wristLink + "/hand_link";
jointArticulationBodies[5] = niryoOne.transform.Find(handLink).GetComponent<ArticulationBody>();
@ -143,7 +143,7 @@ public class RealSimPickAndPlace : MonoBehaviour
rightGripperJoint = rightGripperGameObject.GetComponent<ArticulationBody>();
leftGripperJoint = leftGripperGameObject.GetComponent<ArticulationBody>();
}
void Start()
{
ros.Subscribe<MRobotMoveActionGoal>(rosRobotCommandsTopicName, ExecuteRobotCommands);
@ -190,12 +190,12 @@ public class RealSimPickAndPlace : MonoBehaviour
foreach (var point in trajectories.joint_trajectory.points)
{
var jointPositions = point.positions;
float[] result = jointPositions.Select(r=> (float)r * Mathf.Rad2Deg).ToArray();
float[] result = jointPositions.Select(r => (float)r * Mathf.Rad2Deg).ToArray();
// Set the joint values for every joint
for (int joint = 0; joint < jointArticulationBodies.Length; joint++)
{
var joint1XDrive = jointArticulationBodies[joint].xDrive;
var joint1XDrive = jointArticulationBodies[joint].xDrive;
joint1XDrive.target = result[joint];
jointArticulationBodies[joint].xDrive = joint1XDrive;
}

Просмотреть файл

@ -22,4 +22,8 @@ RUN dos2unix /tutorial && dos2unix /setup.sh && chmod +x /setup.sh && /setup.sh
WORKDIR $ROS_WORKSPACE
ENTRYPOINT ["/tutorial"]
# making sure the file modes are executable
RUN chmod +x src/niryo_moveit/scripts/*.py
ENTRYPOINT ["/tutorial"]

Просмотреть файл

@ -27,7 +27,7 @@ Starts the Niryo One driver, controller manager, and robot state publisher nodes
- Starts ROS node `controller_manager` with arguments `joint_state_controller niryo_one_follow_joint_trajectory_controller
--shutdown-timeout 1`
- Starts ROS node `robot_state_publisher` package.
- Starts ROS node `robot_state_publisher` package.
- Ex. `rosrun robot_state_publisher robot_state_publisher`
**move_group.launch**
@ -41,7 +41,7 @@ Starts the Move Group node which is the entry point into using MoveIt. Also call
- `moveit_controller_manager` set to `niryo_one`
- Call `planning_context.launch`
- Start ROS node `moveit_ros_move_group`
- Start ROS node `moveit_ros_move_group`
- Set rosparam `allow_trajectory_execution` to true
- Set rosparam `max_safe_path_cost` to 1
- Set rosparam `jiggle_fraction` to 0.05
@ -63,7 +63,7 @@ Loads the Niryo One URDF with accompanying parameters for command validation, se
- Sets rosparams `service_timeout` to 2, `action_connection_timeout` to 2, `action_execute_timeout` to 15, and `action_preempt_timeout` to 3 for `niryo_one/python_api` namespace
- Sets rosparams `rate_tf_listener` to 5.0 and `rate_publish_state` to 5.0 for `niryo_one/robot_state` namespace
- Loads `niryo_one_urdf.xacro` as rosparams `robot_description` and `robot_description_tf2`
**niryo_one_moveit_controller_manager.launch.xml**
@ -75,9 +75,9 @@ Set controllers available to MoveIt
- Reads `controllers.yaml` into rosparam
**ompl_planning_pipeline.launch.xml**
Sets ROS params and topics for OMPL pipeline communication
- Set rosparam `planning_plugin` with value of `ompl_interface/OMPLPlanner`
- Set rosparam `planning_adapters` with value of:
@ -138,7 +138,7 @@ Sets ROS params required for trajectory execution and then calls controller mana
**niryo_one.srdf**
- Defines joint groups, group states, and disables collisions between joints and links that are impossible to collide.
- [MoveIt SRDF Documentation](https://ros-planning.github.io/moveit_tutorials/doc/urdf_srdf/urdf_srdf_tutorial.html#srdf)
- [MoveIt SRDF Documentation](https://ros-planning.github.io/moveit_tutorials/doc/urdf_srdf/urdf_srdf_tutorial.html#srdf)
**niryo_one_controllers.yaml**

Просмотреть файл

@ -18,7 +18,7 @@ This part uses scripts to automatically set up and run the Niryo One pick-and-pl
1. Install [Unity Hub](https://unity3d.com/get-unity/download).
1. Go to the [Unity 2020.2 Beta website](https://unity3d.com/unity/beta/2020.2.0b9) to install this project's version of Unity: **2020.2.0b9**.
1. Go to the [Unity 2020.2 Beta website](https://unity3d.com/unity/beta/2020.2.0b9) to install this project's version of Unity: **2020.2.0b9**.
## Start ROS
@ -42,7 +42,7 @@ This part uses scripts to automatically set up and run the Niryo One pick-and-pl
1. Look for the `DemoScene` in the Project browser in the Assets/Scenes directory, and double-click to open it.
1. Click the `Play` button to watch the full demo.
> Note: the planning process will take about ten seconds before the Niryo One starts to move
> Note: the planning process will take about ten seconds before the Niryo One starts to move
> Note: several game objects will be created in the Hierarchy window at runtime
>
@ -51,11 +51,11 @@ This part uses scripts to automatically set up and run the Niryo One pick-and-pl
> * **TargetPlacement**: the area that the target cube will be placed; instantiation of the TargetPlacement prefab
> * **niryo_one**: the Niryo One robot imported from URDF
> * **ROSConnect**: the object that operates ROS communication
> * **Publisher**: the object that publish joint configurations to the ROS network for planning
> * **Publisher**: the object that publish joint configurations to the ROS network for planning
> Note: the configurations of ROS communication can be found in the Inspector window of ROSConnect object
>
> * Joint configurations are published to ROS nodes running in the Docker container (127.0.0.1:10000)
> * ROS nodes in the Docker container will be notified that Unity's IP address is 127.0.0.1:5005
### If you'd now like to follow the full tutorial to learn how to build the pick-and-place simulation from scratch, proceed to [Part 1](1_urdf.md).

Просмотреть файл

@ -2,19 +2,19 @@
This page provides brief instructions on installing the Unity Robotics packages. Head over to the [Pick-and-Place Tutorial](pick_and_place/README.md) for more detailed instructions and steps for building a sample project.
1. Create or open a Unity project.
1. Create or open a Unity project.
> Note: If you are adding the URDF-Importer, ensure you are using a [2020.2.0](https://unity3d.com/unity/whats-new/2020.2.0)+ version of Unity Editor.
1. Open `Window` -> `Package Manager`.
1. In the Package Manager window, find and click the `+` button in the upper lefthand corner of the window. Select `Add package from git URL...`.
1. In the Package Manager window, find and click the `+` button in the upper lefthand corner of the window. Select `Add package from git URL...`.
![](../images/packman.png)
1. Enter the git URL for the desired package.
1. For the [ROS-TCP-Connector](https://github.com/Unity-Technologies/ROS-TCP-Connector), enter `https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector#v0.2.0`.
1. For the [URDF-Importer](https://github.com/Unity-Technologies/URDF-Importer), enter `https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#v0.2.0`.
1. Enter the git URL for the desired package. Note: you can append a version tag to the end of the git url, like `#v0.3.0` or `#v0.4.0`, to declare a specific package version, or exclude the tag to get the latest from the package's `main` branch.
1. For the [ROS-TCP-Connector](https://github.com/Unity-Technologies/ROS-TCP-Connector), enter `https://github.com/Unity-Technologies/ROS-TCP-Connector.git?path=/com.unity.robotics.ros-tcp-connector`.
1. For the [URDF-Importer](https://github.com/Unity-Technologies/URDF-Importer), enter `https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer`.
1. Click `Add`.
1. Click `Add`.
To install from a local clone of the repository, see [installing a local package](https://docs.unity3d.com/Manual/upm-ui-local.html) in the Unity manual.

Просмотреть файл

@ -14,6 +14,8 @@ The `ROSConnection` plugin (also from [ROS TCP Connector](https://github.com/Uni
## Tutorials
- [ROS–Unity Integration: Initial Setup](setup.md) - ROS-Unity Initial Setup
- [ROS–Unity Integration: Network Description](network.md) - Description of network settings and troubleshooting
- [ROS–Unity Integration: Publisher](publisher.md) - Adding a Publisher to a Unity Scene
- [ROS–Unity Integration: Subscriber](subscriber.md) - Adding a Subscriber to a Unity Scene
- [ROS–Unity Integration: Service](service.md) - Adding a Service call to a Unity Scene

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 44 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 124 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 45 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 128 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 139 KiB

Просмотреть файл

@ -0,0 +1,119 @@
# ROS–Unity Integration Networking
## Table of Contents
- [Definitions](#definitions)
- [Communicaton Minimum Requirements](#communication-minimum-requirements)
- [If Using Docker](#if-using-docker)
- [Explicitly Setting UNITY_IP](#explicitly-setting-unity_ip)
- [Troubleshoooting](#troubleshooting)
- [Where Does Communication Break Down](#where-does-communication-break-down)
- [1. Can Unity send messages to ROS?](#1-can-unity-send-messages-to-ros)
- [2. Can ROS send messages to Unity?](#2-can-ros-send-messages-to-unity)
- [Open Port on Windows Firewalll](#open-port-on-windows-firewall)
# Definitions
`ROS_IP` : The IP address of the machine, VM, or container running ROS.
`UNITY_IP` : The IP address of the machine running Unity.
> It is possible to set both of these variables on the machines running Unity and ROS. The specifics of where and why each of these settings will be described below.
On the ROS machine these settings are set as a rosparam and will typically be set in a launch file like [this](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/tutorials/ros_packages/robotics_demo/launch/robo_demo.launch) or in a [param file](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/tutorials/pick_and_place/ROS/src/niryo_moveit/config/params.yaml) loaded by a launch file like [this](https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/main/tutorials/pick_and_place/ROS/src/niryo_moveit/launch/part_3.launch#L2). The param file can also be loaded manually by running the `rosparam load params.yaml` command.
On the Unity machine these settings are set from the menu by going to `Robotics` -> `ROS Settings`
# Communication Minimum Requirements
The minimum settings required for Unity to communicate with ROS is to set the `ROS_IP` on the ROS side in a launch file and on the Unity side in `Robotics` -> `ROS Settings`.
## If Using Docker
The container will need to be started with the following arguments to forward the ports used for communication between ROS and Unity.
`-p 10000:10000 -p 5005:5005`
- On the ROS side, set `ROS_IP` to `0.0.0.0`.
- On the Unity side, set `ROS_IP` to `127.0.0.1` and the `Override Unity IP Address` to your local machine's IP address.
![](images/troubleshoot-docker-unity.png)
## Explicitly setting `UNITY_IP`
The `UNITY_IP` can be set in two different places.
1. If set on the ROS side as a rosparam, the `server_endpoint` will only use this IP to send messages to Unity.
1. If set on the Unity side as the `Override Unity IP Address`, the `UNITY_IP` on the ROS side will be set to this value during the initial handshake between ROS and Unity once play is pressed in the Editor.
> If the `UNITY_IP` is not set in either of these places, then the IP that makes the first connection to ROS during the initial handshake will be used.
# Troubleshooting
## Where Does Communication Break Down
### 1. Can Unity send messages to ROS?
When play is pressed in the Editor, a handshake message is sent from Unity to ROS.
If Unity can communicate with ROS, the following message should be printed to the console screen running the `server_endpoint.py` script.
```[UnityTcpSender]: ROS-Unity Handshake received, will connect to UNITY_IP_ADDRESS:5005```
With the corresponding response message printed to the Unity console,
```ROS-Unity server listening on UNITY_IP_ADDRESS:5005```
If the previous message is not shown and either of the following errors are thrown instead:
```
SocketException: A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond.
```
```
SocketException: Connection refused
```
Confirm that:
- `server_endpoint` is running
- You can ping ROS machine from Unity machine
- From a terminal on the Unity machine, run the following command to confirm whether the ROS machine is reachable over the network. ```ping ROS_IP```
If issue still persists:
- Confirm your IP addresses
- If on Windows you may need to [open ports for the firewall](#open-port-on-windows-firewall).
### 2. Can ROS send messages to Unity?
After it is confirmed that Unity can communicate with ROS, publish a message to a ROS topic to which Unity has instantiated a subscriber.
If an error is thrown in the `server_endpoint` console then ROS cannot connect to Unity.
If issue still persists:
- Confirm your IP addresses
- Explicitly set the `UNITY_IP`
- If on Windows you may need to [open ports for the firewall](#open-port-on-windows-firewall).
## Open port on Windows Firewall
- Open port in Windows Firewall by opening `Windows Defender Firewall` then selecting `Action` -> `New Rule...`
- Port `10000` will need to be added as an outbound rule
- Port `5005` will need to obe added as an inbound rule
![](images/troubleshoot-port-firewall.png)
In some instances opening a port did not resolve the communication issues and the Unity Editor had to be allowed through the firewall
- Allow the Editor through the firewall by opening `Windows Defender Firewall` -> `Allowed Apps` and then modifying the settings for the Unity Editor to allow communication on private and public networks.
![](images/troubleshoot-unity-firewall.png)

Просмотреть файл

@ -9,7 +9,7 @@ Create a simple Unity scene which publishes a GameObject's position and rotation
- Follow the [ROS–Unity Initial Setup](setup.md) guide.
- Open a new terminal window and run the following commands:
```bash
source devel/setup.bash
rosrun robotics_demo server_endpoint.py
@ -42,21 +42,21 @@ using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
/// <summary>
///
///
/// </summary>
public class RosPublisherExample : MonoBehaviour
{
ROSConnection ros;
public string topicName = "pos_rot";
// The game object
// The game object
public GameObject cube;
// Publish the cube's position and rotation every N seconds
public float publishMessageFrequency = 0.5f;
// Used to determine how much time has elapsed since the last message was published
private float timeElapsed;
void Start()
{
// start the ROS connection
@ -99,6 +99,8 @@ public class RosPublisherExample : MonoBehaviour
- Pressing play in the Editor should publish a message to the terminal running the `rostopic echo pos_rot` command every 0.5 seconds
> Please reference [networking troubleshooting](network.md) doc if any errors are thrown.
![](images/tcp_1.gif)
Continue to the [ROS Subscriber](subscriber.md) tutorial.

Просмотреть файл

@ -24,14 +24,14 @@ def main():
connections = rospy.get_param("/TCP_CONNECTIONS", 10)
tcp_server = TcpServer(ros_node_name, buffer_size, connections)
rospy.init_node(ros_node_name, anonymous=True)
tcp_server.start({
'pos_rot': RosPublisher('pos_rot', PosRot, queue_size=10),
'color': RosSubscriber('color', UnityColor, tcp_server),
'pos_srv': RosService('pos_srv', PositionService),
'obj_pose_srv': UnityService('obj_pose_srv', ObjectPoseService, tcp_server),
})
rospy.spin()
@ -74,7 +74,7 @@ The `ros_node_name` argument is required and the `buffer_size` and `connections`
'pos_srv': RosService('pos_srv', PositionService),
'obj_pose_srv': UnityService('obj_pose_srv', ObjectPoseService, tcp_server),
})
rospy.spin()
```
@ -141,7 +141,7 @@ An example launch file that will set the appropriate ROSPARAM values required fo
<env name="ROS_IP" value="127.0.0.1"/>
<env name="ROS_HOSTNAME" value="$(env ROS_IP)"/>
<param name="ROS_IP" type="str" value="$(env ROS_IP)" />
<param name="ROS_TCP_PORT" type="int" value="10000" />
<param name="TCP_NODE_NAME" type="str" value="TCPServer" />

Просмотреть файл

@ -11,7 +11,7 @@ Create a simple Unity scene which calls a [ROS service](http://wiki.ros.org/Serv
- Follow the [ROS–Unity Initial Setup](setup.md) guide.
- Open a new terminal window, navigate to your ROS workspace, and run the following commands:
```bash
source devel/setup.bash
rosrun robotics_demo server_endpoint.py
@ -106,4 +106,7 @@ public class RosServiceExample : MonoBehaviour
- Attach the `RosServiceExample` script to the `RosService` GameObject. Drag the cube GameObject onto its `cube` parameter.
- Pressing play in the Editor should start communication with the `position_service` script, running as a ROS node, causing the cube to move to random positions in the scene.
> Please reference [networking troubleshooting](network.md) doc if any errors are thrown.
![](images/tcp_3.gif)

Просмотреть файл

@ -9,7 +9,7 @@ The minimum requirements for a ROS–Unity integration.
1. Navigate to your Catkin workspace and run `catkin_make && source devel/setup.bash`. Ensure there are no errors.
1. Open a new terminal, navigate to your Catkin workspace, and run:
```bash
source devel/setup.bash
roscore &
@ -17,9 +17,9 @@ The minimum requirements for a ROS–Unity integration.
Once ROS Core has started, it will print `started core service [/rosout]` to the terminal window.
1. Note that in the `server_endpoint`, the script fetches parameters for the TCP connection. You will need to know the IP address of your ROS machine as well as the IP address of the machine running Unity.
1. Note that in the `server_endpoint`, the script fetches parameters for the TCP connection. You will need to know the IP address of your ROS machine as well as the IP address of the machine running Unity.
- The ROS machine IP, i.e. `ROS_IP` should be the same value as the one set as `Host Name` on the RosConnect component in Unity.
1. The ROS parameter values can be set using a YAML file. Create a `params.yaml` file in your package, e.g. `./config/params.yaml`. Open the file for editing.
1. The ROS parameter values can be set using a YAML file. Create a `params.yaml` file in your package, e.g. `./config/params.yaml`. Open the file for editing.
1. Update the `ROS_IP` below with the appropriate address and copy the contents into the `params.yaml` file.
@ -27,7 +27,7 @@ Once ROS Core has started, it will print `started core service [/rosout]` to the
ROS_IP: <your ROS IP>
ROS_TCP_PORT: 10000
```
e.g.
```yaml
@ -49,7 +49,7 @@ Once ROS Core has started, it will print `started core service [/rosout]` to the
<rosparam file="$(find <PACKAGE_NAME>)/config/params.yaml" command="load"/>
</launch>
```
> Read more about rosparam YAML options [here](http://wiki.ros.org/rosparam).
>
> Read more about the ROS Parameter Server [here](http://wiki.ros.org/Parameter%20Server).

Просмотреть файл

@ -11,7 +11,7 @@ Create a simple Unity scene which subscribes to a [ROS topic](http://wiki.ros.or
- Follow the [ROS–Unity Initial Setup](setup.md) guide.
- Open a new terminal window, navigate to your Catkin workspace, and run the following commands:
```bash
source devel/setup.bash
rosrun robotics_demo server_endpoint.py
@ -21,7 +21,7 @@ Once the server_endpoint has started, it will print something similar to `[INFO]
- In Unity, we need to generate the C# code for the `UnityColor` message. Open `Robotics` -> `Generate ROS Messages...`.
- Set the ROS message path to `PATH/TO/Unity-Robotics-Hub/tutorials/ros_packages/robotics_demo/`, expand the robotics_demo subfolder and click `Build 2 msgs`.
![](images/generate_messages_1.png)
- The generated files will be saved in the default directory `Assets/RosMessages/RoboticsDemo/msg`.
@ -56,16 +56,13 @@ public class RosSubscriberExample : MonoBehaviour
- Attach the `RosSubscriberExample` script to the `RosSubscriber` GameObject and drag the cube GameObject onto the `cube` parameter in the Inspector window.
- From the Unity menu bar, open `Robotics/ROS Settings`, and set the `ROS IP Address` variable to your ROS IP.
- Unlike the previous tutorial, using a subscriber requires an incoming connection from ROS to Unity. You may need to adjust your firewall settings for this to work.
- The IP for Unity to listen on should be determined automatically, but if you're having trouble, you can set it manually in the `Override Unity IP` field. Finding the IP address of your local machine (the one running Unity) depends on your operating system.
- On a Mac, open `System Preferences > Network`. Your IP address should be listed on the active connection.
- On Windows, click the Wi-Fi icon on the taskbar, and open `Properties`. Your IP address should be listed near the bottom, next to "IPv4 address."
- Press play in the editor
### In ROS Terminal Window
- After the scene has entered Play mode, run the following command: `rosrun robotics_demo color_publisher.py` to change the color of the cube GameObject in Unity to a random color
> Please reference [networking troubleshooting](network.md) doc if any errors are thrown.
![](images/tcp_2.gif)
Continue to the [ROS–Unity Integration Service](service.md).

Просмотреть файл

@ -17,7 +17,7 @@ public class RosPublisherExample : MonoBehaviour
// Used to determine how much time has elapsed since the last message was published
private float timeElapsed;
void Start()
{
// start the ROS connection
@ -48,4 +48,4 @@ public class RosPublisherExample : MonoBehaviour
timeElapsed = 0;
}
}
}
}

Просмотреть файл

@ -47,7 +47,7 @@ public class RosServiceExample : MonoBehaviour
// Send message to ROS and return the response
ros.SendServiceMessage<MPositionServiceResponse>(serviceName, positionServiceRequest, Callback_Destination);
awaitingResponseUntilTimestamp = Time.time+1.0f; // don't send again for 1 second, or until we receive a response
awaitingResponseUntilTimestamp = Time.time + 1.0f; // don't send again for 1 second, or until we receive a response
}
}
@ -57,4 +57,4 @@ public class RosServiceExample : MonoBehaviour
destination = new Vector3(response.output.pos_x, response.output.pos_y, response.output.pos_z);
Debug.Log("New Destination: " + destination);
}
}
}

Просмотреть файл

@ -1,18 +1,18 @@
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
using RosColor = RosMessageTypes.RoboticsDemo.MUnityColor;
public class RosSubscriberExample : MonoBehaviour
{
public GameObject cube;
void Start()
{
ROSConnection.instance.Subscribe<RosColor>("color", ColorChange);
}
void ColorChange(RosColor colorMessage)
{
cube.GetComponent<Renderer>().material.color = new Color32((byte)colorMessage.r, (byte)colorMessage.g, (byte)colorMessage.b, (byte)colorMessage.a);
}
}
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
using RosColor = RosMessageTypes.RoboticsDemo.MUnityColor;
public class RosSubscriberExample : MonoBehaviour
{
public GameObject cube;
void Start()
{
ROSConnection.instance.Subscribe<RosColor>("color", ColorChange);
}
void ColorChange(RosColor colorMessage)
{
cube.GetComponent<Renderer>().material.color = new Color32((byte)colorMessage.r, (byte)colorMessage.g, (byte)colorMessage.b, (byte)colorMessage.a);
}
}

Просмотреть файл

@ -31,13 +31,13 @@ public class RosUnityServiceExample : MonoBehaviour
MObjectPoseServiceResponse objectPoseResponse = new MObjectPoseServiceResponse();
// Find a game object with the requested name
GameObject gameObject = GameObject.Find(request.object_name);
if (gameObject)
if (gameObject)
{
// Fill-in the response with the object pose converted from Unity coordinate to ROS coordinate system
objectPoseResponse.object_pose.position = gameObject.transform.position.To<FLU>();
objectPoseResponse.object_pose.orientation = gameObject.transform.rotation.To<FLU>();
}
return objectPoseResponse;
}
}

Просмотреть файл

@ -11,7 +11,7 @@ Create a simple Unity scene which create a [Service](http://wiki.ros.org/Service
- Follow the [ROS–Unity Initial Setup](setup.md) guide.
- Open a new terminal window, navigate to your ROS workspace, and run the following commands:
```bash
source devel/setup.bash
rosrun robotics_demo server_endpoint.py
@ -26,7 +26,7 @@ Once the server_endpoint has started, it will print something similar to `[INFO]
![](images/generate_messages_2.png)
- The generated files will be saved in the default directory `Assets/RosMessages/RoboticsDemo/srv`.
- Create a new C# script and name it `RosUnityServiceExample.cs`
- Paste the following code into `RosUnityServiceExample.cs`
- **Note:** This script can be found at `tutorials/ros_unity_integration/unity_scripts`.
@ -65,13 +65,13 @@ public class RosUnityServiceExample : MonoBehaviour
MObjectPoseServiceResponse objectPoseResponse = new MObjectPoseServiceResponse();
// Find a game object with the requested name
GameObject gameObject = GameObject.Find(request.object_name);
if (gameObject)
if (gameObject)
{
// Fill-in the response with the object pose converted from Unity coordinate to ROS coordinate system
objectPoseResponse.object_pose.position = gameObject.transform.position.To<FLU>();
objectPoseResponse.object_pose.orientation = gameObject.transform.rotation.To<FLU>();
}
return objectPoseResponse;
}
}
@ -79,8 +79,8 @@ public class RosUnityServiceExample : MonoBehaviour
- From the main menu bar, open `Robotics/ROS Settings`, and change the `ROS IP Address` variable to the ROS IP.
- Create an empty GameObject and name it `UnityService`.
- Attach the `RosUnityServiceExample` script to the `UnityService` GameObject.
- Pressing play in the Editor should start running as a ROS node, waiting to accept ObjectPose requests. Once a connection to ROS has been established, a message will be printed on the ROS terminal similar to `ROS-Unity Handshake received, will connect to 192.168.50.130:5005`.
- Attach the `RosUnityServiceExample` script to the `UnityService` GameObject.
- Pressing play in the Editor should start running as a ROS node, waiting to accept ObjectPose requests. Once a connection to ROS has been established, a message will be printed on the ROS terminal similar to `Connection from 172.17.0.1`.
## Start the Client
@ -94,12 +94,12 @@ public class RosUnityServiceExample : MonoBehaviour
```bash
Requesting pose for Cube
Pose for Cube:
position:
Pose for Cube:
position:
x: 0.0
y: -1.0
z: 0.20000000298023224
orientation:
orientation:
x: 0.0
y: -0.0
z: 0.0
@ -113,12 +113,12 @@ You may replace `Cube` with the name of any other GameObject currently present i
rosservice call /obj_pose_srv Cube
```
```bash
object_pose:
position:
object_pose:
position:
x: 0.0
y: -1.0
z: 0.20000000298023224
orientation:
orientation:
x: 0.0
y: -0.0
z: 0.0

Просмотреть файл

@ -3,9 +3,9 @@
## File Hierarchy
URDF files and associated meshes should be placed in a single folder within the Assets directory of Unity. We suggest creating a new folder with the robot's name and place the URDF file in its root with all associated mesh files in sub folders. Be sure to update the file locations as described by the URDF file.
## GameObject Hierarchy
## GameObject Hierarchy
The robot imported in Unity follows a Parent - Child hierarchy.
The robot imported in Unity follows a Parent - Child hierarchy.
- Robot GameObject
- UrdfRobot Script: UrdfRobot.cs script contains functions to change the behaviors of the imported robot. The script is used to control a robot's behavior, compare against a URDF file, and export the robot as a URDF file.
- Controller Script: Enables keyboard control of the robot. It can be modified to create custom controllers as described [here](##Guide-to-write-your-own-controller).
@ -30,12 +30,12 @@ URDF comparator is a testing tool to compare two URDF files. This tool can be us
- After the exported file location is selected, its location is automatically selected as location of `Log File Save Location`. You can choose your own save location by pressing the `Select` next to the text field.
- To compare the two URDF files press `Compare URDF Files` to generate the [log file](#URDF_Comparator).
## URDF_Comparator
## URDF_Comparator
The URDF comparator generates a log file which details the results of the comparison. Log file contains two types of log blocks. One type of block details joint:
```
********LINK*****
Name:
Name:
Equal: True
Name: Source: base_link Exported: base_link
Inertial Checks
@ -64,10 +64,10 @@ The URDF comparator generates a log file which details the results of the compar
Material Checks
Material Nullity Check: True
Name Equal: True
Name: Source: LightGrey
Name: Source: LightGrey
Exported: LightGrey
Colors Equal: True
RGB :0.700 0.700 0.700
RGB :0.700 0.700 0.700
Texture nullity equality: True
Collisions Checks
Number of Collision Components
@ -77,8 +77,8 @@ Exported Count: 0001
-Collision Component: 1
Collision Name
Equal: True
Name: Source:
Exported:
Name: Source:
Exported:
Origin Checks
Origin Nullity Check: True
Geometry:
@ -118,9 +118,9 @@ Parent: Exported: base_link
Axis Checks
Axis
Equal: True
XYZ : (0.000,0.000,1.000)
XYZ : (0.000,0.000,1.000)
Dynamics Checks
Dynamics Equal: True
Dynamics Equal: True
Lower Limit:
Equal: True
Lower Limit Value: -3.14159265359
@ -135,7 +135,7 @@ Child Name: Source: shoulder_link
Child Name: Exported: shoulder_link
```
Log file contains comparison for every attribute contained in the source URDF file to the corresponding attribute in exported URDF file. Each attribute follows the format :
Log file contains comparison for every attribute contained in the source URDF file to the corresponding attribute in exported URDF file. Each attribute follows the format :
```
<Attribute_Name>
Equal : <True/False>
@ -144,7 +144,7 @@ Equal : <True/False>
```
Some attributes generates a nullity check which checks for presence of attributes in both URDF files.
## Articulation Body axis definition
## Articulation Body axis definition
![](images/Unity_coordinate.png)
The most commonly used Coordinate system is the right hand coordinate system which is shown in the figure above. It follows the convention that if your right-hand thumb represents the X direction, then the index finger and the middle finger stretched out uncrossed at right angles would represent the Y and Z direction respectively. Positive direction of rotation is represented by the curl of the fingers with the thumb stretched out.
@ -163,7 +163,7 @@ Note: When the mesh is imported in Unity, the x axis is negated to convert the m
Articulation Body allows the joints to be controlled by three methods:
1. Position Control
2. Torque Control
2. Torque Control
3. Velocity Control
All types of control are governed by the Spring-Damper equation :
@ -174,7 +174,7 @@ F = stiffness * (currentPosition - target) - damping * (currentVelocity - target
#### Example Code
Code for positional control can be divided into two scripts. One script would be attached to the root GameObject which represents the robot. This script would determine the correct position of the joint, directed by a control policy implemented by the user. The other end of the script is attached to the GameObject with ArticulationBody component which receives the target position and assigns that
Code for positional control can be divided into two scripts. One script would be attached to the root GameObject which represents the robot. This script would determine the correct position of the joint, directed by a control policy implemented by the user. The other end of the script is attached to the GameObject with ArticulationBody component which receives the target position and assigns that
value to the articulation body.
**Note: This architecture can be changed according to the user's design.**
@ -215,7 +215,7 @@ void Update()
}
Highlight(selectedIndex);
}
UpdateDirection(selectedIndex);
}
```
@ -224,10 +224,10 @@ The up and down arrow keys are used to update the direction in which the joint i
private void UpdateDirection(int jointIndex)
{
float moveDirection = Input.GetAxis("Vertical");
JointControl current = articulationChain[jointIndex].GetComponent<JointControl>();
JointControl current = articulationChain[jointIndex].GetComponent<JointControl>();
if (previousIndex != jointIndex)
{
JointControl previous = articulationChain[previousIndex].GetComponent<JointControl>();
JointControl previous = articulationChain[previousIndex].GetComponent<JointControl>();
previous.direction = RotationDirection.None;
previousIndex = jointIndex;
}
@ -269,16 +269,16 @@ The joint control script determines the direction in which the joint needs to mo
float newTargetDelta = (int)direction * Time.fixedDeltaTime * speed;
if (newTargetDelta + currentDrive.target <= currentDrive.upperLimit && newTargetDelta + currentDrive.target >= currentDrive.lowerLimit){
currentDrive.target += newTargetDelta;
}
}
joint.xDrive = currentDrive;
}
}
}
}
}
```
### Position Control
### Position Control
Position Control can be imagined as adding a spring to a joint with linear spring in case of prismatic joint and a torsional spring in case of revolute joint. The joint follows Hooke's law:
@ -320,7 +320,7 @@ To address this predicament we have integrated another algorithm to create Conve
URDF defines the robot visually using Visual Meshes, and its collision using Collision Meshes. Collision meshes define the physical volume of the links, and are used to calculate the inertia of the links and also to detect collisions between different physical objects. In Unity, rigidbodies cannot have concave collision meshes, so when importing a concave collision mesh, all concave regions are closed over to produce a convex outline. As a result, the convex shapes might intersect with each other, creating a hindrance in robot movement. To remedy this, we support a ```disable collision``` tag in URDF. To add an exception for collision detection in Unity:
1. Identify the links between which you want to ignore the collisions.
2. Add a tag in the URDF file with the format
2. Add a tag in the URDF file with the format
```XML
<disable_collision link1= <name_of_link_1> link2=<name_of_link_2>>
</disable_collision>

Просмотреть файл

@ -6,20 +6,20 @@
- Niryo One URDF files from [Niryo One ROS](https://github.com/NiryoRobotics/niryo_one_ros)
- Working ROS environment
## Setting up the URDF Importer in Unity Editor
## Setting up the URDF Importer in Unity Editor
- Integrate the URDF Importer following these [instructions](https://github.com/Unity-Technologies/URDF-Importer#integrate-urdf-importer-into-unity-project)
- Create a new directory in `Assets` and name it `URDF`
- Clone the [Niryo One ROS](https://github.com/NiryoRobotics/niryo_one_ros) repo and copy the `niryo_one_description` directory into `Assets/URDF`
- This directory only includes a `.urdf.xacro` file which will need to be converted into a `.urdf` file before we can import it
- Run the following command to convert Xacro to URDF, `rosrun xacro xacro --inorder -o PATH/TO/niryo_one.urdf PATH/TO/niryo_one.urdf.xacro`
- Copy the generated `niryo_one.urdf` file to `Assets/URDF`
- Right click on the this file and select `Import Robot from URDF`
- Select the co-ordinate system in which the meshes were designed. Default mesh orientation is Y-up which is supported by Unity but some packages often use Z-up and X-up configuration. For more [information](https://docs.unity3d.com/Manual/HOWTO-FixZAxisIsUp.html).
- Right click on the this file and select `Import Robot from URDF`
- Select the co-ordinate system in which the meshes were designed. Default mesh orientation is Y-up which is supported by Unity but some packages often use Z-up and X-up configuration. For more [information](https://docs.unity3d.com/Manual/HOWTO-FixZAxisIsUp.html).
- Select the Convex Mesh Decomposer you want to use for the imported robot. More information can be found [here](urdf_appendix.md##Convex-Mesh-Collider).
- Click `Import`
## Using the Controller
- To add the controller to an imported robot click the `Enable` button in the Inspector window in front of the `Controller Script` option. This will add a Controller Script, FKrobot and Joint Control at runtime.
- To add the controller to an imported robot click the `Enable` button in the Inspector window in front of the `Controller Script` option. This will add a Controller Script, FKrobot and Joint Control at runtime.
- To prevent the joints from slipping set the `Stiffness` and `Damping` to `100,000` and `10,000` respectively.
- To be able to apply forces to the joints set the `Force Limit` to `10,000`.
- To prevent the robot from falling over, in the GameObject tree expand `niryo_one` -> `world` -> `base_link` and set the toggle for `Immovable` for the base_link.