Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1a0f42d
refactor(env): sim specific gripper func into own wrapper
juelg May 9, 2025
40f1ecf
refactor(control): remove app code
juelg May 9, 2025
6cd4f62
refactor: removed unsued recordings
juelg May 9, 2025
d631e93
refactor: remove unused n robots class
juelg May 9, 2025
0244fd7
refactor: rename resource manager to context manager
juelg May 9, 2025
75fe8cf
refactor(env): renamed factories to creators
juelg May 9, 2025
39b99eb
refactor(env): factory functions into env creators
juelg May 9, 2025
67533e0
moved creators to the correct location
juelg May 9, 2025
6332a2c
refactor: rename quart to quat
juelg May 9, 2025
cb7b5ac
refactor: rename motion generator
juelg May 9, 2025
ff81bcc
refactor: removed unused robotwithgripper class
juelg May 9, 2025
3604951
refactor(cpp): sim independent of robot type
juelg May 9, 2025
8686804
undo Vectord to Vector7d
juelg May 9, 2025
1843345
refactor: rename sim robot classes pybind
juelg May 9, 2025
c388ef0
updated generated stubs
juelg May 9, 2025
f79c032
refactor: rename rcs sim classes in python
juelg May 10, 2025
7ca6b52
refactor: renaming of env creator classes
juelg May 12, 2025
501f24e
refactor: rename FR3Env to RobotEnv
juelg May 12, 2025
024df2c
refactor: Flexible dof and robot meta config
juelg May 14, 2025
f31e823
refactor: traj interpolator in same style
juelg May 14, 2025
95a32fb
refactor: renamed bindings file to rcs.cpp
juelg May 14, 2025
e883154
refactor: renamed rcsss python folder to rcs
juelg May 14, 2025
00b8ac9
refactor: renamed imports and all other occurrences rcsss -> rcs
juelg May 14, 2025
fa0aa5c
refactor: stubs and ik solver rename to fit rcs package
juelg May 14, 2025
3880417
style: fix cpp format
juelg May 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Test realsense",
"type": "debugpy",
"request": "launch",
"module": "rcsss",
"module": "rcs",
"console": "integratedTerminal",
"args": ["realsense", "test", "config.yaml"],
"justMyCode": true,
Expand All @@ -17,7 +17,7 @@
"name": "Record with realsense",
"type": "debugpy",
"request": "launch",
"module": "rcsss",
"module": "rcs",
"console": "integratedTerminal",
"args": ["realsense", "test-record", "config.yaml"],
"justMyCode": true,
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ clangcompile:

# Auto generation of CPP binding stub files
stubgen:
pybind11-stubgen -o python --numpy-array-use-type-var rcsss
pybind11-stubgen -o python --numpy-array-use-type-var rcs
find ./python -name '*.pyi' -print | xargs sed -i '1s/^/# ATTENTION: auto generated from C++ code, use `make stubgen` to update!\n/'
find ./python -not -path "./python/rcsss/_core/*" -name '*.pyi' -delete
find ./python/rcsss/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[typing\.Literal\[\([0-9]\+\)\], typing\.Literal\[1\]\]/typing\.Literal[\1]/g'
find ./python/rcsss/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[\([M|N]\), typing\.Literal\[1\]\]/\1/g'
ruff check --fix python/rcsss/_core
isort python/rcsss/_core
black python/rcsss/_core
find ./python -not -path "./python/rcs/_core/*" -name '*.pyi' -delete
find ./python/rcs/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[typing\.Literal\[\([0-9]\+\)\], typing\.Literal\[1\]\]/typing\.Literal[\1]/g'
find ./python/rcs/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[\([M|N]\), typing\.Literal\[1\]\]/\1/g'
ruff check --fix python/rcs/_core
isort python/rcs/_core
black python/rcs/_core

# Python
pycheckformat:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ pip install -ve .
```

## Usage
The python package is called `rcsss` (sss because of the sound of a snake).
The python package is called `rcs`.
Import the library in python:
```python
import rcsss
import rcs
```
Checkout the python examples that we provide in [python/examples](python/examples):
- [fr3.py](python/examples/fr3.py) shows direct robot control with RCS's python bindings
- [env_joint_control.py](python/examples/env_joint_control.py) and [env_cartesian_control.py](python/examples/env_cartesian_control.py) demonstrates RCS's high level [gymnasium](https://gymnasium.farama.org/) interface both for joint- and end effector space control
All of these examples work both in the MuJoCo simulation as well as on your hardware FR3.
Just switch between the following settings in the example script
```python
ROBOT_INSTANCE = RobotInstance.SIMULATION
# ROBOT_INSTANCE = RobotInstance.HARDWARE
ROBOT_INSTANCE = RobotPlatform.SIMULATION
# ROBOT_INSTANCE = RobotPlatform.HARDWARE
```
and add your robot credentials to a `.env` file like this:
```env
Expand All @@ -49,7 +49,7 @@ DESK_PASSWORD=...
The package includes a command line interface which define useful commands to handle the FR3 robot without the need to use the Desk Website.
To list all available subcommands use:
```shell
python -m rcsss --help
python -m rcs --help
```

## Development
Expand All @@ -71,7 +71,7 @@ make pytest
```

### Stub Files for Python Bindings
We use autogenerated python stub files (`.pyi`) in the [`_core`](python/rcsss/_core/) folder to show our linters the expected types of the C++ Python bindings.
We use autogenerated python stub files (`.pyi`) in the [`_core`](python/rcs/_core/) folder to show our linters the expected types of the C++ Python bindings.
If the python bindings in the C++ code have changed you might need to regenerate them by using:
```shell
make stubgen
Expand Down
4 changes: 2 additions & 2 deletions cmake/compile_scenes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ foreach(scene_dir ${scene_dirs})
list(APPEND mjb_files ${scene_mjb})

# Install scene files
install(FILES ${scene_mjb} DESTINATION rcsss/scenes/${scene_name} COMPONENT python_package)
install(FILES ${scene_mjb} DESTINATION rcs/scenes/${scene_name} COMPONENT python_package)

# Install URDF files
file(GLOB_RECURSE urdfs ${scene_dir}/*.urdf)
foreach(urdf ${urdfs})
install(FILES ${urdf} DESTINATION rcsss/scenes/${scene_name} COMPONENT python_package)
install(FILES ${urdf} DESTINATION rcs/scenes/${scene_name} COMPONENT python_package)
endforeach()
endforeach()

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = []
build-backend = "scikit_build_core.build"

[project]
name = "rcsss"
name = "rcs"
version = "0.4.0"
description="Python Interface for libfranka to control the Franka Research 3 Robot"
dependencies = ["websockets>=11.0",
Expand Down Expand Up @@ -60,7 +60,7 @@ build.verbose = true
build.targets = ["_core", "utn_scenes"]
logging.level = "INFO"
build-dir = "build"
wheel.packages = ["python/rcsss"]
wheel.packages = ["python/rcs"]
install.components = ["python_package"]

[tool.ruff]
Expand Down Expand Up @@ -147,5 +147,5 @@ update_changelog_on_bump = true
major_version_zero = true
version_files = [
"CMakeLists.txt:VERSION",
"python/rcsss/_core/__init__.pyi:__version__",
"python/rcs/_core/__init__.pyi:__version__",
]
44 changes: 22 additions & 22 deletions python/examples/env_cartesian_control.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging

from rcsss.control.fr3_desk import FCI, Desk, DummyResourceManager
from rcsss.control.utils import load_creds_fr3_desk
from rcsss.envs.base import ControlMode, RelativeTo, RobotInstance
from rcsss.envs.factories import fr3_hw_env, fr3_sim_env
from rcsss.envs.utils import (
from rcs._core.common import RobotPlatform
from rcs.control.fr3_desk import FCI, ContextManager, Desk, load_creds_fr3_desk
from rcs.envs.base import ControlMode, RelativeTo
from rcs.envs.creators import RCSFR3EnvCreator, RCSSimEnvCreator
from rcs.envs.utils import (
default_fr3_hw_gripper_cfg,
default_fr3_hw_robot_cfg,
default_fr3_sim_gripper_cfg,
Expand All @@ -16,7 +16,7 @@
logger.setLevel(logging.INFO)

ROBOT_IP = "192.168.101.1"
ROBOT_INSTANCE = RobotInstance.SIMULATION
ROBOT_INSTANCE = RobotPlatform.SIMULATION


"""
Expand All @@ -26,44 +26,44 @@

When you use a real FR3 you first need to unlock its joints using the following cli script:

python -m rcsss fr3 unlock <ip>
python -m rcs fr3 unlock <ip>

or put it into guiding mode using:

python -m rcsss fr3 guiding-mode <ip>
python -m rcs fr3 guiding-mode <ip>

When you are done you lock it again using:

python -m rcsss fr3 lock <ip>
python -m rcs fr3 lock <ip>

or even shut it down using:

python -m rcsss fr3 shutdown <ip>
python -m rcs fr3 shutdown <ip>
"""


def main():
resource_manger: FCI | DummyResourceManager
if ROBOT_INSTANCE == RobotInstance.HARDWARE:
context_manger: ContextManager
if ROBOT_INSTANCE == RobotPlatform.HARDWARE:
user, pw = load_creds_fr3_desk()
resource_manger = FCI(Desk(ROBOT_IP, user, pw), unlock=False, lock_when_done=False)
context_manger = FCI(Desk(ROBOT_IP, user, pw), unlock=False, lock_when_done=False)
else:
resource_manger = DummyResourceManager()
context_manger = ContextManager()

with resource_manger:
if ROBOT_INSTANCE == RobotInstance.HARDWARE:
env_rel = fr3_hw_env(
with context_manger:
if ROBOT_INSTANCE == RobotPlatform.HARDWARE:
env_rel = RCSFR3EnvCreator()(
ip=ROBOT_IP,
control_mode=ControlMode.CARTESIAN_TQuart,
control_mode=ControlMode.CARTESIAN_TQuat,
robot_cfg=default_fr3_hw_robot_cfg(),
collision_guard="lab",
gripper_cfg=default_fr3_hw_gripper_cfg(),
max_relative_movement=0.5,
relative_to=RelativeTo.LAST_STEP,
)
else:
env_rel = fr3_sim_env(
control_mode=ControlMode.CARTESIAN_TQuart,
env_rel = RCSSimEnvCreator()(
control_mode=ControlMode.CARTESIAN_TQuat,
robot_cfg=default_fr3_sim_robot_cfg(),
collision_guard=False,
gripper_cfg=default_fr3_sim_gripper_cfg(),
Expand All @@ -79,14 +79,14 @@ def main():
for _ in range(10):
for _ in range(10):
# move 1cm in x direction (forward) and close gripper
act = {"tquart": [0.01, 0, 0, 0, 0, 0, 1], "gripper": 0}
act = {"tquat": [0.01, 0, 0, 0, 0, 0, 1], "gripper": 0}
obs, reward, terminated, truncated, info = env_rel.step(act)
if truncated or terminated:
logger.info("Truncated or terminated!")
return
for _ in range(10):
# move 1cm in negative x direction (backward) and open gripper
act = {"tquart": [-0.01, 0, 0, 0, 0, 0, 1], "gripper": 1}
act = {"tquat": [-0.01, 0, 0, 0, 0, 0, 1], "gripper": 1}
obs, reward, terminated, truncated, info = env_rel.step(act)
if truncated or terminated:
logger.info("Truncated or terminated!")
Expand Down
36 changes: 18 additions & 18 deletions python/examples/env_joint_control.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging

import numpy as np
from rcsss.control.fr3_desk import FCI, Desk, DummyResourceManager
from rcsss.control.utils import load_creds_fr3_desk
from rcsss.envs.base import ControlMode, RelativeTo, RobotInstance
from rcsss.envs.factories import fr3_hw_env, fr3_sim_env
from rcsss.envs.utils import (
from rcs._core.common import RobotPlatform
from rcs.control.fr3_desk import FCI, ContextManager, Desk, load_creds_fr3_desk
from rcs.envs.base import ControlMode, RelativeTo
from rcs.envs.creators import RCSFR3EnvCreator, RCSSimEnvCreator
from rcs.envs.utils import (
default_fr3_hw_gripper_cfg,
default_fr3_hw_robot_cfg,
default_fr3_sim_gripper_cfg,
Expand All @@ -17,7 +17,7 @@
logger.setLevel(logging.INFO)

ROBOT_IP = "192.168.101.1"
ROBOT_INSTANCE = RobotInstance.SIMULATION
ROBOT_INSTANCE = RobotPlatform.SIMULATION


"""
Expand All @@ -27,33 +27,33 @@

When you use a real FR3 you first need to unlock its joints using the following cli script:

python -m rcsss fr3 unlock <ip>
python -m rcs fr3 unlock <ip>

or put it into guiding mode using:

python -m rcsss fr3 guiding-mode <ip>
python -m rcs fr3 guiding-mode <ip>

When you are done you lock it again using:

python -m rcsss fr3 lock <ip>
python -m rcs fr3 lock <ip>

or even shut it down using:

python -m rcsss fr3 shutdown <ip>
python -m rcs fr3 shutdown <ip>
"""


def main():
resource_manger: FCI | DummyResourceManager
if ROBOT_INSTANCE == RobotInstance.HARDWARE:
context_manger: FCI | ContextManager
if ROBOT_INSTANCE == RobotPlatform.HARDWARE:
user, pw = load_creds_fr3_desk()
resource_manger = FCI(Desk(ROBOT_IP, user, pw), unlock=False, lock_when_done=False)
context_manger = FCI(Desk(ROBOT_IP, user, pw), unlock=False, lock_when_done=False)
else:
resource_manger = DummyResourceManager()
with resource_manger:
context_manger = ContextManager()
with context_manger:

if ROBOT_INSTANCE == RobotInstance.HARDWARE:
env_rel = fr3_hw_env(
if ROBOT_INSTANCE == RobotPlatform.HARDWARE:
env_rel = RCSFR3EnvCreator()(
ip=ROBOT_IP,
control_mode=ControlMode.JOINTS,
robot_cfg=default_fr3_hw_robot_cfg(),
Expand All @@ -63,7 +63,7 @@ def main():
relative_to=RelativeTo.LAST_STEP,
)
else:
env_rel = fr3_sim_env(
env_rel = RCSSimEnvCreator()(
control_mode=ControlMode.JOINTS,
collision_guard=False,
robot_cfg=default_fr3_sim_robot_cfg(),
Expand Down
Loading