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

Fallschool multiverse demo + Minor Changes #227

Merged
merged 91 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
b34c45d
[MultiverseTest] changed cup spawn position to a bit nearer to the mi…
AbdelrhmanBassiouny Oct 15, 2024
497f84d
[MultiverseContact] (WIP) Adding support for multiple contact points.
AbdelrhmanBassiouny Oct 15, 2024
0a56902
[MultiverseContact] Multiple contact points with normals now working.
AbdelrhmanBassiouny Oct 16, 2024
d441ac7
[World] Changed bounding box methods to not being abstract since ther…
AbdelrhmanBassiouny Oct 17, 2024
c7472f5
[Multiverse] create object from generic_description.
AbdelrhmanBassiouny Oct 22, 2024
20a31cb
[ObjectType] Added Imagined Surface as an object type.
AbdelrhmanBassiouny Oct 22, 2024
65ab190
[Multiverse] corrected multiple removal of same simulator state.
AbdelrhmanBassiouny Oct 23, 2024
af8a51d
[WorldSync] pause and resume world sync is not used anymore as the sy…
AbdelrhmanBassiouny Oct 25, 2024
b78d078
[MultiverseFallschoolDemo] Created a demo for the fallschool for mult…
AbdelrhmanBassiouny Oct 28, 2024
065a93b
[euROBIN] Added ur5e description and a demo for using it in eurobin.
AbdelrhmanBassiouny Oct 17, 2024
fc5f933
[euROBIN] new process_module for gripper, accept grippers as separate…
AbdelrhmanBassiouny Oct 18, 2024
80b5b2e
[euROBIN] changed gripper_name to be in end_effector_description inst…
AbdelrhmanBassiouny Oct 18, 2024
dc021f8
[Multiverse] No need for simulation name anymore for Multiverse, a st…
AbdelrhmanBassiouny Oct 25, 2024
e15fc98
[euROBIN] update belief state world with the real world info.
AbdelrhmanBassiouny Oct 25, 2024
65811e7
[ros] fixed issue with wait_for_message and create_timer methods.
AbdelrhmanBassiouny Oct 25, 2024
2484cef
[Costmaps] check if the maximum of the map is 0 before dividing and r…
AbdelrhmanBassiouny Oct 29, 2024
39e8389
[ProcessModules] use camera link name not the frame name when getting…
AbdelrhmanBassiouny Oct 29, 2024
43e4d51
[RobotDescription] some cleaning and added a method for getting camer…
AbdelrhmanBassiouny Oct 29, 2024
ab2caa8
[JointLimits] added a check and clipping step to avoid exceeding join…
AbdelrhmanBassiouny Oct 29, 2024
f0a775c
[Multiverse] can use controller in static mode as well when un pausin…
AbdelrhmanBassiouny Oct 29, 2024
2aed166
[MultiverseFallschoolDemo] updated the demo with the milk in the fridge.
AbdelrhmanBassiouny Oct 29, 2024
fee0ada
[Costmaps] Ignore floor when making an occupanct map.
AbdelrhmanBassiouny Oct 30, 2024
40f4d8b
[WorldSync] Copy object with original pose not current pose such that…
AbdelrhmanBassiouny Nov 1, 2024
5f41047
[MultiverseFallschoolDemo] The demo works.
AbdelrhmanBassiouny Nov 1, 2024
3ed8129
[Multiverse] Made tests more independent.
AbdelrhmanBassiouny Nov 1, 2024
5b8613b
[GoalValidator] Made goal validation an option and added this option …
AbdelrhmanBassiouny Nov 5, 2024
cb9d135
[RobotDescription] Add an attribute that holds ignored joints, for ex…
AbdelrhmanBassiouny Nov 5, 2024
a5332d2
[RobotStateUpdater] Updated to the new version of RobotDescription.
AbdelrhmanBassiouny Nov 5, 2024
78c2dc5
[MultiverseFallschoolDemo] (WIP) Navigate works, but LookinAt is not …
AbdelrhmanBassiouny Nov 5, 2024
68f701a
[MultiverseFallschoolDemo] (WIP) Need to figure out why giskard state…
AbdelrhmanBassiouny Nov 7, 2024
2e3c938
[MultiverseFallschoolDemo] (WIP) Need to fix multiverse contact, and …
AbdelrhmanBassiouny Nov 8, 2024
401306f
[MultiverseFallschoolDemo] testing transport action.
AbdelrhmanBassiouny Nov 10, 2024
c23dbb0
[Multiverse] corrected multiverse contact bodies in the case of multi…
AbdelrhmanBassiouny Nov 10, 2024
4a7b00c
[Designator] Added some debug logging.
AbdelrhmanBassiouny Nov 10, 2024
f41f5d7
[Multiverse] Can get all contact links.
AbdelrhmanBassiouny Nov 11, 2024
8528d0a
[Contact] corrected the setting of in_contact variable by checking th…
AbdelrhmanBassiouny Nov 11, 2024
40ec4e2
[NavigateAction] Add an option that asks if the joint states should b…
AbdelrhmanBassiouny Nov 11, 2024
e24a071
[Multiverse] new version of multiverse contact points.
AbdelrhmanBassiouny Nov 11, 2024
e8565cf
[MultiverseFallschoolDemo] (WIP) picking up prepose and pose of arm n…
AbdelrhmanBassiouny Nov 11, 2024
6154944
[Multiverse] corrected multiverse contact points.
AbdelrhmanBassiouny Nov 11, 2024
31cd583
[ActionMotionDesignation] An option to specify movement types with Mo…
AbdelrhmanBassiouny Nov 12, 2024
5006100
[ActionLocationDesignators] can ignore collisions with certain specif…
AbdelrhmanBassiouny Nov 12, 2024
5f7fa4b
[ActionLocationDesignators] can ignore collisions with certain specif…
AbdelrhmanBassiouny Nov 12, 2024
2ff6352
[ActionLocationDesignators] can ignore collisions with certain specif…
AbdelrhmanBassiouny Nov 12, 2024
3602bb1
[ActionLocationDesignators] can ignore collisions with certain specif…
AbdelrhmanBassiouny Nov 12, 2024
37973b6
[ActionLocationDesignators] don't resolve costmap
AbdelrhmanBassiouny Nov 12, 2024
62b5d11
[CostmapLocation] don't compare objects but object names when checkin…
AbdelrhmanBassiouny Nov 12, 2024
ff2381d
[CostmapLocation] add ignored collisions to the allowed collisions of…
AbdelrhmanBassiouny Nov 12, 2024
dbc190e
[CostmapLocation] use link names instead of link objects in allowed c…
AbdelrhmanBassiouny Nov 12, 2024
4005d88
[Multiverse] add option to ignore contacts of attached objects when q…
AbdelrhmanBassiouny Nov 12, 2024
20f6a21
[LocationDesignator] exclude hand endeffector links not hand links in…
AbdelrhmanBassiouny Nov 12, 2024
f3f5327
[Multiverse] check if object has attachments in get contact to avoid …
AbdelrhmanBassiouny Nov 12, 2024
b0d4178
[Pr2ProcessModules] MoveTCP can include motion of base.
AbdelrhmanBassiouny Nov 12, 2024
88274ae
[Pr2ProcessModules] MoveTCP can include motion of base.
AbdelrhmanBassiouny Nov 12, 2024
c0330b7
[ActionDesignator] better prepose and approach technique for picking …
AbdelrhmanBassiouny Nov 12, 2024
b174d05
[MultiverseFallschoolDemo] The demo works.
AbdelrhmanBassiouny Nov 12, 2024
5f7ba6d
[World] Save and Restore state from a file.
AbdelrhmanBassiouny Nov 12, 2024
9437e47
[MultiverseFallschoolDemo] adjusting grasping pose and looking at pose.
AbdelrhmanBassiouny Nov 12, 2024
6b3cd2e
[PickupAction] Check that the object is in contact with the gripper a…
AbdelrhmanBassiouny Nov 13, 2024
ccf743e
[MultiverseFallschoolDemo] try and redo actions
AbdelrhmanBassiouny Nov 13, 2024
1555dbc
[MultiverseFallschoolDemo] try and redo motions
AbdelrhmanBassiouny Nov 13, 2024
6e9110b
[MultiverseFallschoolDemo] try and redo motions
AbdelrhmanBassiouny Nov 13, 2024
e3e9f95
[MultiverseFallschoolDemo] increase number of retries
AbdelrhmanBassiouny Nov 13, 2024
a296104
[MultiverseFallschoolDemo] add mutex at every send and receive in mul…
AbdelrhmanBassiouny Nov 13, 2024
e3a8521
[Giskard] Move straight caretesian can allow gripper colllision.
AbdelrhmanBassiouny Nov 14, 2024
6bcd33e
[MultiverseBulletWorld] added an option in bullet_world to use multiv…
AbdelrhmanBassiouny Nov 15, 2024
119824c
[BugFixes] Fixed issues after merge with dev, ORM is still not working.
AbdelrhmanBassiouny Nov 19, 2024
e67e671
[FixORM] added new paramters to orm classes to match actions/motions.
AbdelrhmanBassiouny Nov 20, 2024
40d53cd
[CheckforPickedObject] a function to check if an object is currently …
AbdelrhmanBassiouny Nov 26, 2024
2a2676a
[JupyterTests] (WIP) cram_plan_tutorial has problems.
AbdelrhmanBassiouny Nov 27, 2024
95ab050
[JupyterTests] Fixed cram_plan_tutorial.md.
AbdelrhmanBassiouny Nov 27, 2024
1e4f319
[MultiverseBugFix] empty send data.
AbdelrhmanBassiouny Nov 28, 2024
6b3d824
[MultiverseGetImages] Made use of target pose to adjust camera pose.
AbdelrhmanBassiouny Nov 28, 2024
9e8a516
[MultiverseGetImages] plot is false by default
AbdelrhmanBassiouny Nov 28, 2024
6a02a2f
[MultiverseDemo] formatting
AbdelrhmanBassiouny Nov 28, 2024
6beac86
[JupyterExamples] correcting link name in multiverse case of the exam…
AbdelrhmanBassiouny Nov 28, 2024
216528c
[AccessingLocation] check for collision at the start to make search f…
AbdelrhmanBassiouny Nov 28, 2024
f087926
[JupyterTests] (WIP) location designator passes.
AbdelrhmanBassiouny Nov 29, 2024
8e15d46
[JupyterTests] All tests passed.
AbdelrhmanBassiouny Nov 29, 2024
a8dfa0a
[MultiversePycrap] used pycrap in multiverse.
AbdelrhmanBassiouny Nov 30, 2024
b4b400d
[NavigateAction] Add an option that asks if the joint states should b…
AbdelrhmanBassiouny Nov 11, 2024
ed85920
[PR2ProcessModulesPyCRAP] used pycrap in pr2 process modules.
AbdelrhmanBassiouny Nov 30, 2024
aef6b45
[MultiverseFallschoolChanges] rebased on giskard_fallschool_changes t…
AbdelrhmanBassiouny Dec 3, 2024
0097900
[MultiverseFallSchoolDemo] fixed some multiverse bugs.
AbdelrhmanBassiouny Dec 5, 2024
0f03bcd
[MultiverseFallSchoolDemo] added optional argument grasps to CostmapL…
AbdelrhmanBassiouny Dec 5, 2024
7460f59
[VizMarkerPublisher] use scale values of geometry if exists.
AbdelrhmanBassiouny Dec 5, 2024
74a19e0
[MultiverseFallschoolDemo] making review changes.
AbdelrhmanBassiouny Dec 5, 2024
368e90e
[MultiverseFallschoolDemo] making review changes.
AbdelrhmanBassiouny Dec 6, 2024
c0c5847
[Accessing] Adjusted costmap of accessing location to remove location…
AbdelrhmanBassiouny Dec 9, 2024
8b471bb
[Logging] Corrected logger name in logdebug.
AbdelrhmanBassiouny Dec 9, 2024
6fbff05
[Accessing] use costmap resolution.
AbdelrhmanBassiouny Dec 10, 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
15 changes: 10 additions & 5 deletions config/multiverse_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class MultiverseConfig(WorldConfig):
similar to bullet_world which uses the bullet physics engine.
"""

use_controller: bool = False
use_controller = use_controller and not use_static_mode
use_controller: bool = True
"""
Only used when use_static_mode is False. This turns on the controller for the robot joints.
"""
Expand All @@ -58,12 +57,14 @@ class MultiverseConfig(WorldConfig):
The default description type for the objects.
"""

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

clear_cache_at_start = False
validate_goals = True

clear_cache_at_start = True

let_pycram_move_attached_objects = False
let_pycram_handle_spawning = False
Expand All @@ -72,4 +73,8 @@ class MultiverseConfig(WorldConfig):
prismatic_joint_position_tolerance = 2e-2

use_giskard_monitor = False
allow_gripper_collision = False
allow_gripper_collision = True

use_multiverse_process_modules = True

depth_images_are_in_meter = True
12 changes: 11 additions & 1 deletion config/world_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WorldConfig:
Whether to clear the cache directory at the start.
"""

prospection_world_prefix: str = "prospection_"
prospection_world_prefix: str = "prospection"
"""
The prefix for the prospection world name.
"""
Expand Down Expand Up @@ -84,6 +84,11 @@ class WorldConfig:
Whether to use a percentage of the goal as the acceptable error.
"""

validate_goals: bool = False
"""
Whether to validate the goals when executing them.
"""

raise_goal_validator_error: bool = False
"""
Whether to raise an error if the goals are not achieved.
Expand All @@ -99,6 +104,11 @@ class WorldConfig:
Whether to allow the gripper to collide with the objects when planning for the goals.
"""

depth_images_are_in_meter: bool = False
"""
Whether the depth images produced by :meth:`datastructures.world.World.get_images_for_target` are in meters.
"""

@classmethod
def get_pose_tolerance(cls) -> Tuple[float, float]:
return cls.position_tolerance, cls.orientation_tolerance
3 changes: 2 additions & 1 deletion demos/pycram_bullet_world_demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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 pycram.ros_utils.viz_marker_publisher import VizMarkerPublisher
from pycrap import Robot, Apartment, Milk, Cereal, Spoon, Bowl
import numpy as np

Expand Down Expand Up @@ -101,4 +101,5 @@ def move_and_detect(obj_type):

ParkArmsAction([Arms.BOTH]).resolve().perform()


world.exit()
57 changes: 35 additions & 22 deletions demos/pycram_multiverse_demo/demo.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
from typing_extensions import Type

import pycrap
from pycram.datastructures.dataclasses import Color
from pycram.datastructures.enums import ObjectType, Arms, Grasp
from pycram.datastructures.enums import ObjectType, Arms, Grasp, DetectionTechnique
from pycram.datastructures.pose import Pose
from pycram.designators.action_designator import ParkArmsAction, MoveTorsoAction, TransportAction, NavigateAction, \
LookAtAction, DetectAction, OpenAction, PickUpAction, CloseAction, PlaceAction
from pycram.designators.location_designator import CostmapLocation, AccessingLocation
from pycram.designators.motion_designator import MoveArmJointsMotion, MoveTCPMotion
from pycram.designators.object_designator import BelieveObject, ObjectPart
from pycram.object_descriptors.urdf import ObjectDescription
from pycram.process_module import simulated_robot, with_simulated_robot
from pycram.robot_description import RobotDescription
from pycram.world_concepts.world_object import Object
from pycram.worlds.multiverse import Multiverse
from pycrap import PhysicalObject


@with_simulated_robot
def move_and_detect(obj_type: ObjectType, pick_pose: Pose):
NavigateAction(target_locations=[Pose([1.7, 2, 0])]).resolve().perform()

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

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

return object_desig

world = Multiverse(simulation_name='pycram_test')
world = Multiverse()
extension = ObjectDescription.get_file_extension()
robot = Object('pr2', ObjectType.ROBOT, f'pr2{extension}', pose=Pose([1.3, 2, 0.01]))
apartment = Object("apartment", ObjectType.ENVIRONMENT, f"apartment{extension}")
robot = Object('pr2', pycrap.Robot, f'pr2{extension}', pose=Pose([1.3, 2, 0.01]))
apartment = Object("apartment", pycrap.Apartment, f"apartment{extension}")

milk = Object("milk", ObjectType.MILK, f"milk.stl", pose=Pose([2.4, 2, 1.02]),
milk = Object("milk", pycrap.Milk, f"milk.xml", pose=Pose([2.4, 2, 1.02]),
color=Color(1, 0, 0, 1))

spoon = Object("spoon", ObjectType.SPOON, "spoon.stl", pose=Pose([2.5, 2.2, 0.85]),
spoon = Object("spoon", pycrap.Spoon, "spoon.xml", pose=Pose([2.5, 2.2, 0.85]),
color=Color(0, 0, 1, 1))
apartment.attach(spoon, 'cabinet10_drawer1')

Expand All @@ -47,9 +43,10 @@ def move_and_detect(obj_type: ObjectType, pick_pose: Pose):

LookAtAction(targets=[Pose([2.6, 2.15, 1])]).resolve().perform()

milk_desig = DetectAction(BelieveObject(types=[milk.obj_type])).resolve().perform()
milk_desig = DetectAction(DetectionTechnique.TYPES,
object_designator_description=BelieveObject(types=[pycrap.Milk])).resolve().perform()[0]

TransportAction(milk_desig, [Arms.LEFT], [Pose([2.4, 3, 1.02])]).resolve().perform()
TransportAction(milk_desig, [Pose([2.4, 3, 1.02])], [Arms.LEFT]).resolve().perform()

# Find and navigate to the drawer containing the spoon
handle_desig = ObjectPart(names=["cabinet10_drawer1_handle"], part_of=apartment_desig.resolve())
Expand All @@ -58,19 +55,34 @@ def move_and_detect(obj_type: ObjectType, pick_pose: Pose):

NavigateAction([drawer_open_loc.pose]).resolve().perform()

OpenAction(object_designator_description=handle_desig, arms=[drawer_open_loc.arms[0]]).resolve().perform()
spoon.detach(apartment)
OpenAction(object_designator_description=handle_desig,
arms=[drawer_open_loc.arms[0]]).resolve().perform()

arm_ee = RobotDescription.current_robot_description.get_arm_chain(drawer_open_loc.arms[0]).get_tool_frame()
closing_arm_pose = robot.get_link_pose(arm_ee)

# Detect and pickup the spoon
spoon.detach(apartment)
LookAtAction([apartment.get_link_pose("cabinet10_drawer1_handle")]).resolve().perform()

spoon_desig = DetectAction(BelieveObject(types=[ObjectType.SPOON])).resolve().perform()
spoon_desig = DetectAction(DetectionTechnique.TYPES,
object_designator_description=BelieveObject(types=[pycrap.Spoon])).resolve().perform()[0]

ParkArmsAction([Arms.BOTH]).resolve().perform()

pickup_arm = Arms.LEFT if drawer_open_loc.arms[0] == Arms.RIGHT else Arms.RIGHT
pick_up_loc = CostmapLocation(target=spoon_desig.pose, reachable_for=robot_desig.resolve(),
reachable_arm=pickup_arm, grasps=[Grasp.TOP]).resolve()

NavigateAction([pick_up_loc.pose]).resolve().perform()
MoveTCPMotion(closing_arm_pose, drawer_open_loc.arms[0]).perform()

PickUpAction(spoon_desig, [pickup_arm], [Grasp.TOP]).resolve().perform()

ParkArmsAction([Arms.LEFT if pickup_arm == Arms.LEFT else Arms.RIGHT]).resolve().perform()

NavigateAction([drawer_open_loc.pose]).resolve().perform()

CloseAction(object_designator_description=handle_desig, arms=[drawer_open_loc.arms[0]]).resolve().perform()

ParkArmsAction([Arms.BOTH]).resolve().perform()
Expand All @@ -79,7 +91,8 @@ def move_and_detect(obj_type: ObjectType, pick_pose: Pose):

# Find a pose to place the spoon, move and then place it
spoon_target_pose = Pose([2.35, 2.6, 0.95], [0, 0, 0, 1])
placing_loc = CostmapLocation(target=spoon_target_pose, reachable_for=robot_desig.resolve()).resolve()
placing_loc = CostmapLocation(target=spoon_target_pose,
reachable_for=robot_desig.resolve()).resolve()

NavigateAction([placing_loc.pose]).resolve().perform()

Expand Down
34 changes: 34 additions & 0 deletions demos/pycram_multiverse_demo/demo_euROBIN_industrial_robotics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pycrap
from pycram.datastructures.enums import GripperState, Arms
from pycram.datastructures.world import UseProspectionWorld
from pycram.process_module import simulated_robot, real_robot
from pycram.world_concepts.world_object import Object
from pycram.datastructures.pose import Pose
from pycram.worlds.multiverse import Multiverse
from pycram.designators.action_designator import SetGripperAction
from pycram.ros_utils.robot_state_updater import WorldStateUpdater


if __name__ == '__main__':
# Create a new world
world = Multiverse()
WorldStateUpdater(tf_topic="/tf", joint_state_topic="/real/ur5e/joint_states")

# Load the robot and the gripper
robot = Object("ur5e", pycrap.Robot, "universal_robot/ur5e/urdf/ur5e.urdf")
gripper = Object("gripper-2F-85", pycrap.Gripper, "robotiq/gripper-2F-85/gripper-2F-85.urdf")

# Attach the gripper to the robot at the wrist_3_link with the correct pose
wrist_3_tf_frame = robot.get_link_tf_frame("wrist_3_link")
gripper.set_pose(Pose([0, 0.1, 0], [1.0, 0.0, 0.0, -1.0], frame=wrist_3_tf_frame))
robot.attach(gripper, parent_link="wrist_3_link")

# Get the robot arms
robot_arms = [chain.arm_type for chain in robot.robot_description.get_manipulator_chains()]

# Perform the plan
with real_robot:
SetGripperAction(robot_arms, [GripperState.CLOSE]).resolve().perform()


world.exit()
87 changes: 87 additions & 0 deletions demos/pycram_multiverse_demo/fallschool_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import logging
from datetime import timedelta

import rospy
from tf.transformations import quaternion_from_euler
from typing_extensions import Type

import pycrap
from pycram.datastructures.dataclasses import Color
from pycram.datastructures.enums import Arms
from pycram.datastructures.pose import Pose
from pycram.datastructures.world import UseProspectionWorld, World
from pycram.designators.action_designator import ParkArmsAction, MoveTorsoAction, TransportAction, NavigateAction, \
LookAtAction, DetectAction
from pycram.designators.object_designator import BelieveObject
from pycram.process_module import simulated_robot, with_simulated_robot, real_robot
from pycram.ros_utils.robot_state_updater import WorldStateUpdater
from pycram.world_concepts.world_object import Object
from pycram.worlds.bullet_world import BulletWorld
from pycram.worlds.multiverse import Multiverse
from pycram.ros_utils.viz_marker_publisher import VizMarkerPublisher
from pycrap import PhysicalObject


@with_simulated_robot
def move_and_detect(obj_type: Type[PhysicalObject], pick_pose: Pose):
NavigateAction(target_locations=[Pose([1.7, 2, 0])]).resolve().perform()

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

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

return object_desig


use_bullet_world = False

if use_bullet_world:
world = BulletWorld(use_multiverse_for_real_world_simulation=True)
vis_publisher = VizMarkerPublisher()
milk_path = "milk.stl"
else:
world = Multiverse()
vis_publisher = None
milk_path = "milk.xml"

robot = Object('pr2', pycrap.Robot, f'pr2.urdf', pose=Pose([1.3, 2.6, 0.01]))
WorldStateUpdater(tf_topic="/tf", joint_state_topic="/real/pr2/joint_states", update_rate=timedelta(seconds=2),
world=world)
apartment = Object("apartment", pycrap.Apartment, f"apartment.urdf")
milk = Object("milk", pycrap.Milk, milk_path, pose=Pose([0.4, 2.6, 1.34],
[1, 0, 0, 0]),
color=Color(1, 0, 0, 1))

# apartment.set_joint_position("fridge_door1_joint", 1.5707963267948966)

fridge_base_pose = apartment.get_link_pose("fridge_base")
fridge_base_pose.position.z -= 0.12
fridge_base_pose.position.x += 0.16
fridge_base_pose.position.y += -0.1
milk.set_pose(fridge_base_pose, base=True)


robot_desig = BelieveObject(names=[robot.name])
apartment_desig = BelieveObject(names=[apartment.name])


with real_robot:

# Transport the milkMoveGripperMotion
ParkArmsAction([Arms.BOTH]).resolve().perform()

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

NavigateAction(target_locations=[Pose([1.4, 3.15, 0.01], quaternion_from_euler(0, 0, 3.14))]).resolve().perform()

LookAtAction(targets=[Pose(milk.get_position_as_list())]).resolve().perform()

milk_desig = DetectAction(BelieveObject(types=[milk.obj_type])).resolve().perform()
AbdelrhmanBassiouny marked this conversation as resolved.
Show resolved Hide resolved

TransportAction(milk_desig, [Pose([2.4, 3, 1.02])], [Arms.LEFT]).resolve().perform()

ParkArmsAction([Arms.BOTH]).resolve().perform()

if vis_publisher is not None:
vis_publisher._stop_publishing()
world.exit()
Loading