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

Calculate fov #3

Merged
merged 63 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
32859d1
initial commit
Tigul Jun 12, 2019
72b9ed3
moved gui in own thread
Tigul Jun 12, 2019
bf71677
introduced bullet_world class
Tigul Jun 16, 2019
9c628b0
adapting new architecture
Tigul Jun 16, 2019
6e047d9
clean up
Tigul Jun 16, 2019
18bb06e
completed stable predicate
Tigul Jun 18, 2019
07dc0ed
improved thread handling
Tigul Jun 21, 2019
5eda412
removed test urdf
Tigul Jun 21, 2019
8254695
completed contact prdicate
Tigul Jun 21, 2019
348adad
fixed bug
Tigul Jun 21, 2019
8413aca
removed demo file
Tigul Jun 21, 2019
e499ed3
finished support for multiple BulletWorlds
Tigul Jun 21, 2019
f086866
fixed fault with BulletWorld attributes
Tigul Jun 22, 2019
27f2d93
remoced urdfs
Tigul Jun 22, 2019
6479a37
visible predicate finished
Tigul Jun 22, 2019
d193cee
completed occluding predicate
Tigul Jun 22, 2019
2a0cd6f
some helper functions and refactor
Tigul Jun 23, 2019
864c8bf
added current_bullet_world and made world in predicates mandatory
Tigul Jun 27, 2019
464ef7f
added link methods to object calss
Tigul Jun 27, 2019
90dbaac
implemented view and projection matrix
Tigul Jun 27, 2019
3cf7f6a
implemented reachable predicate
Tigul Jun 27, 2019
e84609a
object attachments
Tigul Jun 30, 2019
2951d74
reworked attachments
Tigul Jun 30, 2019
8739bdc
implemented attachment for base
Tigul Jul 2, 2019
f36b50f
fixed attachments
Tigul Jul 2, 2019
d18de98
refactor, moved reasoning into own file
Tigul Jul 8, 2019
8d23d76
added supporting predicate
Tigul Jul 8, 2019
75c6506
object loading for .urdf
Tigul Jul 11, 2019
b480c85
added support for .stl files
Tigul Jul 11, 2019
b4bb479
finally fixed attachments
Tigul Jul 15, 2019
b9391e9
added support for colors when spawning .obj
Tigul Jul 15, 2019
fb5d34c
implemented Events for attachments
Tigul Jul 17, 2019
cfe4817
fixed reachable predicate
Tigul Aug 1, 2019
24a16a1
changed attachments to save cid in both objects
Tigul Aug 2, 2019
0a9bf35
implemented blocking predicate and minor fixes
Tigul Aug 2, 2019
41405d1
made world parameter in predicates optional
Tigul Aug 2, 2019
101a614
fixed optional world parameter
Tigul Aug 2, 2019
b5d0976
documentation predicates
Tigul Aug 2, 2019
a52b0ed
Documentation bullet_world and refactor
Tigul Aug 3, 2019
bf4925a
minor changes and struct demo
Tigul Aug 7, 2019
2eecda9
first process Modules
Tigul Aug 14, 2019
bc270f2
first motion_designators
Tigul Aug 15, 2019
e791d94
finished process modules and designators
Tigul Aug 19, 2019
20aefff
a few more getters and setters
Tigul Sep 10, 2019
ff3cfb5
new process modules
Tigul Oct 21, 2019
5de19bf
more designator
Tigul Oct 26, 2019
a40ebf4
more designators
Tigul Oct 27, 2019
7b6fdb8
a littöe bit of everything
Tigul Oct 28, 2019
9121665
demo finished
Tigul Nov 5, 2019
5f5fa18
last changes in demo
Tigul Nov 27, 2019
e66305c
fixed exit method of BulletWorld
Tigul Nov 29, 2019
044ba0f
Update README.md
Tigul Nov 28, 2019
aacba01
Update README.md
Tigul Nov 28, 2019
8700efe
Update README.md
Tigul Nov 28, 2019
8807f99
documentation
Tigul Dec 3, 2019
1739607
final commit
Tigul Dec 3, 2019
4c78167
fixed structure after merge
Tigul Feb 26, 2020
42ef4fb
removed __pycache__
Tigul Feb 26, 2020
f0b6e3d
added event.py
Tigul Feb 27, 2020
615a961
new calculation for FOV
Tigul Mar 12, 2020
43f65fa
updated documentation
Tigul Mar 12, 2020
ed02694
added missing comma
Tigul Mar 12, 2020
00f8e52
fixed upvector for FOV calculation
Tigul Mar 19, 2020
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
195 changes: 195 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
cmake_minimum_required(VERSION 2.8.3)
project(pycram)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs # Or other packages containing msgs
# )

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES pycram
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
# ${catkin_INCLUDE_DIRS}
)

## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/pycram.cpp
# )

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/pycram_node.cpp)

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_pycram.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# PyCRAM

Python 3 implementation of CRAM.

PyCRAM requires [a specific fork of MacroPy](https://github.com/daugsten93/macropy), which, however, is already included in the source. So, you do not have to install it.

## Authors

* **Andy Augsten** <a.augsten@uni-bremen.de>
* **Dustin Augsten** <augsten@uni-bremen.de>
* **Jonas Dech** <jdech@uni-bremen-de>

## Dependecies
To work with the Bullet World of PyCRAM the follwing packages are required.
* PyBullet
* pathlib
* numpy

## Run the Demo
### Prerequisites
To run the demo one needs, all files in the resources folder along with the [pr2 description](https://github.com/PR2/pr2_common/tree/melodic-devel/pr2_description) and the description of the [kitchen](https://github.com/code-iai/iai_maps/tree/master/iai_kitchen). **Both descriptions must be in the same folder as this repository**.

### Execute
To execute the demo the follwing commands have to be executed:
```
cd demo
```
```
python3 run.py
```
69 changes: 69 additions & 0 deletions demos/pycram_pr2_bullet_world_demo/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import process_modules
import motion_designators # Needs to be imported to load Process Modules and designator solutions
import pycram.bullet_world_reasoning as btr
from pycram.designator import MotionDesignator
from pycram.process_module import ProcessModule
from pycram.bullet_world import BulletWorld, Object
from pycram.language import macros, par

world = BulletWorld()
world.set_gravity([0, 0, -9.8])
plane = Object("floor", "environment", "../resources/plane.urdf", world=world)
robot = Object("pr2", "robot", "../resources/pr2.urdf")
kitchen = Object("kitchen", "environment", "../resources/kitchen.urdf")
milk = Object("milk", "milk", "../resources/milk.stl", [1.3, 1, 1])
spoon = Object("spoon", "spoon", "../resources/spoon.stl", [1.35, 0.7, 0.8])
cereal = Object("cereal", "cereal", "../resources/breakfast_cereal.stl", [1.3, 0.6, 1])
bowl = Object("bowl", "bowl", "../resources/bowl.stl", [1.3, 0.8, 1])
BulletWorld.robot = robot

targets = {
'milk': [[-0.8, 1, 0.93], "left", False],
'bowl': [[-0.8, 1.2, 0.9], "right", False],
'cereal': [[-1, 1, 0.94], "right", False],
'spoon': [[-0.8, 1.2, 0.94], "right", False]
}


def move_object(object_type, target, arm):
gripper = "l_gripper_tool_frame" if arm == "left" else "r_gripper_tool_frame"
with par as s:
ProcessModule.perform(MotionDesignator([('type', 'move-arm-joints'), ('left-arm', 'park'), ('right-arm', 'park')]))
ProcessModule.perform(MotionDesignator([('type', 'moving'), ('target', [0.65, 0.7, 0]), ('orientation', [0, 0, 0, 1])]))

if object_type == "spoon":
ProcessModule.perform(MotionDesignator([('type', 'accessing'), ('drawer-joint', 'sink_area_left_upper_drawer_main_joint'), ('drawer-handle', 'sink_area_left_upper_drawer_handle'), ('arm', 'left'), ('distance', 0.3), ('part-of', kitchen)]))

ProcessModule.perform(MotionDesignator([('type', 'looking'), ('target', [1.3, 0.6, 1])]))

det_obj = ProcessModule.perform(MotionDesignator([('type', 'detecting'), ('object', object_type)]))

block = btr.blocking(det_obj, BulletWorld.robot, gripper)
block_new = list(filter(lambda obj: obj.type != "environment", block))

if block_new:
move_object(block_new[0].type, targets[block_new[0].type][0], targets[block_new[0].type][1])
ProcessModule.perform(MotionDesignator([('type', 'moving'), ('target', [0.65, 0.7, 0]), ('orientation', [0, 0, 0, 1])]))

ProcessModule.perform(MotionDesignator([('type', 'pick-up'), ('object', det_obj), ('arm', arm)]))

ProcessModule.perform(MotionDesignator([('type', 'move-arm-joints'), ('right-arm', 'park')]))

ProcessModule.perform(MotionDesignator([('type', 'moving'), ('target', [-0.3, 1, 0]), ('orientation', [0, 0, 1, 0])]))

if btr.reachable_pose(targets[object_type][0], robot, gripper):
ProcessModule.perform(MotionDesignator([('type', 'place'), ('object', det_obj), ('target', target), ('arm', arm)]))

ProcessModule.perform(MotionDesignator([('type', 'move-arm-joints'), ('left-arm', 'park'), ('right-arm', 'park')]))
print("placed: ", object_type)

if not btr.stable(det_obj):
raise btr.ReasoningError
targets[object_type][2] = True


object_types = ['milk', 'bowl', 'cereal', 'spoon']
for i in range(0, 4):
if not targets[object_types[i]][2]:
move_object(object_types[i], targets[object_types[i]][0], targets[object_types[i]][1])

87 changes: 87 additions & 0 deletions demos/pycram_pr2_bullet_world_demo/motion_designators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from pycram.designator import MotionDesignator
from pycram.bullet_world import BulletWorld


def pr2_motion_designators(desig):
"""
This method defines the referencing of all available motion designator.
If a possible solution is found it will be appended to the list of solutions.
:param desig: The designator to be referenced
:return: A list with possible solution.
"""
solutions = []

# Type: moving
if desig.check_constraints([('type', 'moving'), 'target']):
if desig.check_constraints(['orientation']):
solutions.append(desig.make_dictionary([('cmd', 'navigate'), 'target', 'orientation']))
solutions.append(desig.make_dictionary([('cmd', 'navigate'), 'target', ('orientation', BulletWorld.robot.get_orientation())]))

# Type: pick-up
if desig.check_constraints([('type', 'pick-up'), 'object']):
if desig.check_constraints([('arm', 'right')]):
solutions.append(desig.make_dictionary([('cmd', 'pick'), 'object', ('gripper', 'r_gripper_tool_frame')]))
solutions.append(desig.make_dictionary([('cmd', 'pick'), 'object', ('gripper', 'l_gripper_tool_frame')]))

# Type: place
if desig.check_constraints([('type', 'place'), 'target']):
if desig.check_constraints(['object']):
if desig.check_constraints([('arm', 'right')]):
solutions.append(desig.make_dictionary([('cmd', 'place'), 'target', 'object', ('gripper', 'r_gripper_tool_frame')]))
solutions.append(desig.make_dictionary([('cmd', 'place'), 'target', 'object', ('gripper', 'l_gripper_tool_frame')]))

# Type: accessing
if desig.check_constraints([('type', 'accessing'), 'drawer-joint', 'drawer-handle', 'part-of']):
if desig.check_constraints([('arm', 'right')]):
if desig.check_constraints('distance'):
solutions.append(desig.make_dictionary([('cmd', 'access'), 'drawer-joint', 'drawer-handle', ('gripper', 'r_gripper_tool_frame'), 'distance', 'part-of']))
solutions.append(desig.make_dictionary([('cmd', 'access'), 'drawer-joint', 'drawer-handle', ('gripper', 'r_gripper_tool_frame'), ('distance', 0.3), 'part-of']))
solutions.append(desig.make_dictionary([('cmd', 'access'), 'drawer-joint', 'drawer-handle', 'part-of', ('distance', 0.3), ('gripper', 'l_gripper_tool_frame'), 'part-of']))

# Type: move-tcp
if desig.check_constraints([('type', 'move-tcp'), 'target']):
if desig.check_constraints([('arm', 'right')]):
solutions.append(desig.make_dictionary([('cmd', 'move-tcp'), 'target', ('gripper', 'r_gripper_tool_frame')]))
solutions.append(desig.make_dictionary([('cmd', 'move-tcp'), 'target', ('gripper', 'l_gripper_tool_frame')]))

# Type: park-arms
if desig.check_constraints([('type', 'park-arms')]):
solutions.append(desig.make_dictionary([('cmd', 'park')]))

# Type: looking
if desig.check_constraints([('type', 'looking')]):
if desig.check_constraints(['target']):
solutions.append(desig.make_dictionary([('cmd', 'looking'), 'target']))
if desig.check_constraints(['object']):
solutions.append(desig.make_dictionary([('cmd', 'looking'), ('target', BulletWorld.current_bullet_world.
get_objects_by_name(desig.prop_value('object')).get_pose())]))

# Type: opening-gripper
if desig.check_constraints([('type', 'opening-gripper'), 'gripper']):
solutions.append(desig.make_dictionary([('cmd', 'move-gripper'), ('motion', 'open'), 'gripper']))

# Type: closing-gripper
if desig.check_constraints([('type', 'closing-gripper'), 'gripper']):
solutions.append(desig.make_dictionary([('cmd', 'move-gripper'), ('motion', 'close'), 'gripper']))

# Type: detecting
if desig.check_constraints([('type', 'detecting'), 'object']):
solutions.append(desig.make_dictionary([('cmd', 'detecting'), ('cam_frame', 'wide_stereo_optical_frame'), 'object']))

# Type: move-arm-joints
if desig.check_constraints([('type', 'move-arm-joints')]):
if desig.check_constraints(['left-arm', 'right-arm']):
solutions.append(desig.make_dictionary([('cmd', 'move-joints'), ('left-poses', desig.prop_value('left-arm')), ('right-poses', desig.prop_value('right-arm'))]))
if desig.check_constraints(['left-arm']):
solutions.append(desig.make_dictionary([('cmd', 'move-joints'), ('left-poses', desig.prop_value('left-arm')), ('right-poses', None)]))
if desig.check_constraints(['right-arm']):
solutions.append(desig.make_dictionary([('cmd', 'move-joints'), ('right-poses', desig.prop_value('right-arm')), ('left-poses', None)]))

# Type: world-state-detecting
if desig.check_constraints([('type', 'world-state-detecting')]):
solutions.append(desig.make_dictionary([('cmd', 'world-state-detecting'), 'object']))

return solutions


MotionDesignator.resolvers.append(pr2_motion_designators)
Loading