-
Notifications
You must be signed in to change notification settings - Fork 37
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
Robot infra and env #7
Conversation
Signed-off-by: youliang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some code changes to this PR. Overall, this PR should be good to go. Robot env is usually very custom to individual setup, thus there is a limit on how this serl_robot_infra
can be a generic library.
The best way for us is to document this, so that user knows how to create their own robot env, and then run it. User can optionally choose to utilize existing env_wrappers or utils in their custom robot env.
Thank you @youliangtan so much for the cleanups and suggestions! I will test the updated code on the robot tomorrow and make more improvements. |
Signed-off-by: youliang <[email protected]>
self.action_scale = (0.02, 0.2, 1) | ||
|
||
def crop_image(self, image): | ||
return image[90:390, 170:470, :] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crop_image() should be optional
self._TARGET_POSE = np.array( | ||
[ | ||
0.5668657154487453, | ||
0.002050321710641817, | ||
0.05462772570641611, | ||
# 0.9998817571282431,-0.010581843089284471,0.008902600824764906,0.0067260729646395475 | ||
3.1279511, | ||
0.0176617, | ||
0.0212859, | ||
] | ||
) | ||
self.resetpos[:3] = self._TARGET_POSE[:3] | ||
self.resetpos[2] += 0.04 | ||
self.resetpos[3:] = euler_2_quat(self._TARGET_POSE[3:]) | ||
|
||
# Bouding box | ||
self.xyz_bounding_box = gym.spaces.Box( | ||
self._TARGET_POSE[:3] | ||
- np.array([self.random_xy_range, self.random_xy_range, 0.005]), | ||
self._TARGET_POSE[:3] | ||
+ np.array([self.random_xy_range, self.random_xy_range, 0.05]), | ||
dtype=np.float32, | ||
) | ||
rpy_delta_range = np.array([0.05, 0.05, self.random_rz_range]) | ||
self.rpy_bounding_box = gym.spaces.Box( | ||
self._TARGET_POSE[3:] - rpy_delta_range, | ||
self._TARGET_POSE[3:] + rpy_delta_range, | ||
dtype=np.float32, | ||
) | ||
|
||
self._REWARD_THRESHOLD = [0.005, 0.005, 0.001, 0.1, 0.1, 0.1] | ||
self.action_scale = (0.02, 0.2, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like i said in the PR comments, we should probably get another python file and use a ConfigDict to encompass all experiment-related parameters, when we launch our experiments, we should only need python --config xxx.py
# requests.post(self.url + "pcb_compliance_mode") | ||
self.update_currpos() | ||
reset_pose = copy.deepcopy(self.currpos) | ||
reset_pose[2] += 0.03 | ||
self.interpolate_move(reset_pose, timeout=1.5) | ||
|
||
# time.sleep(2) | ||
requests.post(self.url + "precision_mode") | ||
time.sleep(1) # wait for mode switching | ||
|
||
reset_pose = self.resetpos.copy() | ||
self.interpolate_move(reset_pose, timeout=1) | ||
|
||
# perform random reset | ||
if self.randomreset: # randomize reset position in xy plane | ||
reset_pose[:2] += np.random.uniform( | ||
-self.random_xy_range, self.random_xy_range, (2,) | ||
) | ||
euler_random = self._TARGET_POSE[3:].copy() | ||
euler_random[-1] += np.random.uniform( | ||
-self.random_rz_range, self.random_rz_range | ||
) | ||
reset_pose[3:] = euler_2_quat(euler_random) | ||
self.interpolate_move(reset_pose, timeout=1) | ||
|
||
if jpos: | ||
requests.post(self.url + "precision_mode") | ||
print("JOINT RESET") | ||
requests.post(self.url + "jointreset") | ||
|
||
requests.post(self.url + "pcb_compliance_mode") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix this
] | ||
) | ||
self.resetpos[:3] = self._TARGET_POSE[:3] | ||
self.resetpos[2] += 0.1 | ||
self.resetpos[3:] = euler_2_quat(self._TARGET_POSE[3:]) | ||
|
||
# Bouding box | ||
self.xyz_bounding_box = gym.spaces.Box( | ||
self._TARGET_POSE[:3] | ||
- np.array([self.random_xy_range, self.random_xy_range, 0]), | ||
self._TARGET_POSE[:3] | ||
+ np.array([self.random_xy_range, self.random_xy_range, 0.1]), | ||
dtype=np.float32, | ||
) | ||
rpy_delta_range = np.array([0.01, 0.01, self.random_rz_range]) | ||
self.rpy_bounding_box = gym.spaces.Box( | ||
self._TARGET_POSE[3:] - rpy_delta_range, | ||
self._TARGET_POSE[3:] + rpy_delta_range, | ||
dtype=np.float32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract this away in config file
Can someone address my comment on putting env/experiment related config into a separate config file? then we can just python --config PATH_TO_CONFIG.py |
Signed-off-by: youliang <[email protected]>
@Leo428 @charlesxu0124 In 752ded1. I briefly try to split out the config by having custom configs in both peg and pcb insertion examples:
|
Signed-off-by: youliang <[email protected]>
|
||
def go_to_rest(self, jpos=False): | ||
# TODO: Implement this | ||
return NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that go_to_rest is not impl here added this TODO. Not sure if this is giving an issue.
Also I make the workspace boundary configurable in the config class. Best if we can test it on the robot to ensure everything still works fine.
Signed-off-by: youliang <[email protected]>
@youliangtan @Leo428 @charlesxu0124 are the required config changes done? |
Yes done. will need @Leo428 help to simply test it out the experiments to make sure things are not breaking. |
@Leo428 @charlesxu0124 can you test it tomorrow? then I believe we can close this PR |
We are testing it right now along with BC baseline. |
We refactor, fixed some minor mistakes, and tested the env config files. They should be good to merge now. |
Once we merge this one, I will add BC training eval scripts, pick and place task, and vice agent (if it works) in the next PR. |
@youliangtan hi youliang, can you take a look and merge it? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good! Thanks for the commit
In this PR, I added:
Soon Charles will add in a new cleaner spacemouse utils and wrappers.
Thank you for reviewing! Happy New Year!