Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:cram2/pycram into knowledge
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigul committed Oct 17, 2024
2 parents 12248b2 + 09b634d commit b30a8b3
Show file tree
Hide file tree
Showing 209 changed files with 18,506 additions and 33,516 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Sphinx documentation 📖
name: Build Jupyter-Book documentation 📖

on:
push:
Expand All @@ -18,30 +18,35 @@ defaults:

jobs:
test-and-build:
name: Build Sphinx documentation
runs-on: ubuntu-20.04
name: Build Jupyter-Book documentation
runs-on: ubuntu-22.04

steps:

- name: Checkout 🛎
uses: actions/checkout@v3

- name: Install PyCRAM dependencies 🍼
uses: py-actions/py-dependency-install@v4
with:
path: "requirements-setuptools.txt"

# ----------------------------------------------------------------------------------------------------------------

- name: Install PyCRAM dependencies 🍼
- name: Install Jupyter-Book dependencies 🍼
uses: py-actions/py-dependency-install@v4
with:
path: "requirements.txt"

# ----------------------------------------------------------------------------------------------------------------
- name: Install Sphinx dependencies 📚
- name: Install Jupyter-Book dependencies 📚
uses: py-actions/py-dependency-install@v4
with:
path: "doc/requirements.txt"

# ----------------------------------------------------------------------------------------------------------------
- name: Build Sphinx documentation 📝
- name: Build Jupyter-Book documentation 📝
working-directory: ./doc
run: |
sudo apt install pandoc
make html
cd source
jupyter-book build .
30 changes: 24 additions & 6 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: "ubuntu-20.04"
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"
apt_packages:
- graphviz
- python3-catkin-pkg
jobs:
pre_build:
# Generate the Sphinx configuration for this Jupyter Book so it builds.
- "jupyter-book config sphinx doc/source"

python:
install:
- requirements: doc/requirements.txt
install:
- requirements: doc/requirements.txt
# - method: pip
# path: .
# extra_requirements:
# - catkin_pkg
# - sphinx

submodules:
exclude: all
sphinx:
builder: html
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM $FROM_IMAGE as builder
ARG OVERLAY_WS=/opt/ros/overlay_ws
WORKDIR $OVERLAY_WS/src

RUN sudo apt-get update && apt-get install python3-pip python3-vcstool git -y
RUN sudo apt-get update && apt-get install python3-pip python3-vcstool git default-jre -y
RUN vcs import --input https://raw.githubusercontent.com/cram2/pycram/dev/pycram-https.rosinstall --recursive --skip-existing $OVERLAY_WS/src
RUN sudo apt-get update && apt-get install python3-pip -y && pip3 install pip --upgrade
RUN pip3 install --no-cache-dir -r $OVERLAY_WS/src/pycram/requirements.txt
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ The plan that both robots execute is a relativly simple pick and place plan:

The code for this plan can be seen below.
```
from pycram.bullet_world import BulletWorld, Object
from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.process_module import simulated_robot
from pycram.designators.motion_designator import *
from pycram.designators.location_designator import *
from pycram.designators.action_designator import *
from pycram.designators.object_designator import *
from pycram.enums import ObjectType
from pycram.datastructures.enums import ObjectType, Arms, Grasp, WorldMode
world = BulletWorld()
world = BulletWorld(WorldMode.GUI)
kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
robot = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
cereal = Object("cereal", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl", position=[1.4, 1, 0.95])
cereal = Object("cereal", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl", pose=Pose([1.4, 1, 0.95]))
cereal_desig = ObjectDesignatorDescription(names=["cereal"])
kitchen_desig = ObjectDesignatorDescription(names=["kitchen"])
Expand All @@ -56,7 +57,7 @@ with simulated_robot:
NavigateAction(target_locations=[pickup_pose.pose]).resolve().perform()
PickUpAction(object_designator_description=cereal_desig, arms=[pickup_arm], grasps=["front"]).resolve().perform()
PickUpAction(object_designator_description=cereal_desig, arms=[pickup_arm], grasps=[Grasp.FRONT]).resolve().perform()
ParkArmsAction([Arms.BOTH]).resolve().perform()
Expand All @@ -69,6 +70,8 @@ with simulated_robot:
PlaceAction(cereal_desig, target_locations=[place_island.pose], arms=[pickup_arm]).resolve().perform()
ParkArmsAction([Arms.BOTH]).resolve().perform()
world.exit()
```


Expand Down
15 changes: 1 addition & 14 deletions binder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ RUN cd pycram \
&& cd src/neem_interface_python \
&& git clone https://github.com/benjaminalt/neem-interface.git src/neem-interface
RUN pip install --requirement ${PYCRAM_WS}/src/pycram/requirements.txt --user
RUN pip install --requirement ${PYCRAM_WS}/src/pycram/src/neem_interface_python/requirements.txt --user \
RUN pip install --requirement ${PYCRAM_WS}/src/pycram/requirements.txt --user \
&& pip cache purge
```

Expand Down Expand Up @@ -448,15 +447,3 @@ with simulated_robot:
arms=["left"],
grasps=["left", "right"]).resolve().perform()
```












8 changes: 0 additions & 8 deletions binder/pycram-http.rosinstall
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@ repositories:
type: git
url: http://github.com/code-iai/iai_robots.git
version: master
pr2_common:
type: git
url: https://github.com/PR2/pr2_common.git
version: b34703bcca2b07cadbc3777d3c504c232a0c0c28
kdl_ik_services:
type: git
url: https://github.com/cram2/kdl_ik_service.git
verison: master
pr2_kinematics:
type: git
url: https://github.com/PR2/pr2_kinematics.git
version: kinetic-devel
orocos_kinematics_dynamics:
type: git
url: https://github.com/orocos/orocos_kinematics_dynamics.git
Expand Down
Empty file added config/__init__.py
Empty file.
72 changes: 72 additions & 0 deletions config/multiverse_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import datetime

from typing_extensions import Type

from .world_conf import WorldConfig
from pycram.description import ObjectDescription
from pycram.helper import find_multiverse_resources_path
from pycram.object_descriptors.mjcf import ObjectDescription as MJCF


class MultiverseConfig(WorldConfig):
# Multiverse Configuration
resources_path = find_multiverse_resources_path()
"""
The path to the Multiverse resources directory.
"""

# Multiverse Socket Configuration
HOST: str = "tcp://127.0.0.1"
SERVER_HOST: str = HOST
SERVER_PORT: str = 7000
BASE_CLIENT_PORT: int = 9000

# Multiverse Client Configuration
READER_MAX_WAIT_TIME_FOR_DATA: datetime.timedelta = datetime.timedelta(milliseconds=1000)
"""
The maximum wait time for the data in seconds.
"""

# Multiverse Simulation Configuration
simulation_time_step: datetime.timedelta = datetime.timedelta(milliseconds=10)
simulation_frequency: int = int(1 / simulation_time_step.total_seconds())
"""
The time step of the simulation in seconds and the frequency of the simulation in Hz.
"""

simulation_wait_time_factor: float = 1.0
"""
The factor to multiply the simulation wait time with, this is used to adjust the simulation wait time to account for
the time taken by the simulation to process the request, this depends on the computational power of the machine
running the simulation.
"""

use_static_mode: bool = True
"""
If True, the simulation will always be in paused state unless the simulate() function is called, this behaves
similar to bullet_world which uses the bullet physics engine.
"""

use_controller: bool = False
use_controller = use_controller and not use_static_mode
"""
Only used when use_static_mode is False. This turns on the controller for the robot joints.
"""

default_description_type: Type[ObjectDescription] = MJCF
"""
The default description type for the objects.
"""

use_physics_simulator_state: bool = True
"""
Whether to use the physics simulator state when restoring or saving the world state.
"""

clear_cache_at_start = False

let_pycram_move_attached_objects = False
let_pycram_handle_spawning = False

position_tolerance = 2e-2
prismatic_joint_position_tolerance = 2e-2
93 changes: 93 additions & 0 deletions config/world_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import math
import os

from typing_extensions import Tuple, Type
from pycram.description import ObjectDescription
from pycram.object_descriptors.urdf import ObjectDescription as URDF


class WorldConfig:

"""
A class to store the configuration of the world, this can be inherited to create a new configuration class for a
specific world (e.g. multiverse has MultiverseConfig which inherits from this class).
"""

resources_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources')
resources_path = os.path.abspath(resources_path)
"""
Global reference for the resources path, this is used to search for the description files of the robot and
the objects.
"""

cache_dir_name: str = 'cached'
"""
The name of the cache directory.
"""

cache_dir: str = os.path.join(resources_path, cache_dir_name)
"""
Global reference for the cache directory, this is used to cache the description files of the robot and the objects.
"""

clear_cache_at_start: bool = True
"""
Whether to clear the cache directory at the start.
"""

prospection_world_prefix: str = "prospection_"
"""
The prefix for the prospection world name.
"""

simulation_frequency: int = 240
"""
The simulation frequency (Hz), used for calculating the equivalent real time in the simulation.
"""

update_poses_from_sim_on_get: bool = True
"""
Whether to update the poses from the simulator when getting the object poses.
"""

default_description_type: Type[ObjectDescription] = URDF
"""
The default description type for the objects.
"""

use_physics_simulator_state: bool = False
"""
Whether to use the physics simulator state when restoring or saving the world state.
Currently with PyBullet, this causes a bug where ray_test does not work correctly after restoring the state using the
simulator, so it is recommended to set this to False in PyBullet.
"""

let_pycram_move_attached_objects: bool = True
let_pycram_handle_spawning: bool = True
let_pycram_handle_world_sync: bool = True
"""
Whether to let PyCRAM handle the movement of attached objects, the spawning of objects,
and the world synchronization.
"""

position_tolerance: float = 1e-2
orientation_tolerance: float = 10 * math.pi / 180
prismatic_joint_position_tolerance: float = 1e-2
revolute_joint_position_tolerance: float = 5 * math.pi / 180
"""
The acceptable error for the position and orientation of an object/link, and the joint positions.
"""

use_percentage_of_goal: bool = False
acceptable_percentage_of_goal: float = 0.5
"""
Whether to use a percentage of the goal as the acceptable error.
"""

raise_goal_validator_error: bool = False
"""
Whether to raise an error if the goals are not achieved.
"""
@classmethod
def get_pose_tolerance(cls) -> Tuple[float, float]:
return cls.position_tolerance, cls.orientation_tolerance
Loading

0 comments on commit b30a8b3

Please sign in to comment.