-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor: cleanup; add install/run instructions * Fix: correct repo name at top of README.md
- Loading branch information
1 parent
69cee67
commit 8171791
Showing
16 changed files
with
1,806 additions
and
1,614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.DEFAULT_GOAL := all | ||
isort = python -m isort . | ||
black = python -m black --target-version py39 . | ||
|
||
.PHONY: format | ||
format: | ||
$(isort) | ||
$(black) | ||
|
||
.PHONY: lint | ||
lint: | ||
$(black) --check --diff | ||
python -m flake8 . | ||
python -m pydocstyle . --count | ||
|
||
|
||
|
||
.PHONY: mypy | ||
mypy: | ||
mypy --config-file setup.cfg --package . | ||
mypy --config-file setup.cfg . | ||
|
||
.PHONY: all | ||
all: format lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,22 @@ | ||
# pf400_driver | ||
Driver for communicating with the PF400 | ||
# pf400_module | ||
|
||
Driver for communicating with the PF400. | ||
|
||
## Installation | ||
|
||
``` | ||
git clone https://github.com/AD-SDL/pf400_module.git | ||
cd pf400_module | ||
pip install -r requirements.txt | ||
pip install -e . | ||
``` | ||
|
||
## Running the PF400 Module | ||
|
||
In `/scripts`, run the following | ||
|
||
``` | ||
python3 pf400_rest_client.py --host=<hostname> --port 3000 --alias pf400 | ||
``` | ||
|
||
You can use `0.0.0.0` as the hostname to connect from any device on the local network. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,57 @@ | ||
|
||
class ConnectionException(Exception): | ||
def __init__(self, err_message = "error"): | ||
def __init__(self, err_message="error"): | ||
# Call the base class constructor with the parameters it needs | ||
super(ConnectionException, self).__init__("Could not establish connection! Error type: " + err_message) | ||
super(ConnectionException, self).__init__( | ||
"Could not establish connection! Error type: " + err_message | ||
) | ||
|
||
|
||
class CommandException(Exception): | ||
def __init__(self, err_message = "error"): | ||
def __init__(self, err_message="error"): | ||
super(CommandException, self).__init__( | ||
"Invalid command! Check if communication is open. Error type: " + err_message | ||
"Invalid command! Check if communication is open. Error type: " | ||
+ err_message | ||
) | ||
|
||
|
||
class ErrorResponse(Exception): | ||
"""Error during command execution..""" | ||
|
||
@staticmethod | ||
def from_error_code(error: str): | ||
error_codes = { | ||
"-1009":"*No robot attached*", | ||
"-1012":"*Joint out-of-range* Set robot joints within their range", | ||
"-1039":"*Position too close* Robot 1", | ||
"-1040":"*Position too far* Robot 1", | ||
"-1042":"*Can't change robot config* Robot 1", | ||
"-1046":"*Power not enabled*", | ||
"-1600":"*Power off requested*", | ||
"-2800":"*Warning Parameter Mismatch*", | ||
"-2801":"*Warning No Parameters", | ||
"-2802":"*Warning Illegal move command*", | ||
"-2803":"*Warning Invalid joint angles*", | ||
"-2804":"*Warning: Invalid Cartesian coordinate values*", | ||
"-2805":"*Unknown command* ", | ||
"-2806":"*Command Exception*", | ||
"-2807":"*Warning cannot set Input states*", | ||
"-2808":"*Not allowed by this thread*", | ||
"-2809":"*Invalid robot type*", | ||
"-2810":"*Invalid serial command*", | ||
"-2811":"*Invalid robot number*", | ||
"-2812":"*Robot already selected*", | ||
"-2813":"*Module not initialized*", | ||
"-2814":"*Invalid location index*", | ||
"-2816":"*Undefined location*", | ||
"-2817":"*Undefined profile*", | ||
"-2818":"*Undefined pallet*", | ||
"-2819":"*Pallet not supported*", | ||
"-2820":"*Invalid station index*", | ||
"-2821":"*Undefined station*", | ||
"-2822":"*Not a pallet*", | ||
"-2823":"*Not at pallet origin*", | ||
"-3122":"*Soft envelope error* Robot 1: 1" | ||
"-1009": "*No robot attached*", | ||
"-1012": "*Joint out-of-range* Set robot joints within their range", | ||
"-1039": "*Position too close* Robot 1", | ||
"-1040": "*Position too far* Robot 1", | ||
"-1042": "*Can't change robot config* Robot 1", | ||
"-1046": "*Power not enabled*", | ||
"-1600": "*Power off requested*", | ||
"-2800": "*Warning Parameter Mismatch*", | ||
"-2801": "*Warning No Parameters", | ||
"-2802": "*Warning Illegal move command*", | ||
"-2803": "*Warning Invalid joint angles*", | ||
"-2804": "*Warning: Invalid Cartesian coordinate values*", | ||
"-2805": "*Unknown command* ", | ||
"-2806": "*Command Exception*", | ||
"-2807": "*Warning cannot set Input states*", | ||
"-2808": "*Not allowed by this thread*", | ||
"-2809": "*Invalid robot type*", | ||
"-2810": "*Invalid serial command*", | ||
"-2811": "*Invalid robot number*", | ||
"-2812": "*Robot already selected*", | ||
"-2813": "*Module not initialized*", | ||
"-2814": "*Invalid location index*", | ||
"-2816": "*Undefined location*", | ||
"-2817": "*Undefined profile*", | ||
"-2818": "*Undefined pallet*", | ||
"-2819": "*Pallet not supported*", | ||
"-2820": "*Invalid station index*", | ||
"-2821": "*Undefined station*", | ||
"-2822": "*Not a pallet*", | ||
"-2823": "*Not at pallet origin*", | ||
"-3122": "*Soft envelope error* Robot 1: 1", | ||
} | ||
if error not in error_codes: | ||
return ErrorResponse(f"Unknown error code: {error}") | ||
return ErrorResponse(error_codes[error]) | ||
|
Oops, something went wrong.