Skip to content

Commit 0627464

Browse files
authored
Add linter (#227)
* Add linter and pre-commit hooks * Formatting * Remove setting up ruby
1 parent b6e1921 commit 0627464

37 files changed

+366
-240
lines changed

.editorconfig

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
; see http://editorconfig.org/ for docs on this file
2+
; See https://github.com/dotnet/format for dotnet format
3+
4+
root = true
5+
6+
[*]
7+
ignore_if_in_header = This code was generated by a tool|<auto-generated>
8+
indent_style = space
9+
indent_size = 4
10+
; uncomment to help with sharing files across os's (i.e. network share or through local vm)
11+
#end_of_line = lf
12+
; avoid a bom, which causes endless problems with naive text tooling
13+
charset = utf-8
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true
16+
; keeping auto-format enabled helps avoid merge hell for projects without CI-based format validation
17+
#disable_auto_format = true
18+
19+
[*.cs]
20+
; uncomment to enable full formatting of c# files
21+
formatters = generic, uncrustify
22+
23+
[*.asmdef]
24+
scrape_api = true
25+
26+
[**/Tests/**.asmdef]
27+
scrape_api = false
28+
29+
[*.Tests.asmdef]
30+
scrape_api = false
31+
32+
[*.md]
33+
indent_size = 2
34+
; trailing whitespace is unfortunately significant in markdown
35+
trim_trailing_whitespace = false
36+
; uncomment to enable basic formatting of markdown files
37+
#formatters = generic
38+
39+
[{Makefile,makefile}]
40+
; tab characters are part of the Makefile format
41+
indent_style = tab
42+
43+
[*.asmdef]
44+
indent_size = 4
45+
46+
[*.json]
47+
indent_size = 2
48+
49+
[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}]
50+
end_of_line = crlf
51+
52+
; this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited.
53+
; the settings are meant to closely match what VS does to minimize unnecessary diffs.
54+
[*.{vcxproj,vcxproj.filters}]
55+
indent_style = space
56+
indent_size = 2
57+
end_of_line = crlf
58+
charset = utf-8-bom
59+
trim_trailing_whitespace = true
60+
insert_final_newline = false
61+
; must be broken out because of 51-char bug (https://github.com/editorconfig/editorconfig-visualstudio/issues/21)
62+
[*.{csproj,pyproj,props,targets}]
63+
indent_style = space
64+
indent_size = 2
65+
end_of_line = crlf
66+
charset = utf-8-bom
67+
trim_trailing_whitespace = true
68+
insert_final_newline = false
69+
[*.{sln,sln.template}]
70+
indent_style = tab
71+
indent_size = 4
72+
end_of_line = crlf
73+
charset = utf-8
74+
trim_trailing_whitespace = true
75+
insert_final_newline = false

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Provide any relevant links here.
1616

1717
## Testing and Verification
1818

19-
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.
19+
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.
2020

2121
### Test Configuration:
2222
- Unity Version: [e.g. Unity 2020.2.0f1]

.github/workflows/pre-commit.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [dev]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.7.x
16+
- uses: actions/setup-dotnet@v1
17+
with:
18+
dotnet-version: '3.1.x'
19+
- uses: pre-commit/action@v2.0.0

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.swp
33
.idea
44
.vscode/
5-
tutorials/pick_and_place/PickAndPlaceProject/Packages/packages-lock.json
5+
tutorials/pick_and_place/PickAndPlaceProject/Packages/packages-lock.json

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: mixed-line-ending
6+
exclude: >
7+
(?x)^(
8+
.*cs.meta|
9+
.*.css|
10+
.*.meta|
11+
.*.mat|
12+
.*.preset|
13+
.*.lighting|
14+
.*.dae
15+
)$
16+
args: [--fix=lf]
17+
18+
- id: trailing-whitespace
19+
name: trailing-whitespace-markdown
20+
types: [markdown]
21+
- id: check-merge-conflict
22+
args: [--assume-in-merge]
23+
- id: check-yaml
24+
# Won't handle the templating in yamato
25+
exclude: \.yamato/.*
26+
27+
28+
- repo: https://github.com/dotnet/format
29+
rev: "7e343070a0355c86f72bdee226b5e19ffcbac931"
30+
hooks:
31+
- id: dotnet-format
32+
args: [--folder, --include]

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contribution Guidelines
22

3-
Thank you for your interest in contributing to Unity Robotics! To facilitate your
4-
contributions, we've outlined a brief set of guidelines to ensure that your extensions
3+
Thank you for your interest in contributing to Unity Robotics! To facilitate your
4+
contributions, we've outlined a brief set of guidelines to ensure that your extensions
55
can be easily integrated.
66

77
## Communication
@@ -40,10 +40,10 @@ We run continuous integration on all PRs; all tests must be passing before the P
4040

4141
All Python code should follow the [PEP 8 style guidelines](https://pep8.org/).
4242

43-
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).
44-
Additionally, the [Unity Coding package](https://docs.unity3d.com/Packages/com.unity.coding@0.1/manual/index.html)
45-
can be used to format, encode, and lint your code according to the standard Unity
46-
development conventions. Be aware that these Unity conventions will supersede the
43+
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).
44+
Additionally, the [Unity Coding package](https://docs.unity3d.com/Packages/com.unity.coding@0.1/manual/index.html)
45+
can be used to format, encode, and lint your code according to the standard Unity
46+
development conventions. Be aware that these Unity conventions will supersede the
4747
Microsoft C# Coding Conventions where applicable.
4848

4949
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).
6060

6161
## Contribution review
6262

63-
Once you have a change ready following the above ground rules, simply make a
63+
Once you have a change ready following the above ground rules, simply make a
6464
pull request in GitHub.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Simulation plays an important role in robotics development, and we’re here to
1919
| [Quick Installation Instructions](tutorials/quick_setup.md) | Brief steps on installing the Unity Robotics packages |
2020
| [Pick-and-Place Demo](tutorials/pick_and_place/README.md) | A complete end-to-end demonstration, including how to set up the Unity environment, how to import a robot from URDF, and how to set up two-way communication with ROS for control |
2121
| [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 |
22-
| [URDF Importer](tutorials/urdf_importer/urdf_tutorial.md) | Steps on using the Unity package for loading [URDF](http://wiki.ros.org/urdf) files |
22+
| [URDF Importer](tutorials/urdf_importer/urdf_tutorial.md) | Steps on using the Unity package for loading [URDF](http://wiki.ros.org/urdf) files |
2323
| [Articulations Robot Demo](https://github.com/Unity-Technologies/articulations-robot-demo) | A robot simulation demonstrating Unity's new physics solver (no ROS dependency)
2424

2525

@@ -43,7 +43,7 @@ Unite Now 2020: Simulating Robots with ROS and Unity [video](https://resources.u
4343
- (August 26, 2020)
4444
Announcing Unity Robotic Simulation [blog post](https://unity.com/solutions/automotive-transportation-manufacturing/robotics)
4545
- (May 20, 2020)
46-
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/)
46+
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/)
4747

4848
### More from Unity
4949

@@ -67,8 +67,8 @@ Here’s a peek into what our Physics Team is hard at work on…
6767

6868
## Community and Feedback
6969

70-
The Unity Robotics projects are open-source and we encourage and welcome contributions.
71-
If you wish to contribute, be sure to review our [contribution guidelines](CONTRIBUTING.md)
70+
The Unity Robotics projects are open-source and we encourage and welcome contributions.
71+
If you wish to contribute, be sure to review our [contribution guidelines](CONTRIBUTING.md)
7272
and [code of conduct](CODE_OF_CONDUCT.md).
7373

7474
## Support
@@ -77,7 +77,7 @@ For questions or discussions about Unity Robotics package installations or how t
7777

7878
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.
7979

80-
For any other questions or feedback, connect directly with the
80+
For any other questions or feedback, connect directly with the
8181
Robotics team at [unity-robotics@unity3d.com](mailto:unity-robotics@unity3d.com).
8282

8383
## License

faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ How does your Unity integration compare to ROS#?
2121
---
2222
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).
2323

24-
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.
24+
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.
2525

2626
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.
2727

tutorials/pick_and_place/0_ros_setup.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Pick-and-Place Tutorial: Part 0
22

33
This part provides two options for setting up your ROS workspace: using Docker, or manually setting up a catkin workspace.
4-
4+
55
**Table of Contents**
66
- [Option A: Use Docker](#option-a-use-docker)
77
- [Option B: Manual Setup](#option-b-manual-setup)
@@ -34,28 +34,28 @@ git clone --recurse-submodules https://github.com/Unity-Technologies/Unity-Robot
3434
docker build -t unity-robotics:pick-and-place -f docker/Dockerfile .
3535
```
3636

37-
> 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.
38-
39-
1. Start the newly built Docker container:
40-
37+
> 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.
38+
39+
1. Start the newly built Docker container:
40+
4141
```docker
4242
docker run -it --rm -p 10000:10000 -p 5005:5005 unity-robotics:pick-and-place /bin/bash
4343
```
4444

45-
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#`.
45+
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#`.
4646

4747
The ROS workspace is now ready to accept commands!
4848

4949
---
5050

5151
## Option B: Manual Setup
5252

53-
1. Navigate to the `/PATH/TO/Unity-Robotics-Hub/tutorials/pick_and_place/ROS` directory of this downloaded repo.
53+
1. Navigate to the `/PATH/TO/Unity-Robotics-Hub/tutorials/pick_and_place/ROS` directory of this downloaded repo.
5454
- This directory will be used as the [ROS catkin workspace](http://wiki.ros.org/catkin/Tutorials/using_a_workspace).
55-
- 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.
55+
- 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.
5656
- Copy or download this directory to your ROS operating system if you are doing ROS operations in another machine, VM, or container.
5757
> 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`.
58-
58+
5959
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:
6060
6161
```bash
@@ -75,7 +75,7 @@ The ROS workspace is now ready to accept commands!
7575
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.
7676
7777
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:
78-
78+
7979
```bash
8080
echo "ROS_IP: $(hostname -I)" > src/niryo_moveit/config/params.yaml
8181
```
@@ -85,7 +85,7 @@ The ROS workspace is now ready to accept commands!
8585
```yaml
8686
ROS_IP: <your ROS IP>
8787
```
88-
88+
8989
e.g.
9090
9191
```yaml
@@ -98,17 +98,17 @@ The ROS workspace is now ready to accept commands!
9898
9999
## Troubleshooting
100100
- 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`.
101-
101+
102102
- `...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.
103-
103+
104104
- 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.
105105
106106
---
107107
108108
## Resources
109109
- [Getting started with Docker](https://docs.docker.com/get-started/)
110110
- Setting up a ROS workspace:
111-
111+
112112
> Note: this tutorial has been tested with ROS Melodic as well as ROS Noetic.
113113
- http://wiki.ros.org/ROS/Installation
114114
- http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment

0 commit comments

Comments
 (0)