From 214bc9f704af3530fe56d0449f5d9fd23ba97c6e Mon Sep 17 00:00:00 2001 From: thisjustin123 Date: Wed, 17 Apr 2024 23:18:07 -0400 Subject: [PATCH] Removed deprecated examples. --- pyrcareworld/Examples/example_base_object.py | 35 ---- pyrcareworld/Examples/example_bioik.py | 10 -- pyrcareworld/Examples/example_camera.py | 51 ------ pyrcareworld/Examples/example_franka_grasp.py | 157 ------------------ pyrcareworld/Examples/example_human_joint.py | 17 -- pyrcareworld/Examples/example_load_object.py | 10 -- pyrcareworld/Examples/example_robot_move.py | 14 -- pyrcareworld/Examples/example_robot_skin.py | 63 ------- pyrcareworld/Examples/example_scene_setup.py | 6 - pyrcareworld/Examples/example_tongue.py | 7 - pyrcareworld/Examples/test_human_attr.py | 6 - 11 files changed, 376 deletions(-) delete mode 100644 pyrcareworld/Examples/example_base_object.py delete mode 100644 pyrcareworld/Examples/example_bioik.py delete mode 100644 pyrcareworld/Examples/example_camera.py delete mode 100644 pyrcareworld/Examples/example_franka_grasp.py delete mode 100644 pyrcareworld/Examples/example_human_joint.py delete mode 100644 pyrcareworld/Examples/example_load_object.py delete mode 100644 pyrcareworld/Examples/example_robot_move.py delete mode 100644 pyrcareworld/Examples/example_robot_skin.py delete mode 100644 pyrcareworld/Examples/example_scene_setup.py delete mode 100644 pyrcareworld/Examples/example_tongue.py delete mode 100644 pyrcareworld/Examples/test_human_attr.py diff --git a/pyrcareworld/Examples/example_base_object.py b/pyrcareworld/Examples/example_base_object.py deleted file mode 100644 index 0207d700..00000000 --- a/pyrcareworld/Examples/example_base_object.py +++ /dev/null @@ -1,35 +0,0 @@ -from pyrcareworld.envs import RCareWorld - -env = RCareWorld() -cube = env.create_object(id=12345, name="Cube", is_in_scene=False) -ball = env.create_object(id=67890, name="Sphere", is_in_scene=True) -cube.load() -cube.setTransform([0, 0, 0]) -env.stepSeveralSteps(5) -cube.setTransform([1, 1, 1]) -env.stepSeveralSteps(5) - - -new_cube = cube.copy(1234560) -new_cube.setTransform([0, 0, 2]) -env.stepSeveralSteps(10) -new_cube.destroy() - -for i in range(60): - cube.setTransform(rotation=[0, 0, 0 + i]) - env.stepSeveralSteps(1) - -cube.setParent(ball) -env.stepSeveralSteps(50) -cube.unsetParent() -env.stepSeveralSteps(50) - -ball.setActive(False) -env.stepSeveralSteps(50) -ball.setActive(True) -env.stepSeveralSteps(50) -ball.destroy() -env.stepSeveralSteps(50) -cube.destroy() -env.stepSeveralSteps(50) -env.close() diff --git a/pyrcareworld/Examples/example_bioik.py b/pyrcareworld/Examples/example_bioik.py deleted file mode 100644 index 177a9ca7..00000000 --- a/pyrcareworld/Examples/example_bioik.py +++ /dev/null @@ -1,10 +0,0 @@ -from pyrcareworld.envs import RCareWorld - -env = RCareWorld() -franka = env.create_robot( - id=639787, gripper_list=["6397870"], robot_name="franka_panda", base_pos=[0, 0, 1] -) -franka.BioIKMove(targetPose=[0, 0, -0.5], duration=0.1, relative=True) -franka.BioIKRotateQua(taregetEuler=[90, 0, 0], duration=30, relative=True) - -env.close() diff --git a/pyrcareworld/Examples/example_camera.py b/pyrcareworld/Examples/example_camera.py deleted file mode 100644 index 31a40582..00000000 --- a/pyrcareworld/Examples/example_camera.py +++ /dev/null @@ -1,51 +0,0 @@ -from pyrcareworld.envs import RCareWorld -import numpy as np -import pyrcareworld.utils.depth_processor as dp -import open3d as o3d -import cv2 - -env = RCareWorld(scene_file="ActiveDepth.json") -main_intrinsic_matrix = [600, 0, 0, 0, 600, 0, 240, 240, 1] -ir_intrinsic_matrix = [480, 0, 0, 0, 480, 0, 240, 240, 1] -camera = env.create_camera( - id=789789, name="camera", intrinsic_matrix=main_intrinsic_matrix -) - -nd_main_intrinsic_matrix = np.reshape(main_intrinsic_matrix, [3, 3]).T -camera.initializeRGB() -img_rgb = camera.getRGB() -cv2.imshow("show", img_rgb) -cv2.waitKey(0) - -camera.initializeDepthEXR() -img_depth_exr = camera.getDepthEXR() -camera.initializeActiveDepthWithIntrinsic(ir_intrinsic_matrix) -img_active_depth = camera.getActiveDepth() -local_to_world_matrix = camera.getLocalToWorldMatrix() - -point2 = dp.image_array_to_point_cloud_intrinsic_matrix( - img_rgb, img_active_depth, nd_main_intrinsic_matrix, local_to_world_matrix -) - -# unity space to open3d space and show -point2.transform([[-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) -print(point2) -coorninate = o3d.geometry.TriangleMesh.create_coordinate_frame() -o3d.visualization.draw_geometries([point2, coorninate]) -# env.close() - -# env2 = RCareWorld(executable_file='@Editor',) -# env2.asset_channel.set_action( -# "InstanceObject", -# name='PointCloud', -# id=123456 -# ) -# env2.instance_channel.set_action( -# "ShowPointCloud", -# id=123456, -# positions=np.array(point2.points).reshape(-1).tolist(), -# colors=np.array(point2.colors).reshape(-1).tolist(), -# ) - -for i in range(500000): - env._step() diff --git a/pyrcareworld/Examples/example_franka_grasp.py b/pyrcareworld/Examples/example_franka_grasp.py deleted file mode 100644 index 621b625c..00000000 --- a/pyrcareworld/Examples/example_franka_grasp.py +++ /dev/null @@ -1,157 +0,0 @@ -from pyrcareworld.envs import RCareWorld -import random - -env = RCareWorld() -franka = env.create_robot( - id=965874, gripper_list=["9658740"], robot_name="franka_panda", base_pos=[0, 0, 0] -) - - -# env.asset_channel.set_action("InstanceObject", name="franka_panda", id=123456) -env.instance_channel.set_action( - "SetIKTargetOffset", - id=123456, - position=[0, 0.105, 0], -) -for i in range(200): - env.step() - -env.instance_channel.set_action( - "GripperOpen", - id=1234560, -) -env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[0, 0.7, 0.5], - duration=0, - speed_based=False, -) -env.instance_channel.set_action( - "IKTargetDoRotate", - id=123456, - vector3=[0, 45, 180], - duration=0, - speed_based=False, -) -env.step() -while ( - not env.instance_channel.data[123456]["move_done"] - or not env.instance_channel.data[123456]["rotate_done"] -): - env.step() - -while 1: - env.asset_channel.set_action("InstanceObject", name="Rigidbody_Box", id=111111) - env.instance_channel.set_action( - "SetTransform", - id=111111, - position=[random.uniform(-0.5, -0.3), 0.03, random.uniform(0.3, 0.5)], - scale=[0.06, 0.06, 0.06], - ) - env.asset_channel.set_action("InstanceObject", name="Rigidbody_Box", id=222222) - env.instance_channel.set_action( - "SetTransform", - id=222222, - position=[random.uniform(0.3, 0.5), 0.03, random.uniform(0.3, 0.5)], - scale=[0.06, 0.06, 0.06], - ) - for i in range(100): - env.step() - - position1 = env.instance_channel.data[111111]["position"] - position2 = env.instance_channel.data[222222]["position"] - - env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[position1[0], position1[1] + 0.5, position1[2]], - duration=2, - speed_based=False, - ) - env.step() - while not env.instance_channel.data[123456]["move_done"]: - env.step() - env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[position1[0], position1[1], position1[2]], - duration=2, - speed_based=False, - ) - env.step() - while not env.instance_channel.data[123456]["move_done"]: - env.step() - env.instance_channel.set_action( - "GripperClose", - id=1234560, - ) - for i in range(50): - env.step() - env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[0, 0.5, 0], - duration=2, - speed_based=False, - relative=True, - ) - env.step() - while not env.instance_channel.data[123456]["move_done"]: - env.step() - env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[position2[0], position2[1] + 0.5, position2[2]], - duration=4, - speed_based=False, - ) - env.step() - while not env.instance_channel.data[123456]["move_done"]: - env.step() - env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[position2[0], position2[1] + 0.06, position2[2]], - duration=2, - speed_based=False, - ) - env.step() - while not env.instance_channel.data[123456]["move_done"]: - env.step() - env.instance_channel.set_action( - "GripperOpen", - id=1234560, - ) - for i in range(50): - env.step() - env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[0, 0.5, 0], - duration=2, - speed_based=False, - relative=True, - ) - env.step() - while not env.instance_channel.data[123456]["move_done"]: - env.step() - env.instance_channel.set_action( - "IKTargetDoMove", - id=123456, - position=[0, 0.7, 0.5], - duration=2, - speed_based=False, - ) - env.step() - while not env.instance_channel.data[123456]["move_done"]: - env.step() - env.instance_channel.set_action( - "Destroy", - id=111111, - ) - env.instance_channel.set_action( - "Destroy", - id=222222, - ) - env.step() diff --git a/pyrcareworld/Examples/example_human_joint.py b/pyrcareworld/Examples/example_human_joint.py deleted file mode 100644 index 61276e64..00000000 --- a/pyrcareworld/Examples/example_human_joint.py +++ /dev/null @@ -1,17 +0,0 @@ -import os -from pyrcareworld.envs import RCareWorld - -env = RCareWorld(executable_file="@Editor", assets=["HumanArticulation"]) - -human = env.create_human(id=123456, name="HumanArticulation", is_in_scene=False) -human.load() - -human.setBasePosition([0, 2, 0]) -human.getJointStateByName("Spine1") -env._step() -human.setJointPoisitionByNameDirectly("Neck", [20, 20, 20]) -human.setJointPoisitionByNameDirectly("Spine2", [20, 0, 0]) -env._step() -human.getJointStateByName("Spine1") -while 100: - env._step() diff --git a/pyrcareworld/Examples/example_load_object.py b/pyrcareworld/Examples/example_load_object.py deleted file mode 100644 index 2d6ae069..00000000 --- a/pyrcareworld/Examples/example_load_object.py +++ /dev/null @@ -1,10 +0,0 @@ -from pyrcareworld.envs import RCareWorld - -env = RCareWorld(executable_file="your_pth.x86_64", assets=["Cube"]) -# if mac, something like /home/cathy/Workspace/RCareUnity/Build/TestInstall/Mac/loadObject.app/Contents/MacOS/RCareWorld -cube = env.create_object(id=12345, name="Cube", is_in_scene=False) -cube.load() -for i in range(500): - env._step() - print(env.instance_channel.data) -env.close() diff --git a/pyrcareworld/Examples/example_robot_move.py b/pyrcareworld/Examples/example_robot_move.py deleted file mode 100644 index f2f703f8..00000000 --- a/pyrcareworld/Examples/example_robot_move.py +++ /dev/null @@ -1,14 +0,0 @@ -from pyrcareworld.envs import RCareWorld - -env = RCareWorld() -robot = env.create_robot( - id=315893, - gripper_list=["3158930"], - robot_name="kinova_gen3_7dof-robotiq85", - base_pos=[0, 0, 1], -) -target = env.create_object(id=315867, name="Cube", is_in_scene=True) -while True: - position = target.getPosition() - robot.directlyMoveTo(position) - env.step() diff --git a/pyrcareworld/Examples/example_robot_skin.py b/pyrcareworld/Examples/example_robot_skin.py deleted file mode 100644 index 8e790540..00000000 --- a/pyrcareworld/Examples/example_robot_skin.py +++ /dev/null @@ -1,63 +0,0 @@ -from pyrcareworld.envs import RCareWorld -import numpy as np -import pybullet as p -import math - - -class RobotSkinEnv(RCareWorld): - def __init__( - self, - executable_file: str = None, - scene_file: str = None, - custom_channels: list = [], - assets: list = [], - **kwargs - ): - RCareWorld.__init__( - self, - executable_file=executable_file, - scene_file=scene_file, - custom_channels=custom_channels, - assets=assets, - **kwargs, - ) - - # create robot - self.robot = self.create_robot(315893, [3158930], "kinova_gen3_7dof") - # create the object for pose initialization - self.init_pose_obj = self.create_object(6666, "Ini", True) - # get the position of the init_pose_obj, and later move the robot to that position - ini_world_pose = self.init_pose_obj.getPosition() - # get the rotation of the init_pose_obj, and later move the robot to that position - ini_world_rot = self.init_pose_obj.getQuaternion() - # move the robot to the position of the init_pose_obj with its rotation - self.robot.moveTo(ini_world_pose, ini_world_rot) - # close gripper - self.robot.closeGripper() - # create the skin - self.skin = self.create_skin(id=114514, name="Skin", is_in_scene=True) - - def step(self): - # get the position and rotation of the init_pose_obj - pose = self.init_pose_obj.getPosition() - rot = self.init_pose_obj.getQuaternion() - # move the robot to this object - self.robot.moveTo(pose, rot) - # get skin reading - skin_info = self.skin.getInfo() - # print it - print(skin_info) - # use self._step() to send the command to Unity - self._step() - - def demo(self): - # keep the simulation running - for i in range(10000000): - self.step() - - -if __name__ == "__main__": - # create the environment - env = RobotSkinEnv() - # run the environment - env.demo() diff --git a/pyrcareworld/Examples/example_scene_setup.py b/pyrcareworld/Examples/example_scene_setup.py deleted file mode 100644 index 5e19f869..00000000 --- a/pyrcareworld/Examples/example_scene_setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from pyrcareworld.envs import RCareWorld - -env = RCareWorld(scene_file="my_new_scene.json") -print(env.instance_channel.data) -while True: - env._step() diff --git a/pyrcareworld/Examples/example_tongue.py b/pyrcareworld/Examples/example_tongue.py deleted file mode 100644 index 922f79d7..00000000 --- a/pyrcareworld/Examples/example_tongue.py +++ /dev/null @@ -1,7 +0,0 @@ -from pyrcareworld.envs import RCareWorld - -env = RCareWorld( - executable_file="/home/cathy/Workspace/rfu_063/Build/Tongue/tongue.x86_64" -) -while True: - env._step() diff --git a/pyrcareworld/Examples/test_human_attr.py b/pyrcareworld/Examples/test_human_attr.py deleted file mode 100644 index aa6d483e..00000000 --- a/pyrcareworld/Examples/test_human_attr.py +++ /dev/null @@ -1,6 +0,0 @@ -from pyrcareworld.envs import RCareWorld - -env = RCareWorld() -for i in range(1000000): - env._step() - exit()