Skip to content

Commit 8171791

Browse files
Paper Freeze (#2)
* Refactor: cleanup; add install/run instructions * Fix: correct repo name at top of README.md
1 parent 69cee67 commit 8171791

16 files changed

+1806
-1614
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
162+
.vscode

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.DEFAULT_GOAL := all
2+
isort = python -m isort .
3+
black = python -m black --target-version py39 .
4+
5+
.PHONY: format
6+
format:
7+
$(isort)
8+
$(black)
9+
10+
.PHONY: lint
11+
lint:
12+
$(black) --check --diff
13+
python -m flake8 .
14+
python -m pydocstyle . --count
15+
16+
17+
18+
.PHONY: mypy
19+
mypy:
20+
mypy --config-file setup.cfg --package .
21+
mypy --config-file setup.cfg .
22+
23+
.PHONY: all
24+
all: format lint

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
1-
# pf400_driver
2-
Driver for communicating with the PF400
1+
# pf400_module
2+
3+
Driver for communicating with the PF400.
4+
5+
## Installation
6+
7+
```
8+
git clone https://github.com/AD-SDL/pf400_module.git
9+
cd pf400_module
10+
pip install -r requirements.txt
11+
pip install -e .
12+
```
13+
14+
## Running the PF400 Module
15+
16+
In `/scripts`, run the following
17+
18+
```
19+
python3 pf400_rest_client.py --host=<hostname> --port 3000 --alias pf400
20+
```
21+
22+
You can use `0.0.0.0` as the hostname to connect from any device on the local network.

pf400_driver/errors.py

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,57 @@
1-
21
class ConnectionException(Exception):
3-
def __init__(self, err_message = "error"):
2+
def __init__(self, err_message="error"):
43
# Call the base class constructor with the parameters it needs
5-
super(ConnectionException, self).__init__("Could not establish connection! Error type: " + err_message)
4+
super(ConnectionException, self).__init__(
5+
"Could not establish connection! Error type: " + err_message
6+
)
7+
68

79
class CommandException(Exception):
8-
def __init__(self, err_message = "error"):
10+
def __init__(self, err_message="error"):
911
super(CommandException, self).__init__(
10-
"Invalid command! Check if communication is open. Error type: " + err_message
12+
"Invalid command! Check if communication is open. Error type: "
13+
+ err_message
1114
)
1215

16+
1317
class ErrorResponse(Exception):
1418
"""Error during command execution.."""
1519

1620
@staticmethod
1721
def from_error_code(error: str):
1822
error_codes = {
19-
"-1009":"*No robot attached*",
20-
"-1012":"*Joint out-of-range* Set robot joints within their range",
21-
"-1039":"*Position too close* Robot 1",
22-
"-1040":"*Position too far* Robot 1",
23-
"-1042":"*Can't change robot config* Robot 1",
24-
"-1046":"*Power not enabled*",
25-
"-1600":"*Power off requested*",
26-
"-2800":"*Warning Parameter Mismatch*",
27-
"-2801":"*Warning No Parameters",
28-
"-2802":"*Warning Illegal move command*",
29-
"-2803":"*Warning Invalid joint angles*",
30-
"-2804":"*Warning: Invalid Cartesian coordinate values*",
31-
"-2805":"*Unknown command* ",
32-
"-2806":"*Command Exception*",
33-
"-2807":"*Warning cannot set Input states*",
34-
"-2808":"*Not allowed by this thread*",
35-
"-2809":"*Invalid robot type*",
36-
"-2810":"*Invalid serial command*",
37-
"-2811":"*Invalid robot number*",
38-
"-2812":"*Robot already selected*",
39-
"-2813":"*Module not initialized*",
40-
"-2814":"*Invalid location index*",
41-
"-2816":"*Undefined location*",
42-
"-2817":"*Undefined profile*",
43-
"-2818":"*Undefined pallet*",
44-
"-2819":"*Pallet not supported*",
45-
"-2820":"*Invalid station index*",
46-
"-2821":"*Undefined station*",
47-
"-2822":"*Not a pallet*",
48-
"-2823":"*Not at pallet origin*",
49-
"-3122":"*Soft envelope error* Robot 1: 1"
23+
"-1009": "*No robot attached*",
24+
"-1012": "*Joint out-of-range* Set robot joints within their range",
25+
"-1039": "*Position too close* Robot 1",
26+
"-1040": "*Position too far* Robot 1",
27+
"-1042": "*Can't change robot config* Robot 1",
28+
"-1046": "*Power not enabled*",
29+
"-1600": "*Power off requested*",
30+
"-2800": "*Warning Parameter Mismatch*",
31+
"-2801": "*Warning No Parameters",
32+
"-2802": "*Warning Illegal move command*",
33+
"-2803": "*Warning Invalid joint angles*",
34+
"-2804": "*Warning: Invalid Cartesian coordinate values*",
35+
"-2805": "*Unknown command* ",
36+
"-2806": "*Command Exception*",
37+
"-2807": "*Warning cannot set Input states*",
38+
"-2808": "*Not allowed by this thread*",
39+
"-2809": "*Invalid robot type*",
40+
"-2810": "*Invalid serial command*",
41+
"-2811": "*Invalid robot number*",
42+
"-2812": "*Robot already selected*",
43+
"-2813": "*Module not initialized*",
44+
"-2814": "*Invalid location index*",
45+
"-2816": "*Undefined location*",
46+
"-2817": "*Undefined profile*",
47+
"-2818": "*Undefined pallet*",
48+
"-2819": "*Pallet not supported*",
49+
"-2820": "*Invalid station index*",
50+
"-2821": "*Undefined station*",
51+
"-2822": "*Not a pallet*",
52+
"-2823": "*Not at pallet origin*",
53+
"-3122": "*Soft envelope error* Robot 1: 1",
5054
}
5155
if error not in error_codes:
5256
return ErrorResponse(f"Unknown error code: {error}")
5357
return ErrorResponse(error_codes[error])
54-

0 commit comments

Comments
 (0)