robert-py 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robert_py-0.0.1/.github/workflows/ci-cd.yml +32 -0
- robert_py-0.0.1/.gitignore +2 -0
- robert_py-0.0.1/PKG-INFO +14 -0
- robert_py-0.0.1/README.md +2 -0
- robert_py-0.0.1/pyproject.toml +28 -0
- robert_py-0.0.1/src/robert/__init__.py +0 -0
- robert_py-0.0.1/src/robert/client.py +38 -0
- robert_py-0.0.1/src/robert/protocol.py +36 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build-and-publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
id-token: write
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout Code
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.x"
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install build
|
|
27
|
+
|
|
28
|
+
- name: Build Package
|
|
29
|
+
run: python -m build
|
|
30
|
+
|
|
31
|
+
- name: Publish to PyPI
|
|
32
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
robert_py-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: robert-py
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Python library to interact with RobeRT server.
|
|
5
|
+
Project-URL: Homepage, https://github.com/JuanSobalvarro/RobeRT_client
|
|
6
|
+
Author-email: Juan Sobalvarro <sobalvarrog.juans@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Requires-Python: >=3.14
|
|
10
|
+
Requires-Dist: pyzmq>=27.0.1
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# RobeRT Client
|
|
14
|
+
This is the python client for RobeRT (middleware for ABB robots)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling >= 1.26"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "robert-py"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Juan Sobalvarro", email = "sobalvarrog.juans@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "A Python library to interact with RobeRT server."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.14"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
]
|
|
17
|
+
license = "MIT"
|
|
18
|
+
license-files = ["LICENSE"]
|
|
19
|
+
|
|
20
|
+
dependencies = [
|
|
21
|
+
"pyzmq>=27.0.1"
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/JuanSobalvarro/RobeRT_client"
|
|
26
|
+
|
|
27
|
+
[tool.hatch.build.targets.wheel]
|
|
28
|
+
packages = ["src/robert-py"]
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import List, Any
|
|
2
|
+
import zmq
|
|
3
|
+
from robert.protocol import Commands, RobTarget
|
|
4
|
+
|
|
5
|
+
class RobeRTClient:
|
|
6
|
+
def __init__(self, endpoint: str, timeout: int = 5000):
|
|
7
|
+
self.context = zmq.Context()
|
|
8
|
+
self.socket = self.context.socket(zmq.REQ)
|
|
9
|
+
self.socket.setsockopt(zmq.RCVTIMEO, timeout)
|
|
10
|
+
self.endpoint = endpoint
|
|
11
|
+
|
|
12
|
+
def connect(self):
|
|
13
|
+
self.socket.connect(self.endpoint)
|
|
14
|
+
|
|
15
|
+
def _request(self, message: str) -> str:
|
|
16
|
+
try:
|
|
17
|
+
self.socket.send_string(message)
|
|
18
|
+
|
|
19
|
+
response = self.socket.recv_string()
|
|
20
|
+
|
|
21
|
+
return response
|
|
22
|
+
except zmq.Again:
|
|
23
|
+
return "ERROR: Timeout while waiting for response"
|
|
24
|
+
|
|
25
|
+
def _format_message(self, elements: List[Any]) -> str:
|
|
26
|
+
"""
|
|
27
|
+
This method formats a list of elements into a string message that can be sent to the server. in the format of
|
|
28
|
+
"e1|e2|...|en" where e1, e2, ..., en are the string representations of the elements in the list. Always starting with the command as the first element.
|
|
29
|
+
For example, if the command is "MOVEJ" and the target is a RobTarget object, the message would be "MOVEJ|target"
|
|
30
|
+
* Important: Each element should have a __str__ method that returns a string representation of the element.
|
|
31
|
+
"""
|
|
32
|
+
return "|".join(str(element) for element in elements if element is not None)
|
|
33
|
+
|
|
34
|
+
def movej(self, target: RobTarget) -> str:
|
|
35
|
+
return self._request(self._format_message([Commands.MOVEJ, target]))
|
|
36
|
+
|
|
37
|
+
def ping(self) -> str:
|
|
38
|
+
return self._request(self._format_message([Commands.PING]))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Commands:
|
|
5
|
+
MOVEL = "MOVEL"
|
|
6
|
+
MOVEJ = "MOVEJ"
|
|
7
|
+
MOVEABSJ = "MOVEABSJ"
|
|
8
|
+
MOVEC = "MOVEC"
|
|
9
|
+
PING = "PING"
|
|
10
|
+
PINGR = "PINGR"
|
|
11
|
+
EXIT = "EXIT"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class RobTarget:
|
|
16
|
+
x: float
|
|
17
|
+
y: float
|
|
18
|
+
z: float
|
|
19
|
+
q1: float
|
|
20
|
+
q2: float
|
|
21
|
+
q3: float
|
|
22
|
+
q4: float
|
|
23
|
+
cf1: int
|
|
24
|
+
cf4: int
|
|
25
|
+
cf6: int
|
|
26
|
+
cfx: int
|
|
27
|
+
|
|
28
|
+
def to_list(self):
|
|
29
|
+
return [self.x, self.y, self.z, self.q1, self.q2, self.q3, self.q4,
|
|
30
|
+
self.cf1, self.cf4, self.cf6, self.cfx]
|
|
31
|
+
|
|
32
|
+
def to_csv(self):
|
|
33
|
+
return ",".join(str(value) for value in self.to_list())
|
|
34
|
+
|
|
35
|
+
def __str__(self):
|
|
36
|
+
return self.to_csv()
|