Skip to content

Commit

Permalink
Add pre-commit (#6)
Browse files Browse the repository at this point in the history
* Add pre-commit-config.yaml

* Add pre-commit-config.yaml

* code format

* Add pre-commit action
  • Loading branch information
johnwason authored Oct 12, 2024
1 parent a183661 commit a7f0d3c
Show file tree
Hide file tree
Showing 17 changed files with 400 additions and 322 deletions.
30 changes: 15 additions & 15 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Set update schedule for GitHub Actions

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
- package-ecosystem: "nuget"
directory: "/"
schedule:
# Check for updates to NuGet packages every week
interval: "weekly"
# Set update schedule for GitHub Actions

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
- package-ecosystem: "nuget"
directory: "/"
schedule:
# Check for updates to NuGet packages every week
interval: "weekly"
46 changes: 23 additions & 23 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Docker

on:
push:
release:
types: [created]
workflow_dispatch:
pull_request:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: wasontech/abb-robotraconteur-driver:latest
name: Docker

on:
push:
release:
types: [created]
workflow_dispatch:
pull_request:

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: wasontech/abb-robotraconteur-driver:latest
80 changes: 48 additions & 32 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
name: CI

on:
push:
release:
types: [created]
workflow_dispatch:
pull_request:

jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: set up dotnet core 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: publish
run: dotnet publish -c Release /p:Platform="Any CPU" --framework=net6.0 -o abb_robotraconteur_driver
- name: copy license and readme
run: |
Copy-Item -Path LICENSE.txt -Destination abb_robotraconteur_driver
Copy-Item -Path README.md -Destination abb_robotraconteur_driver
- name: zip
run: Compress-Archive -Path abb_robotraconteur_driver -DestinationPath abb_robotraconteur_driver.zip
- name: upload
uses: actions/upload-artifact@v4
with:
name: abb_robotraconteur_driver
path: abb_robotraconteur_driver.zip
name: CI

on:
push:
release:
types: [created]
workflow_dispatch:
pull_request:

jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: set up dotnet core 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: publish
run: dotnet publish -c Release /p:Platform="Any CPU" --framework=net6.0 -o abb_robotraconteur_driver
- name: copy license and readme
run: |
Copy-Item -Path LICENSE.txt -Destination abb_robotraconteur_driver
Copy-Item -Path README.md -Destination abb_robotraconteur_driver
- name: zip
run: Compress-Archive -Path abb_robotraconteur_driver -DestinationPath abb_robotraconteur_driver.zip
- name: upload
uses: actions/upload-artifact@v4
with:
name: abb_robotraconteur_driver
path: abb_robotraconteur_driver.zip
pre-commit:
runs-on: ubuntu-22.04
env:
SKIP: no-commit-to-branch
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: apt
run: |
sudo apt update
sudo apt install -y dos2unix
- name: Setup dotnet 6.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- uses: pre-commit/[email protected]
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
exclude: ^(bin|obj|\.vs|\.vscode|TestResults|Generated_Code|generated_src)/.*$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
exclude: .clang-format
args: ['--unsafe']
- id: check-ast
- id: check-docstring-first
- id: debug-statements
- id: end-of-file-fixer
exclude: (^.*\.cs$|^.*\.csproj$|^.*\.sln$)
- id: mixed-line-ending
exclude: (^.*\.cs$|^.*\.csproj$|^.*\.sln$)
- id: trailing-whitespace
- id: fix-byte-order-marker
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-json
- id: check-toml
- id: check-xml
- id: detect-private-key
- id: no-commit-to-branch
args: ['--branch', 'master']
- id: forbid-submodules
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
hooks:
- id: autopep8
args: ["--ignore=E402", "-i", "--max-line-length=120"]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', '--preserve-quotes']
exclude: ^\.clang.*$
# - repo: https://github.com/efrecon/pre-commit-hook-lxml
# rev: v0.1.1
# hooks:
# - id: format-xml
# exclude: ^.*\.svg$
- repo: local
hooks:
- id: dos2unix
name: dos2unix
entry: dos2unix
args: ["-n", "-o"]
files: '\.(c|cpp|h|hpp|java|i|m|cmake|txt|css|js|ts|html|md|txt|py|yaml|yml|rst|py\.in|)$'
language: system
- repo: local
hooks:
#Use dotnet format already installed on your machine
- id: dotnet-format
name: dotnet-format
language: system
entry: dotnet format --include
types_or: ["c#", "vb"]
2 changes: 1 addition & 1 deletion ABBRobotRaconteurDriver.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ RUN sudo add-apt-repository ppa:robotraconteur/ppa -y \
&& sudo apt-get update \
&& sudo apt-get install librobotraconteur-net-native -y

CMD exec /opt/abb_robotraconteur_driver/ABBRobotRaconteurDriver --robot-info-file=$ROBOT_INFO_FILE
CMD exec /opt/abb_robotraconteur_driver/ABBRobotRaconteurDriver --robot-info-file=$ROBOT_INFO_FILE

Check warning on line 24 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

Check warning on line 24 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

Check warning on line 24 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ The [common Robot Raconteur node options](https://github.com/robotraconteur/robo

## Running the driver

Zip files containing the driver are available on the
[Releases](https://github.com/robotraconteur-contrib/ABBRobotRaconteurDriver/releases) page.
Zip files containing the driver are available on the
[Releases](https://github.com/robotraconteur-contrib/ABBRobotRaconteurDriver/releases) page.
Download the zip file and extract it to a directory.
The .NET 6.0 runtime is required to run the driver. This driver will run on Windows and Linux.

Expand All @@ -71,7 +71,7 @@ On Linux it is possible to run the driver using docker. The following command wi
sudo docker run --rm --net=host --privileged -v /var/run/robotraconteur:/var/run/robotraconteur -v /var/lib/robotraconteur:/var/lib/robotraconteur wasontech/abb-robotraconteur-driver /opt/abb_robotraconteur_driver/ABBRobotRaconteurDriver --robot-info-file=/config/abb_1200_5_90_robot_default_config.yml
```

It may be necessary to mount a docker "volume" to access configuration yml files that are not included in the docker image.
It may be necessary to mount a docker "volume" to access configuration yml files that are not included in the docker image.
See the docker documentation for instructions on mounting a local directory as a volume so it can be accessed inside the docker.

## Robot Setup Instructions
Expand Down
16 changes: 8 additions & 8 deletions config/abb_1200_5_90_robot_default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ device_info:
user_description: ABB Robot
serial_number: 123456789
device_classes:
- class_identifier:
name: robot
uuid: 39b513e7-21b9-4b49-8654-7537473030eb
subclasses:
- serial
- serial_six_axis
- class_identifier:
name: robot
uuid: 39b513e7-21b9-4b49-8654-7537473030eb
subclasses:
- serial
- serial_six_axis
implemented_types:
- com.robotraconteur.robotics.robot.Robot
- com.robotraconteur.robotics.robot.Robot
robot_type: serial
robot_capabilities:
- jog_command
Expand Down Expand Up @@ -83,7 +83,7 @@ chains:
- 2
- 3
- 4
- 5
- 5
joint_info:
- default_effort_units: newton_meter
default_units: radian
Expand Down
70 changes: 35 additions & 35 deletions examples/abb_jog_example_client.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
from RobotRaconteur.Client import *
import time
import numpy as np

c = RRN.ConnectService('rr+tcp://localhost:58651?service=robot')

robot_info = c.robot_info
print(robot_info)

print(c.robot_state.PeekInValue()[0].command_mode)

robot_const = RRN.GetConstants("com.robotraconteur.robotics.robot", c)

halt_mode = robot_const["RobotCommandMode"]["halt"]
jog_mode = robot_const["RobotCommandMode"]["jog"]

c.command_mode = halt_mode
time.sleep(0.1)
c.command_mode = jog_mode

joint_diff = np.array([-5,0,0,0,0,5,0])*np.deg2rad(1)
joint_vel = np.array([5.0,1,1,1,1,1])

for i in range(5):
t = time.time()
print("Begin move")
c.jog_freespace(np.deg2rad([15,0,0,0,0,0]), joint_vel, True)
print("done")
time.sleep(0.5)
print(hex(c.robot_state.PeekInValue()[0].robot_state_flags))
print("Begin move")
c.jog_freespace(np.deg2rad([-15,0,0,0,0,0]), joint_vel, True)
print("Done")
print(hex(c.robot_state.PeekInValue()[0].robot_state_flags))
time.sleep(0.5)
from RobotRaconteur.Client import *
import time
import numpy as np

c = RRN.ConnectService('rr+tcp://localhost:58651?service=robot')

robot_info = c.robot_info
print(robot_info)

print(c.robot_state.PeekInValue()[0].command_mode)

robot_const = RRN.GetConstants("com.robotraconteur.robotics.robot", c)

halt_mode = robot_const["RobotCommandMode"]["halt"]
jog_mode = robot_const["RobotCommandMode"]["jog"]

c.command_mode = halt_mode
time.sleep(0.1)
c.command_mode = jog_mode

joint_diff = np.array([-5, 0, 0, 0, 0, 5, 0]) * np.deg2rad(1)
joint_vel = np.array([5.0, 1, 1, 1, 1, 1])

for i in range(5):
t = time.time()
print("Begin move")
c.jog_freespace(np.deg2rad([15, 0, 0, 0, 0, 0]), joint_vel, True)
print("done")
time.sleep(0.5)
print(hex(c.robot_state.PeekInValue()[0].robot_state_flags))
print("Begin move")
c.jog_freespace(np.deg2rad([-15, 0, 0, 0, 0, 0]), joint_vel, True)
print("Done")
print(hex(c.robot_state.PeekInValue()[0].robot_state_flags))
time.sleep(0.5)
Loading

0 comments on commit a7f0d3c

Please sign in to comment.