forked from cram2/pycram
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cram2#227 from AbdelrhmanBassiouny/fallschool_mult…
…iverse_demo Fallschool multiverse demo + Minor Changes
- Loading branch information
Showing
65 changed files
with
2,209 additions
and
646 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
34 changes: 34 additions & 0 deletions
34
demos/pycram_multiverse_demo/demo_euROBIN_industrial_robotics.py
This file contains 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 |
---|---|---|
@@ -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() |
This file contains 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 |
---|---|---|
@@ -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() | ||
|
||
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() |
Oops, something went wrong.