Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:cram2/pycram into feature-rapid-neem…
Browse files Browse the repository at this point in the history
…-creation
  • Loading branch information
Leusmann committed Dec 5, 2024
2 parents b26e94c + 4045d9e commit fa38542
Show file tree
Hide file tree
Showing 147 changed files with 6,734 additions and 4,450 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/new-pycram-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
pip3 install --upgrade pip --root-user-action=ignore
cd /opt/ros/overlay_ws/src/pycram
pip3 install -r requirements.txt
sudo apt-get update
sudo apt-get install -y libpq-dev
pip3 install -r requirements-resolver.txt
- name: Install pytest & pyjpt
Expand All @@ -71,3 +73,9 @@ jobs:
source /opt/ros/overlay_ws/devel/setup.bash
roscd pycram
pytest -v test
- name: Run Demos
run: |
source /opt/ros/overlay_ws/devel/setup.bash
roscd pycram
python3 demos/pycram_bullet_world_demo/test_demo.py
84 changes: 84 additions & 0 deletions .github/workflows/notebook-test-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Test Jupyter Notebook Examples

on:
push:
branches:
- dev
- master
pull_request:
branches:
- master
- dev

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

defaults:
run:
shell: bash
working-directory: .

jobs:
test-and-build:
name: Test Jupyter Notebooks
runs-on: ubuntu-20.04
container:
image: "pycram/pycram:dev"

steps:

- name: Checkout PyCRAM
uses: actions/checkout@v3
with:
path: "ros/src/pycram"
repository: ${{ github.repository }}
ref: ${{ github.ref }}
submodules: "recursive"

# For debugging
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

- name: Update PyCRAM source files
run: |
rm -rf /opt/ros/overlay_ws/src/pycram/*
cd /opt/ros/overlay_ws/src/pycram
rm -rf .git .github .gitignore .gitmodules .readthedocs.yaml
cp -r /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/ros/src/pycram /opt/ros/overlay_ws/src
# ----------------------------------------------------------------------------------------------------------------

- name: Install python dependencies
run: |
pip3 install --upgrade pip --root-user-action=ignore
cd /opt/ros/overlay_ws/src/pycram
pip3 install -r requirements.txt
sudo apt-get update
sudo apt-get install -y libpq-dev
pip3 install -r requirements-resolver.txt
# ----------------------------------------------------------------------------------------------------------------

- name: Install Jupytext & Jupyter notebook
run: |
pip3 install jupytext treon
# ----------------------------------------------------------------------------------------------------------------
- name: Convert Notebooks
run: |
cd /opt/ros/overlay_ws/src/pycram/examples
rm -rf tmp
mkdir tmp
jupytext --to notebook *.md
mv *.ipynb tmp && cd tmp
- name: Source and start ROS
run: |
source /opt/ros/overlay_ws/devel/setup.bash
roslaunch pycram ik_and_description.launch &
- name: Run tests
run: |
source /opt/ros/overlay_ws/devel/setup.bash
roscd pycram/examples/tmp
treon --thread 1 -v --exclude=migrate_neems.ipynb --exclude=improving_actions.ipynb
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ resources/cached/

# Example checkpoints
examples/.ipynb_checkpoints/
*/tmp/*
3 changes: 3 additions & 0 deletions config/multiverse_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ class MultiverseConfig(WorldConfig):

position_tolerance = 2e-2
prismatic_joint_position_tolerance = 2e-2

use_giskard_monitor = False
allow_gripper_collision = False
11 changes: 11 additions & 0 deletions config/world_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ class WorldConfig:
"""
Whether to raise an error if the goals are not achieved.
"""

use_giskard_monitor: bool = True
"""
Whether to use the Giskard goal monitor when executing the goals.
"""

allow_gripper_collision: bool = True
"""
Whether to allow the gripper to collide with the objects when planning for the goals.
"""

@classmethod
def get_pose_tolerance(cls) -> Tuple[float, float]:
return cls.position_tolerance, cls.orientation_tolerance
40 changes: 22 additions & 18 deletions demos/pycram_bullet_world_demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@
from pycram.designators.action_designator import *
from pycram.designators.location_designator import *
from pycram.designators.object_designator import *
from pycram.datastructures.enums import ObjectType, WorldMode
from pycram.datastructures.enums import WorldMode
from pycram.datastructures.pose import Pose
from pycram.process_module import simulated_robot, with_simulated_robot
from pycram.object_descriptors.urdf import ObjectDescription
from pycram.world_concepts.world_object import Object
from pycram.datastructures.dataclasses import Color
from pycram.ros.viz_marker_publisher import VizMarkerPublisher
from pycrap import Robot, Apartment, Milk, Cereal, Spoon, Bowl
import numpy as np


np.random.seed(420)
extension = ObjectDescription.get_file_extension()

world = BulletWorld(WorldMode.GUI)

robot = Object("pr2", ObjectType.ROBOT, f"pr2{extension}", pose=Pose([1, 2, 0]))
apartment = Object("apartment", ObjectType.ENVIRONMENT, f"apartment{extension}")
robot = Object("pr2", Robot, f"pr2{extension}", pose=Pose([1, 2, 0]))
apartment = Object("apartment", Apartment, f"apartment{extension}")

milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([2.5, 2, 1.02]),
milk = Object("milk", Milk, "milk.stl", pose=Pose([2.5, 2, 1.02]),
color=Color(1, 0, 0, 1))
cereal = Object("cereal", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl",
cereal = Object("cereal", Cereal, "breakfast_cereal.stl",
pose=Pose([2.5, 2.3, 1.05]), color=Color(0, 1, 0, 1))
spoon = Object("spoon", ObjectType.SPOON, "spoon.stl", pose=Pose([2.4, 2.2, 0.85]),
spoon = Object("spoon", Spoon, "spoon.stl", pose=Pose([2.4, 2.24, 0.85]),
color=Color(0, 0, 1, 1))
bowl = Object("bowl", ObjectType.BOWL, "bowl.stl", pose=Pose([2.5, 2.2, 1.02]),
bowl = Object("bowl", Bowl, "bowl.stl", pose=Pose([2.5, 2.2, 1.02]),
color=Color(1, 1, 0, 1))
apartment.attach(spoon, 'cabinet10_drawer_top')

Expand All @@ -39,27 +43,26 @@ def move_and_detect(obj_type):

LookAtAction(targets=[pick_pose]).resolve().perform()

object_desig = DetectAction(BelieveObject(types=[obj_type])).resolve().perform()

return object_desig
object_desig = DetectAction(technique=DetectionTechnique.TYPES, object_designator_description=BelieveObject(types=[obj_type])).resolve().perform()
return object_desig[0]


with simulated_robot:
ParkArmsAction([Arms.BOTH]).resolve().perform()

MoveTorsoAction([0.25]).resolve().perform()

milk_desig = move_and_detect(ObjectType.MILK)
milk_desig = move_and_detect(Milk)

TransportAction(milk_desig, [Arms.LEFT], [Pose([4.8, 3.55, 0.8])]).resolve().perform()
TransportAction(milk_desig, [Pose([4.8, 3.55, 0.8])], [Arms.LEFT]).resolve().perform()

cereal_desig = move_and_detect(ObjectType.BREAKFAST_CEREAL)
cereal_desig = move_and_detect(Cereal)

TransportAction(cereal_desig, [Arms.RIGHT], [Pose([5.2, 3.4, 0.8], [0, 0, 1, 1])]).resolve().perform()
TransportAction(cereal_desig, [Pose([5.2, 3.4, 0.8], [0, 0, 1, 1])],[Arms.RIGHT]).resolve().perform()

bowl_desig = move_and_detect(ObjectType.BOWL)
bowl_desig = move_and_detect(Bowl)

TransportAction(bowl_desig, [Arms.LEFT], [Pose([5, 3.3, 0.8], [0, 0, 1, 1])]).resolve().perform()
TransportAction(bowl_desig, [Pose([5, 3.3, 0.8], [0, 0, 1, 1])], [Arms.LEFT]).resolve().perform()

# Finding and navigating to the drawer holding the spoon
handle_desig = ObjectPart(names=["handle_cab10_t"], part_of=apartment_desig.resolve())
Expand All @@ -74,8 +77,9 @@ def move_and_detect(obj_type):
# Detect and pickup the spoon
LookAtAction([apartment.get_link_pose("handle_cab10_t")]).resolve().perform()

spoon_desig = DetectAction(BelieveObject(types=[ObjectType.SPOON])).resolve().perform()

spoon_desigs = DetectAction(technique=DetectionTechnique.TYPES,
object_designator_description=BelieveObject(types=[Spoon])).resolve().perform()
spoon_desig = spoon_desigs[0]
pickup_arm = Arms.LEFT if drawer_open_loc.arms[0] == Arms.RIGHT else Arms.RIGHT
PickUpAction(spoon_desig, [pickup_arm], [Grasp.TOP]).resolve().perform()

Expand Down
7 changes: 7 additions & 0 deletions demos/pycram_bullet_world_demo/test_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pycram.datastructures.world import World

try:
import demo
except Exception as e:
World.current_world.exit()
raise e
File renamed without changes.
Binary file added doc/images/algebraic_costmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gaussian_costmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/knowledge/knowledge_arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/knowledge/property_evaluation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/knowledge/property_resolution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/occupancy_costmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/semantic_costmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/visibility_costmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions doc/source/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ parts:
- file: new_robot.rst
- file: notebooks.rst
- file: designators.rst
- file: knowledge.rst
- file: knowledge_and_reasoning.rst
- file: costmap.rst

- caption: Trouble Shooting
chapters:
Expand All @@ -27,6 +30,8 @@ parts:
- file: notebooks/bullet_world
- file: notebooks/language
- file: notebooks/local_transformer
- file: notebooks/minimal_task_tree
- file: notebooks/improving_actions
- file: designator_example.rst
sections:
- file: notebooks/action_designator
Expand All @@ -47,6 +52,10 @@ parts:
- file: notebooks/interface_examples/giskard.md
- file: notebooks/interface_examples/robokudo.md
- file: notebooks/ontology
- file: knowledge_examples.rst
sections:
- file: notebooks/knowledge_source.md
- file: notebooks/properties.md

- caption: API
chapters:
Expand Down
Loading

0 comments on commit fa38542

Please sign in to comment.