-
Notifications
You must be signed in to change notification settings - Fork 16
feat(arcor2_ur): extend ros_worker for collision primitives and basic tests #891
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
Draft
SimonKadnar
wants to merge
9
commits into
robofit:master
Choose a base branch
from
SimonKadnar:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b3021d8
feat(arcor2_ur): extend ros_worker for collision primitives and add b…
SimonKadnar 3261214
feat(arcor2_ur): graspable obj representation, basic functionality tests
SimonKadnar 88d7dc4
fix(arcor_ur): debug build
SimonKadnar c34760e
chore(arcor2_ur): update pinned ROS Jazzy dependency versions
SimonKadnar 70cae31
chore(ci): free disk space before installing ROS dependencies
SimonKadnar 762e2c6
feat(graspable): update grasp metadata, refactor tests and add move_o…
SimonKadnar 4e7e7af
Merge branch 'master' into master
SimonKadnar fc03ad5
feat(graspable): add basic object transfer (move_object_to_pose)
SimonKadnar 5e150ad
feat: add graspable first attach and detach algorithm, added stl base…
SimonKadnar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| import math | ||
| import random | ||
| import time | ||
| from typing import NamedTuple | ||
| from typing import Any | ||
|
|
||
| import humps | ||
| import numpy as np | ||
|
|
@@ -18,19 +18,14 @@ | |
| from arcor2.logging import get_logger | ||
| from arcor2_scene import SCENE_PORT, SCENE_SERVICE_NAME, version | ||
| from arcor2_scene.exceptions import NotFound, SceneGeneral, WebApiError | ||
| from arcor2_ur.common import CollisionSceneObject, parse_collision_body | ||
| from arcor2_web.flask import Response, RespT, create_app, run_app | ||
|
|
||
| app = create_app(__name__) | ||
| logger = get_logger(__name__) | ||
| logger.propagate = False | ||
|
|
||
|
|
||
| class CollisionObject(NamedTuple): | ||
| model: object_type.Models | ||
| pose: common.Pose | ||
|
|
||
|
|
||
| collision_objects: dict[str, CollisionObject] = {} | ||
| collision_objects: dict[str, CollisionSceneObject] = {} | ||
| started: bool = False | ||
| inflation = 0.01 | ||
|
|
||
|
|
@@ -81,7 +76,7 @@ def put_box() -> RespT: | |
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: Pose | ||
| type: object | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Proč ne přesný typ? |
||
| responses: | ||
| 200: | ||
| description: Ok | ||
|
|
@@ -97,12 +92,11 @@ def put_box() -> RespT: | |
| $ref: WebApiError | ||
| """ | ||
|
|
||
| if not isinstance(request.json, dict): | ||
| raise SceneGeneral("Body should be a JSON dict containing Pose.") | ||
| pose, metadata = parse_collision_body() | ||
|
|
||
| args = request.args.to_dict() | ||
| box = object_type.Box(args["boxId"], float(args["sizeX"]), float(args["sizeY"]), float(args["sizeZ"])) | ||
| collision_objects[box.id] = CollisionObject(box, common.Pose.from_dict(humps.decamelize(request.json))) | ||
| collision_objects[box.id] = CollisionSceneObject(box, pose, metadata) | ||
|
|
||
| return jsonify("ok"), 200 | ||
|
|
||
|
|
@@ -131,7 +125,7 @@ def put_sphere() -> RespT: | |
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: Pose | ||
| type: object | ||
| responses: | ||
| 200: | ||
| description: Ok | ||
|
|
@@ -147,12 +141,11 @@ def put_sphere() -> RespT: | |
| $ref: WebApiError | ||
| """ | ||
|
|
||
| if not isinstance(request.json, dict): | ||
| raise SceneGeneral("Body should be a JSON dict containing Pose.") | ||
| pose, metadata = parse_collision_body() | ||
|
|
||
| args = humps.decamelize(request.args.to_dict()) | ||
| sphere = object_type.Sphere(args["sphere_id"], float(args["radius"])) | ||
| collision_objects[sphere.id] = CollisionObject(sphere, common.Pose.from_dict(humps.decamelize(request.json))) | ||
| collision_objects[sphere.id] = CollisionSceneObject(sphere, pose, metadata) | ||
| return jsonify("ok"), 200 | ||
|
|
||
|
|
||
|
|
@@ -185,7 +178,7 @@ def put_cylinder() -> RespT: | |
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: Pose | ||
| type: object | ||
| responses: | ||
| 200: | ||
| description: Ok | ||
|
|
@@ -201,12 +194,11 @@ def put_cylinder() -> RespT: | |
| $ref: WebApiError | ||
| """ | ||
|
|
||
| if not isinstance(request.json, dict): | ||
| raise SceneGeneral("Body should be a JSON dict containing Pose.") | ||
| pose, metadata = parse_collision_body() | ||
|
|
||
| args = humps.decamelize(request.args.to_dict()) | ||
| cylinder = object_type.Cylinder(args["cylinder_id"], float(args["radius"]), float(args["height"])) | ||
| collision_objects[cylinder.id] = CollisionObject(cylinder, common.Pose.from_dict(humps.decamelize(request.json))) | ||
| collision_objects[cylinder.id] = CollisionSceneObject(cylinder, pose, metadata) | ||
| return jsonify("ok"), 200 | ||
|
|
||
|
|
||
|
|
@@ -251,7 +243,7 @@ def put_mesh() -> RespT: | |
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: Pose | ||
| type: object | ||
| responses: | ||
| 200: | ||
| description: Ok | ||
|
|
@@ -267,12 +259,11 @@ def put_mesh() -> RespT: | |
| $ref: WebApiError | ||
| """ | ||
|
|
||
| if not isinstance(request.json, dict): | ||
| raise SceneGeneral("Body should be a JSON dict containing Pose.") | ||
| pose, metadata = parse_collision_body() | ||
|
|
||
| args = humps.decamelize(request.args.to_dict()) | ||
| mesh = object_type.Mesh(args["mesh_id"], args["mesh_file_id"]) | ||
| collision_objects[mesh.id] = CollisionObject(mesh, common.Pose.from_dict(humps.decamelize(request.json))) | ||
| collision_objects[mesh.id] = CollisionSceneObject(mesh, pose, metadata) | ||
| return jsonify("ok"), 200 | ||
|
|
||
|
|
||
|
|
@@ -419,21 +410,25 @@ def put_line_safe() -> RespT: | |
| arcor2/ros x forward, y left, z up | ||
| unity x Right, y Up, z Forward | ||
| """ | ||
| for obj_id, (model, pose) in collision_objects.items(): | ||
| for obj_id, obj in collision_objects.items(): | ||
| model = obj.model | ||
| pose = obj.pose | ||
|
|
||
| if isinstance(model, object_type.Box): | ||
| # The left bottom corner on the front will be placed at (0, 0, 0) | ||
| sx = model.size_x + inflation | ||
| sy = model.size_y + inflation | ||
| sz = model.size_z + inflation | ||
|
|
||
| tm = o3d.geometry.TriangleMesh.create_box(sx, sy, sz) | ||
|
|
||
| tm = tm.translate([pose.position.x - sx / 2, pose.position.y - sy / 2, pose.position.z - sz / 2]) | ||
|
|
||
| elif isinstance(model, object_type.Cylinder): | ||
| tm = o3d.geometry.TriangleMesh.create_cylinder(model.radius + inflation, model.height + inflation) | ||
|
|
||
| elif isinstance(model, object_type.Sphere): | ||
| tm = o3d.geometry.TriangleMesh.create_sphere(model.radius + inflation) | ||
| else: # TODO mesh | ||
|
|
||
| else: | ||
| logger.warning(f"Unsupported type of collision model: {model.type()}.") | ||
| continue | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.