Skip to content

Commit

Permalink
fix bathing stretch move & update dressing_env
Browse files Browse the repository at this point in the history
  • Loading branch information
shxingch committed Sep 14, 2024
1 parent 25c9eab commit 5c26911
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 27 deletions.
24 changes: 22 additions & 2 deletions pyrcareworld/pyrcareworld/envs/dressing_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,33 @@
from pyrcareworld.envs.base_env import RCareWorld
from pathlib import Path


_TEMPLATE_PATH = Path(__file__).parents[3] / "template"
_DEFAULT_EXECUTABLE_PATH = _TEMPLATE_PATH / "Dressing" / "DressingPlayer.x86_64"


class DressingEnv(RCareWorld):
"""Dressing environment for the PhyRC competition."""

# Environment-specific unity attribute IDs.
_robot_id: int = 315893
_gripper_id: int = 3158930
_camera_id: int = 654321
_cloth_id: int = 782563

def __init__(self, executable_file=str(_DEFAULT_EXECUTABLE_PATH), *args, **kwargs):
super().__init__(executable_file=executable_file, *args, **kwargs)

def get_robot(self):
"""Access the robot."""
return self.GetAttr(self._robot_id)

def get_gripper(self):
"""Access the gripper."""
return self.GetAttr(self._gripper_id)

def get_camera(self):
"""Access the camera."""
return self.GetAttr(self._camera_id)

def get_cloth(self):
"""Access the cloth."""
return self.GetAttr(self._cloth_id)
Binary file not shown.
Binary file modified template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified template/Bathing/BathingPlayer_Data/Managed/RFUniverse.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"m_buildTarget":"StandaloneLinux64","m_SettingsHash":"7ad7f27bc56e49a4067c0ba16533d8f2","m_CatalogLocations":[{"m_Keys":["AddressablesMainContentCatalogRemoteHash"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/StandaloneLinux64/catalog_2024.09.07.06.36.40.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalogCacheHash"],"m_InternalId":"{UnityEngine.Application.persistentDataPath}/com.unity.addressables/catalog_2024.09.07.06.36.40.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalog"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/catalog.json","m_Provider":"UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider","m_Dependencies":["AddressablesMainContentCatalogRemoteHash","AddressablesMainContentCatalogCacheHash"],"m_ResourceType":{"m_AssemblyName":"Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","m_ClassName":"UnityEngine.AddressableAssets.ResourceLocators.ContentCatalogData"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]}],"m_ProfileEvents":false,"m_LogResourceManagerExceptions":true,"m_ExtraInitializationData":[],"m_DisableCatalogUpdateOnStart":false,"m_IsLocalCatalogInBundle":false,"m_CertificateHandlerType":{"m_AssemblyName":"","m_ClassName":""},"m_AddressablesVersion":"1.21.21","m_maxConcurrentWebRequests":500,"m_CatalogRequestsTimeout":0}
{"m_buildTarget":"StandaloneLinux64","m_SettingsHash":"2d7c4bd96b721a504d36174c978ba6fb","m_CatalogLocations":[{"m_Keys":["AddressablesMainContentCatalogRemoteHash"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/StandaloneLinux64/catalog_2024.09.13.19.42.00.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalogCacheHash"],"m_InternalId":"{UnityEngine.Application.persistentDataPath}/com.unity.addressables/catalog_2024.09.13.19.42.00.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalog"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/catalog.json","m_Provider":"UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider","m_Dependencies":["AddressablesMainContentCatalogRemoteHash","AddressablesMainContentCatalogCacheHash"],"m_ResourceType":{"m_AssemblyName":"Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","m_ClassName":"UnityEngine.AddressableAssets.ResourceLocators.ContentCatalogData"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]}],"m_ProfileEvents":false,"m_LogResourceManagerExceptions":true,"m_ExtraInitializationData":[],"m_DisableCatalogUpdateOnStart":false,"m_IsLocalCatalogInBundle":false,"m_CertificateHandlerType":{"m_AssemblyName":"","m_ClassName":""},"m_AddressablesVersion":"1.21.21","m_maxConcurrentWebRequests":500,"m_CatalogRequestsTimeout":0}
6 changes: 3 additions & 3 deletions template/Bathing/BathingPlayer_Data/boot.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
player-connection-mode=Listen
player-connection-guid=2757552504
player-connection-guid=3553645385
player-connection-debug=0
player-connection-project-name=BathingPlayer
player-connection-ip=192.168.194.8
player-connection-ip=192.168.80.1
player-connection-ip=192.168.230.1
player-connection-ip=192.168.160.1
player-connection-ip=172.24.32.1
player-connection-ip=192.168.0.181
wait-for-native-debugger=0
hdr-display-enabled=0
gc-max-time-slice=3
force-d3d11-bitblt-model=
build-guid=02e9a24fb7284158b5043ebfe3d02b8a
build-guid=b23937a029ab44bba43305b5ce353d48
Binary file modified template/Bathing/BathingPlayer_Data/globalgamemanagers
Binary file not shown.
Binary file modified template/Bathing/BathingPlayer_Data/resources.assets
Binary file not shown.
12 changes: 6 additions & 6 deletions template/test_bathing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ def _main(use_graphics=False):
env.step(300)

gripper.GripperClose()
env.step()
env.step(300)

# Obtain sponge data and simulate a step
sponge = env.get_sponge()
env.step()
print(sponge.data)

# Camera operations: Attach a camera to the robot's hand
camera_hand = env.GetAttr(654321)
camera_hand.SetTransform(position=gripper.data['position'], rotation=[0, 0, 0])
camera_hand.SetParent(2215820)
camera_hand.GetRGB(512, 512)
camera = env.get_camera()
camera.SetTransform(position=gripper.data['position'], rotation=[0, 0, 0])
camera.SetParent(2215820)
camera.GetRGB(512, 512)
env.step()
rgb = np.frombuffer(camera_hand.data["rgb"], dtype=np.uint8)
rgb = np.frombuffer(camera.data["rgb"], dtype=np.uint8)
rgb = cv2.imdecode(rgb, cv2.IMREAD_COLOR)
cv2.imwrite("rgb_hand.png", rgb)

Expand Down
26 changes: 11 additions & 15 deletions template/test_dressing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,28 @@ def _main(use_graphics=False):
env = DressingEnv(graphics=use_graphics)
print(env.attrs)

kinova_id = 315893
robot = env.GetAttr(kinova_id)
robot = env.get_robot()
env.step()

# Get the gripper attribute and open the gripper
gripper = env.GetAttr(3158930)
gripper = env.get_gripper()
gripper.GripperOpen()
env.step(300)

gripper.GripperClose()
env.step(300)


# Get the cloth attribute and perform a simulation step
cloth = env.GetAttr(782563)
cloth = env.get_cloth()
print(cloth.data)

# Camera operations: Attach a camera to the robot's hand
camera = env.get_camera()
camera.SetTransform(position=gripper.data['position'], rotation=[-90, 90, -90])
camera.SetParent(3158930)
camera.GetRGB(512, 512)
env.step()
# print(cloth.data)

# Set the camera as a child of the robot's hand
# you can also load new cameras and set them as children of other objects in the scene
camera_hand = env.GetAttr(654321)
camera_hand.SetTransform(position=gripper.data['position'], rotation=[-90, 90, -90])
camera_hand.SetParent(3158930)
camera_hand.GetRGB(512, 512)
env.step()
rgb = np.frombuffer(camera_hand.data["rgb"], dtype=np.uint8)
rgb = np.frombuffer(camera.data["rgb"], dtype=np.uint8)
env.step()

# Random positions and rotation
Expand Down

0 comments on commit 5c26911

Please sign in to comment.