-
Notifications
You must be signed in to change notification settings - Fork 18
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 #45 from empriselab/dev
Dev to main sync
- Loading branch information
Showing
5 changed files
with
133 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from pyrcareworld.envs.rcareworld_env import RCareWorld | ||
|
||
# Script to test cloth grasping. Paired with "Cloth Grasp" scene. | ||
if __name__ == "__main__": | ||
env = RCareWorld() | ||
|
||
# Create a new cloth representation. | ||
cloth = env.create_cloth(id=100, name="Cloth", is_in_scene=True) | ||
|
||
# Create a new robot. | ||
robot = env.create_robot( | ||
id=315893, | ||
# Note: "3158930" is the scene gripper id, but it seems to not work. | ||
gripper_list=[315893], | ||
robot_name="kinova_gen3_7dof-robotiq85", | ||
base_pos=[0, 0, 0], | ||
) | ||
|
||
# Note: We use a General Gripper Script on the robot to get the GripperClose() and GripperOpen() functions to have visual effect. | ||
|
||
# ... | ||
for i in range(200): | ||
env.step() | ||
|
||
# Move to pants. | ||
for i in range(100): | ||
robot.moveTo([0, 0.33, 0.477]) | ||
env.step() | ||
|
||
# Grasp. Cloth Grasper script on C# causes grasp. | ||
robot.GripperClose() | ||
|
||
# Grasp... | ||
for i in range(100): | ||
env.step() | ||
|
||
# Move up. | ||
for i in range(100): | ||
robot.moveTo([0, 0.9, 0.3]) | ||
env.step() | ||
|
||
# ... | ||
for i in range(100): | ||
env.step() | ||
|
||
# Release. | ||
robot.GripperOpen() | ||
|
||
# ... | ||
for i in range(200): | ||
env.step() |
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,35 @@ | ||
from pyrcareworld.envs.rcareworld_env import RCareWorld | ||
import random | ||
|
||
# Script to test cloth initial positions. | ||
if __name__ == "__main__": | ||
env = RCareWorld() | ||
|
||
# Create a new cloth representation. | ||
cloth = env.create_cloth(id=100, name="Cloth", is_in_scene=True) | ||
|
||
# Every 200th step, sets the cloth particles to a random position in a cube around some random point in the scene. | ||
step = 0 | ||
for _ in range(10000): | ||
env.step() | ||
step += 1 | ||
|
||
if step % 200 == 0: | ||
# Make a random 3 vector in the range of [0, 1]. | ||
random_pos = [random.uniform(0, 1) for _ in range(3)] | ||
|
||
positions = [] | ||
|
||
# There happens to be 705 particles in this scene. | ||
for _ in range(705): | ||
random_relative_pos = [random.uniform(-0.2, 0.2) for _ in range(3)] | ||
|
||
my_pos = [a + b for a, b in zip(random_pos, random_relative_pos)] | ||
|
||
# Add the new position to the list. | ||
positions.append(my_pos) | ||
|
||
# Convert the list of positions to a mapping. | ||
positions = dict(enumerate(positions)) | ||
|
||
cloth.initializeParticlePositions(positions) |
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