Skip to content
Snippets Groups Projects
Verified Commit 59dfe7f6 authored by Anton Tetov Johansson's avatar Anton Tetov Johansson
Browse files

Installation docs and examples

parent 2a4119dd
Branches
Tags
No related merge requests found
# ur-py-ctl
# ur_py_ctl
[![PyPI version](https://badge.fury.io/py/ur-py-ctl.svg)](https://pypi.org/project/ur-py-ctl/)
[![CI Pipeline status](https://gitlab.control.lth.se/robotlab/ur_py_ctl/badges/main/pipeline.svg)](https://gitlab.control.lth.se/robotlab/ur_py_ctl/-/pipelines)
......@@ -6,6 +6,10 @@
* [Documentation](https://ur-py-ctl.readthedocs.io/)
## Install
[Installation instructions](https://ur-py-ctl.readthedocs.io/latest/installation.html)
## Develop
1. [Install poetry](https://python-poetry.org/docs/#installation)
......
# Examples
## Generate URScript
```{literalinclude} examples/generate_urscript.py
```
## Send script without feedback
```{literalinclude} examples/send_script_wo_feedback.py
```
## Send script with feedback
```{note}
TODO: Make better version of [old send_file.py](https://gitlab.control.lth.se/robotlab/ur_py_ctl/-/blob/2a4119dd539067d3803b86e41e974813342a5d5a/ur_py_ctl/send_script.py)
```
import math
from ur_py_ctl import Motion, move_to_conf, move_to_pose
# rotate joint0 to 45 degrees and the rest to zero moving 10 degrees/s
move_instruction1 = move_to_conf([math.pi / 2, 0, 0, 0, 0, 0], v=math.radians(10))
# move to coordinate .250, .500, .300 in a straight line with blend radius 1 cm
# and 250 mm/s
move_instruction2 = move_to_pose(
0.25, 0.5, 0.3, 0, 0, 0, mode=Motion.LINEAR, r=0.01, v=0.25
)
print(move_instruction1)
print(move_instruction2)
import logging
import socket
import ur_py_ctl.urscript_commands as ur_cmd
TAB = " "
SERVER_ADRESS = "marius-vikarie.d.control.lth.se"
SERVER_PORT = 30002
def get_script():
script = "def program():\n"
script += TAB + ur_cmd.popup("Program starting.") + "\n"
script += TAB + ur_cmd.set_tcp(0, 0, 0, 0, 0, 0) + "\n"
for i in range(10):
script += (
TAB
+ ur_cmd.move_to_pose(
-0.1 + i * 0.01, 0, 0.3, 0, 0, 0, v=50 / 1000, r=5 / 1000
)
+ "\n"
)
script += TAB + ur_cmd.text_msg(f"Sending command number: {i}") + "\n"
script += ur_cmd.text_msg("End program")
script += "end\n\n"
script += "program()\n"
return script.encode()
def send_script():
send_socket = socket.create_connection((SERVER_ADRESS, SERVER_PORT), timeout=2)
send_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
script = get_script()
# send file
send_socket.send(script)
send_socket.close()
logging.debug("File sent")
if __name__ == "__main__":
send_script()
......@@ -5,6 +5,7 @@
maxdepth: 1
caption: Contents
---
installation
examples
reference
```
# Installation instructions
This package is intended to be used as a library, and should be installed into
a python environment and imported into the users own code.
Python includes a tool for creating environments called {py:mod}`venv`.
Anaconda is another alternative that is especially useful on Windows since it
does not only deal with Python dependencies but C/C++ dependencies and more.
Popular packages such as NumPy and OpenCV has non-Python deps that can be
managed using [Anaconda](https://www.anaconda.com/) or some other good package manager.
```{tip}
Anaconda is cross platform and solves a lot of dependency headaches. Together
with an IDE like VS Code (also cross platform and well suited for Python) is a
good starting point.
There is a very helpful guide to get started on VS Code's documentation website
titled
[Getting Started with Python in VS Code](https://code.visualstudio.com/docs/python/python-tutorial)
```
## Set up environment
### Using Anaconda
```bash
conda config --add channels conda-forge
conda create -n my_project python=3.10
conda activate my_project
```
### Using `virtualenv`
```bash
virtualenv --python=python3.8 {{path/to/venv}}
source {{path/to/venv}}/bin/activate
```
## Install package
### Latest release
```bash
pip install ur_py_ctl
```
### Latest commit
```bash
pip install git+https://gitlab.control.lth.se/robotlab/ur_py_ctl
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment