Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebook test ci #212

Merged
merged 31 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
15c1fd4
[workflow] added test ci for notebooks
Tigul Sep 9, 2024
6be5275
[examples] Refactored action designator example
Tigul Sep 9, 2024
76ce3c5
[process module] Fixed typo
Tigul Sep 9, 2024
6b9bbf2
[examples] Fixed examples
Tigul Sep 9, 2024
afededa
[location desig/example] Fixed location designator example
Tigul Sep 23, 2024
c20a919
[language] Fixed return in repeat
Tigul Sep 23, 2024
2151b0d
[examples] Fixed imports
Tigul Sep 23, 2024
c5eda48
Merge branch 'dev' of github.com:cram2/pycram into notebook-test-ci
Tigul Oct 18, 2024
0d0d53d
[examples] Added CI database to improving actions
Tigul Oct 18, 2024
d657cae
[ci] Changed name of notebook test ci
Tigul Oct 18, 2024
11f9a36
[ci] Added setuptool requirements
Tigul Oct 18, 2024
460e0fb
[ci] Update to 22.04
Tigul Oct 18, 2024
994a91c
[ci] Update dependency install
Tigul Oct 18, 2024
13977a8
[ci] Added install of jupytext and treon
Tigul Oct 18, 2024
11bf2d0
[ci] Final fix for ci
Tigul Oct 18, 2024
dfcd6aa
[exxamples] Some fixes
Tigul Oct 18, 2024
ee6740e
[examples] Fixed intro example
Tigul Oct 28, 2024
57ed827
[examples] Fixed more errors
Tigul Oct 28, 2024
7712d49
[ci] Added cleanup to delete leftover old dir before exec
Tigul Oct 29, 2024
79f5801
[ci] Added update of pycram source files
Tigul Oct 29, 2024
7fcbb3c
[bullet world] Check if Display is connected
Tigul Oct 29, 2024
1682856
[bullet world] Better check
Tigul Oct 29, 2024
cb8a1cf
[examples] Errors that appeard in ci
Tigul Oct 29, 2024
50e2983
[examples] more fixes
Tigul Oct 29, 2024
dde07d0
[ci] ADded libpq-dev because dependencies
Tigul Oct 29, 2024
f35a511
[examples] Fixed from test branch
Tigul Oct 30, 2024
6c7f60e
[ci] Added libpq-dev for psycopg2 dependency
Tigul Oct 30, 2024
78d7269
[examples] Added robustness
Tigul Nov 5, 2024
31a52fb
[example] New seed for cram plan tutorial
Tigul Nov 5, 2024
b085b81
[general] removed test code
Tigul Nov 5, 2024
385ea0d
[example] new troso val
Tigul Nov 5, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/new-pycram-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
pip3 install --upgrade pip --root-user-action=ignore
cd /opt/ros/overlay_ws/src/pycram
pip3 install -r requirements.txt
sudo apt-get install -y libpq-dev
pip3 install -r requirements-resolver.txt

- name: Install pytest & pyjpt
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/notebook-test-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this be part of the jb build pipeline?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the pipeline for the documentation?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is specifically so that treon can do the testing for the notebooks


- 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
67 changes: 23 additions & 44 deletions examples/action_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.16.2
jupytext_version: 1.16.3
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---

<!-- #region -->

# Action Designator

Expand All @@ -29,7 +28,7 @@ Designator Description will then pick one of the poses and return a performable
picked pose.


<!-- #endregion -->


## Navigate Action

Expand All @@ -41,9 +40,12 @@ First, we need a BulletWorld with a robot.
from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.datastructures.enums import ObjectType, WorldMode
from pycram.datastructures.pose import Pose

world = BulletWorld(WorldMode.GUI)
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf", pose=Pose([1, 2, 0]))
apartmet = Object("apartment", ObjectType.ENVIRONMENT, "apartment.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([2.3, 2, 1.1]))
```

To move the robot we need to create a description and resolve it to an actual Designator. The description of navigation
Expand All @@ -53,7 +55,7 @@ only needs a list of possible poses.
from pycram.designators.action_designator import NavigateAction
from pycram.datastructures.pose import Pose

pose = Pose([1, 0, 0], [0, 0, 0, 1])
pose = Pose([1.3, 2, 0], [0, 0, 0, 1])

# This is the Designator Description
navigate_description = NavigateAction(target_locations=[pose])
Expand Down Expand Up @@ -141,16 +143,11 @@ the example on object designators for more details.
To start we need an environment in which we can pick up and place things as well as an object to pick up.

```python
kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.3, 1, 0.9]))

world.reset_world()
```

```python
from pycram.designators.action_designator import PickUpAction, PlaceAction, ParkArmsAction, MoveTorsoAction,

NavigateAction
from pycram.designators.action_designator import PickUpAction, PlaceAction, ParkArmsAction, MoveTorsoAction,NavigateAction
from pycram.designators.object_designator import BelieveObject
from pycram.process_module import simulated_robot
from pycram.datastructures.enums import Arms, Grasp
Expand All @@ -164,37 +161,33 @@ with simulated_robot:

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

NavigateAction([Pose([0.78, 1, 0.0],
[0.0, 0.0, 0.014701099828940344, 0.9998919329926708])]).resolve().perform()
NavigateAction([Pose([1.8, 2, 0.0],
[0.0, 0.0, 0., 1])]).resolve().perform()

PickUpAction(object_designator_description=milk_desig,
arms=[arm],
grasps=[Grasp.RIGHT]).resolve().perform()

NavigateAction([Pose([-1.90, 0.78, 0.0],
[0.0, 0.0, 0.16439898301071468, 0.9863939245479175])]).resolve().perform()

PlaceAction(object_designator_description=milk_desig,
target_locations=[Pose([-1.20, 1.0192, 0.9624],
# [0.0, 0.0, 0.6339889056055381, 0.7733421413379024])],
target_locations=[Pose([2.4, 1.8, 1],
[0, 0, 0, 1])],
arms=[arm]).resolve().perform()
```

```python
world.reset_world()
```

## Look At

Look at lets the robot look at a specific point, for example if it should look at an object for detecting.

```python
world.reset_world()
```

```python
from pycram.designators.action_designator import LookAtAction
from pycram.process_module import simulated_robot
from pycram.datastructures.pose import Pose

target_location = Pose([1, 0, 0.5], [0, 0, 0, 1])
target_location = Pose([3, 2, 0.5], [0, 0, 0, 1])
with simulated_robot:
LookAtAction(targets=[target_location]).resolve().perform()
```
Expand All @@ -206,7 +199,7 @@ up/place example, if you didn't execute that example you can spawn the milk with
designator will return a resolved instance of an ObjectDesignatorDescription.

```python
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.3, 1, 0.9]))
world.reset_world()
```

```python
Expand All @@ -221,7 +214,7 @@ milk_desig = BelieveObject(names=["milk"])
with simulated_robot:
ParkArmsAction([Arms.BOTH]).resolve().perform()

NavigateAction([Pose([0, 1, 0], [0, 0, 0, 1])]).resolve().perform()
NavigateAction([Pose([1.7, 2, 0], [0, 0, 0, 1])]).resolve().perform()

LookAtAction(targets=[milk_desig.resolve().pose]).resolve().perform()

Expand All @@ -237,8 +230,7 @@ Place plan used in the Pick-up and Place example. Since we need an Object which
don't need to do this if you already have spawned it in a previous example.

```python
kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.3, 1, 0.9]))
world.reset_world()
```

```python
Expand All @@ -252,8 +244,8 @@ milk_desig = BelieveObject(names=["milk"])

description = TransportAction(milk_desig,
[Arms.LEFT],
[Pose([-1.35, 0.78, 0.95],
[0.0, 0.0, 0.16439898301071468, 0.9863939245479175])])
[Pose([2.4, 1.8, 1],
[0, 0, 0, 1])])
with simulated_robot:
MoveTorsoAction([0.2]).resolve().perform()
description.resolve().perform()
Expand All @@ -268,11 +260,7 @@ For the moment this designator works only in the apartment environment, therefor
apartment.

```python
kitchen.remove()
```

```python
apartment = Object("apartment", ObjectType.ENVIRONMENT, "apartment.urdf")
world.reset_world()
```

```python
Expand Down Expand Up @@ -301,15 +289,6 @@ describing the handle to be grasped.
This action designator only works in the apartment environment for the moment, therefore we remove the kitchen and spawn
the apartment. Additionally, we open the drawer such that we can close it with the action designator.

```python
kitchen.remove()
```

```python
apartment = Object("apartment", ObjectType.ENVIRONMENT, "apartment.urdf")
apartment.set_joint_state("cabinet10_drawer_top_joint", 0.4)
```

```python
from pycram.designators.action_designator import *
from pycram.designators.object_designator import *
Expand Down
Loading
Loading