Skip to content

Commit

Permalink
Paper Freeze (#2)
Browse files Browse the repository at this point in the history
* Refactor: cleanup; add install/run instructions

* Fix: correct repo name at top of README.md
  • Loading branch information
LuckierDodge authored Oct 11, 2023
1 parent 69cee67 commit 8171791
Show file tree
Hide file tree
Showing 16 changed files with 1,806 additions and 1,614 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.vscode
24 changes: 24 additions & 0 deletions Makefile
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
24 changes: 22 additions & 2 deletions README.md
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.
77 changes: 40 additions & 37 deletions pf400_driver/errors.py
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])

Loading

0 comments on commit 8171791

Please sign in to comment.