YAROK - Yet another robot framework
Project description
YAROK - Yet another robot framework
A Python library for interfacing with sensors and actuators, and composing robots and robotic environments. Aimed for quick prototyping, learning, researching, etc.
Key features of Yarok:
- Modularity through components.
- Environment independent control logic.
With Yarok you can:
- Write driver components, for sensors and actuators, with different interfaces for real world and MuJoCo environments.
- Compose robots and robotic environments from driver components.
- Use components from others and/or share your own.
- Write generic python scripts for controlling such robots e.g. RL Algorithms.
- Run experiments in simulation (in MuJoCo) and/or real robots interchangeably.
Install
pip3 install yarok
run the EmptyWorld example from the terminal,
yarok run EmptyWorld
or from code,
# main.py
yarok.run(EmptyWorld, {
'platform_args': {
'viewer_mode': sys.argv[1]
}
})
yarok run main
Example components
We host here some components for reducing any friction with getting started with the library, if you would like us to include/reference yours here let us know.
Sensors
Name | Description |
---|---|
cam | Wraps the py_mujoco and OpenCV APIs for handling generic cameras. |
gelsight2014 | The optical tactile sensor as proposed in Rui Li et al. and the simulation model proposed in Gomes et al. |
geltip | The finger-shaped tactile sensor as proposed in Gomes et al. and simulation model |
Actuators
Name | Description |
---|---|
anet_a30 | FFF 3D printer modeled after the Geeetech ANET A30 (or Creality CR-10) to be used as 3 DoF a cartesian actuator. Real hardware via serial (USB). |
ur5 | The 6 DoF Universal Robots UR5. Real hardware via python-urx library. |
robotiq_2f85 | The Robotiq 2F-85 gripper. Real hardware via python-urx and the UR5 computer. |
Environments
Name | Description |
---|---|
anet_a30 | FFF 3D printer modeled after the Geeetech ANET A30 (or Creality CR-10) to be used as 3 DoF a cartesian actuator. Real hardware via serial (USB). |
ur5 | The 6 DoF Universal Robots UR5. Real hardware via python-urx library. |
robotiq_2f85 | The Robotiq 2F-85 gripper. Real hardware via python-urx and the UR5 computer. |
Getting started
The key concept in Yarok is the component. A component represents one part of your robotic setup, and is composed of:
Name | Description |
---|---|
Model description | The component is described/modeled in .xml, using the yarok-extended MJCF format (from MuJoCo). Then, you can include this component in the description of other components to build full robots or environments. At runtime, Yarok handles the nesting of components, etc. |
Controller | Its the Python class that serves has the common interface for the component in all environments, and can access the controllers of its children components, that are nested in its .xml. Yarok autonomously instantiates and links parent-child controllers. |
Interface | MuJoCo (interface_mjc) or Real Hardware (interface_hw) interface. It serves as a proxy between the controller and the environment. Before instantiating the component Controller, Yarok merges the appropriate environment interface with the controller class, effectively becoming one. Thus, the controller should declare the interface(s) common public methods (api) as empty/pass. |
Model description, using the Yarok-extended MJCF
All paths for meshes are relative to the component directory.
To nest a component onto its parent, the following macro can be used as an MJCF body element
Name | Description |
---|---|
tag name | The name of the component class. Same as the .xml and .py filenames. |
@name | The name/id of the component instance. |
@parent | When sub-nesting (check example) declares the name of the parent's link where to nest into. |
Here we describe the extensions on top of the MJCF language, for the full documentation of MJCF check the MuJoCo XML reference.
An example component would look like:
../example/example.xml
``
../example/example.py
### The controller
@component( components=[ UR5, robotiq_2f85, gelsight2014, geltip, AnetA30, Cam ], interface_mjc=EmptyWorldInterfaceMJC ) ``
You can run the environment using the Yarok cli and/or programmatically. Cli.
Programmatic Yarok API
Name | Description |
---|---|
load | Loads the environment, instantiates components and links parent-child controllers |
run | Same as load, but runs the environment infinitly with a "while true, pass" loop |
CLI Yarok API
Creating simple RL environment
Depending on the application, we have 3 suggestions
- write an environment component that simply represents the "hardware" and have the control logic in your experimental script
- write a dedicated RL environment,
- or even just extend our RL boilerplate class (RLBase).
Here, the control logic in the main script
platform, manager = yarok.load(Env, ...)
ur5 = manager.get('ur5')
while True:
st = [ur5.z]
r = reward(st)
a = ...
ur5.move(a)
platform.step()
Here, a parameterized component is written to hold the reward function (task definition), observation vector, etc. The RL algorithm still goes in the main script.
@Component({
UR5
})
class TaskEnv:
def __init__(self, task, ur5):
self.task = task
self.ur5 = ur5
def state(self):
""" Return the state representation
return [ur5.xyz]
def reward(self):
if self.task == 'the_task':
return ... your reward fn ...
platform, manager = yarok.load(RLEnv, {
...
task: 'the_task'
})
ur5 = manager.get(TaskEnv)
while True:
r = reward(st)
a = ...
ur5.move(a)
platform.step()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file yarok-0.0.14.tar.gz
.
File metadata
- Download URL: yarok-0.0.14.tar.gz
- Upload date:
- Size: 9.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.1 importlib-metadata/4.11.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de51c7cd409fdea2d3feb4070666a0f746b878bd297bf90094c128030b10222f |
|
MD5 | a58543070b814fa2e45ecbb5ee3c9528 |
|
BLAKE2b-256 | d3fd6869edd17185b6965b2cc0e9b907db451803b578db915386af7dfacc1c64 |
File details
Details for the file yarok-0.0.14-py3-none-any.whl
.
File metadata
- Download URL: yarok-0.0.14-py3-none-any.whl
- Upload date:
- Size: 7.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.1 importlib-metadata/4.11.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0844720bebb59edfc01721c32f610944fd8eca612abcf272d2d067e9558adf26 |
|
MD5 | fe642464add8a2d0113ccc4cd16df9c6 |
|
BLAKE2b-256 | 9eae9dee767da5cbd8ddd6e2afecbc62d4080940177c1f4f9ca3c14b98d8513d |