deep-rl-grasping icon indicating copy to clipboard operation
deep-rl-grasping copied to clipboard

Train on custom objects

Open SHZ2006 opened this issue 3 years ago • 16 comments

Your work is very interesting. How can I train for new custom objects or test your trained model on new objects?

SHZ2006 avatar Apr 20 '21 10:04 SHZ2006

Yes, you can do both training and testing on custom objects. I provided one different wooden block object set under model folder. You need to give the config file the name of this dataset. In this case, wooden blocks and those models will be spawned in the scene. For your custom dataset, you also need to change the base scene object sampler and add the function to sample from your custom object dataset. If it is similar to the pybullet random-urdfs object dataset you can use a similar function to this to partition the dataset to train-val-test.

BarisYazici avatar Apr 20 '21 11:04 BarisYazici

Thank you for your fast answering. I have changed in "deep-rl-grasping/config/gripper_grasp.yaml" but nothing is changed. Then I have changed the "deep-rl-grasping/trained_models/SAC_depth_1mbuffer/best_model/config.yaml" and then I saw the wooden blocks for testing. I will test for custom objects as well and let you know about the results. Thanks again.

SHZ2006 avatar Apr 20 '21 13:04 SHZ2006

Thank you for your interesting work. I am writing description for others to apply other datasets. For custom objects I have used This repository to make SDF file from YCB dataset. Then I have added This code to base_scene.py def _sample_ycb(self, n_objects): self._model_path = "models/" object_names = [ '011_banana'] selection = self._rng.choice(object_names, size=n_objects) paths = [os.path.join(self._model_path, 'ycb'+'/'+str(name), name + '.sdf') for name in selection] return paths, 1. and added object_samplers = {'ycb': self._sample_ycb, 'wooden_blocks': self._sample_wooden_blocks, 'random_urdfs': self._sample_random_objects} So if you change the data_set: ycb in any using config.yaml then you have YCB objects in the scene. I want to mention that for scaling objects you can change the number in return paths, scale in def_sample_ycb function Note: The urdf file name should be the same with object_names

SHZ2006 avatar Apr 22 '21 08:04 SHZ2006

Perfect! I am glad that you work it out. Let me know about the test results :)

BarisYazici avatar Apr 22 '21 10:04 BarisYazici

@BarisYazici Could you help me to run the code with Robot Kuka? As I run in KukaExt branch, there is also only gripper without robot. I want to know exact changes that I should do to bring whole robot.

SHZ2006 avatar Apr 27 '21 08:04 SHZ2006

@BarisYazici Second question about command ' pytest tests_gripper' when I try to run it, I get this errors:

~/RL/deep-rl-grasping-kukaExt$ pytest tests_gripper ================================================ test session starts ================================================= platform linux -- Python 3.6.13, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 rootdir: /home/lab/RL/deep-rl-grasping-kukaExt collected 0 items / 1 error

======================================================= ERRORS ======================================================= _____________________________________ ERROR collecting tests_gripper/test_sim.py _____________________________________ tests_gripper/test_sim.py:17: in env_encoder_simp = gym.make('gripper-env-v0', config=CONFIG_ENCODER_SIMP) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:145: in make return registry.make(id, **kwargs) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:90: in make env = spec.make(kwargs) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:60: in make env = cls(_kwargs) manipulation_main/gripperEnv/robot.py:110: in init config, self._camera, self) manipulation_main/gripperEnv/sensor.py:192: in init self._encoder.load_weights(model_dir) manipulation_main/gripperEnv/encoders.py:30: in load_weights self._model.load_weights(weights_path) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/keras/engine/network.py:1166: in load_weights f, self.layers, reshape=reshape) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/keras/engine/saving.py:1004: in load_weights_from_hdf5_group original_keras_version = f.attrs['keras_version'].decode('utf8') E AttributeError: 'str' object has no attribute 'decode'

SHZ2006 avatar Apr 27 '21 08:04 SHZ2006

@BarisYazici Could you help me to run the code with Robot Kuka? As I run in KukaExt branch, there is also only gripper without robot. I want to know exact changes that I should do to bring whole robot.

You need to change the robot model path under the config file

BarisYazici avatar Apr 29 '21 07:04 BarisYazici

@BarisYazici Second question about command ' pytest tests_gripper' when I try to run it, I get this errors:

~/RL/deep-rl-grasping-kukaExt$ pytest tests_gripper ================================================ test session starts ================================================= platform linux -- Python 3.6.13, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 rootdir: /home/lab/RL/deep-rl-grasping-kukaExt collected 0 items / 1 error

======================================================= ERRORS ======================================================= _____________________________________ ERROR collecting tests_gripper/test_sim.py _____________________________________ tests_gripper/test_sim.py:17: in env_encoder_simp = gym.make('gripper-env-v0', config=CONFIG_ENCODER_SIMP) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:145: in make return registry.make(id, **kwargs) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:90: in make env = spec.make(kwargs) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:60: in make env = cls(_kwargs) manipulation_main/gripperEnv/robot.py:110: in init config, self._camera, self) manipulation_main/gripperEnv/sensor.py:192: in init self._encoder.load_weights(model_dir) manipulation_main/gripperEnv/encoders.py:30: in load_weights self._model.load_weights(weights_path) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/keras/engine/network.py:1166: in load_weights f, self.layers, reshape=reshape) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/keras/engine/saving.py:1004: in load_weights_from_hdf5_group original_keras_version = f.attrs['keras_version'].decode('utf8') E AttributeError: 'str' object has no attribute 'decode'

Sorry the tests only cover the master branch. I didn't write tests for Kuka branch. But if you are interested, go ahead and do it. You can submit a pull request

BarisYazici avatar Apr 29 '21 07:04 BarisYazici

@BarisYazici Could you help me to run the code with Robot Kuka? As I run in KukaExt branch, there is also only gripper without robot. I want to know exact changes that I should do to bring whole robot.

You need to change the robot model path under the config file

It doesn't work.

SHZ2006 avatar Apr 30 '21 10:04 SHZ2006

@BarisYazici Second question about command ' pytest tests_gripper' when I try to run it, I get this errors: ~/RL/deep-rl-grasping-kukaExt$ pytest tests_gripper ================================================ test session starts ================================================= platform linux -- Python 3.6.13, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 rootdir: /home/lab/RL/deep-rl-grasping-kukaExt collected 0 items / 1 error ======================================================= ERRORS ======================================================= _____________________________________ ERROR collecting tests_gripper/test_sim.py _____________________________________ tests_gripper/test_sim.py:17: in env_encoder_simp = gym.make('gripper-env-v0', config=CONFIG_ENCODER_SIMP) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:145: in make return registry.make(id, **kwargs) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:90: in make env = spec.make(kwargs) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/gym/envs/registration.py:60: in make env = cls(_kwargs) manipulation_main/gripperEnv/robot.py:110: in init config, self._camera, self) manipulation_main/gripperEnv/sensor.py:192: in init self._encoder.load_weights(model_dir) manipulation_main/gripperEnv/encoders.py:30: in load_weights self._model.load_weights(weights_path) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/keras/engine/network.py:1166: in load_weights f, self.layers, reshape=reshape) ../../miniconda3/envs/grasp_env/lib/python3.6/site-packages/keras/engine/saving.py:1004: in load_weights_from_hdf5_group original_keras_version = f.attrs['keras_version'].decode('utf8') E AttributeError: 'str' object has no attribute 'decode'

Sorry the tests only cover the master branch. I didn't write tests for Kuka branch. But if you are interested, go ahead and do it. You can submit a pull request

I got the same error in master branch.

SHZ2006 avatar Apr 30 '21 10:04 SHZ2006

@BarisYazici Could you help me to run the code with Robot Kuka? As I run in KukaExt branch, there is also only gripper without robot. I want to know exact changes that I should do to bring whole robot.

You need to change the robot model path under the config file

It doesn't work.

Do you have the same problem? Can you post the error messages when the simulation dies?

BarisYazici avatar May 03 '21 07:05 BarisYazici

@BarisYazici Could you help me to run the code with Robot Kuka? As I run in KukaExt branch, there is also only gripper without robot. I want to know exact changes that I should do to bring whole robot.

You need to change the robot model path under the config file

It doesn't work.

Do you have the same problem? Can you post the error messages when the simulation dies?

It doesn't die, just the robot doesn't loaded when I change the config file which you mentioned file while in Kuka branch the config file is written for kuka but by the way it is not loaded and just the gripper only is loaded.

SHZ2006 avatar May 12 '21 14:05 SHZ2006

@BarisYazici Could you help me to run the code with Robot Kuka? As I run in KukaExt branch, there is also only gripper without robot. I want to know exact changes that I should do to bring whole robot.

You need to change the robot model path under the config file

It doesn't work.

Do you have the same problem? Can you post the error messages when the simulation dies?

It doesn't die, just the robot doesn't loaded when I change the config file which you mentioned file while in Kuka branch the config file is written for kuka but by the way it is not loaded and just the gripper only is loaded.

If you are trying to run a trained model then you need to change the specific config file under that model file. For example here at this file. For every model in the trained folder directory, best_model folder if you want to run that one, you need to change the respective config file under the best_model folder.

BarisYazici avatar May 12 '21 16:05 BarisYazici

@BarisYazici Could you help me to run the code with Robot Kuka? As I run in KukaExt branch, there is also only gripper without robot. I want to know exact changes that I should do to bring whole robot.

You need to change the robot model path under the config file

It doesn't work.

Do you have the same problem? Can you post the error messages when the simulation dies?

It doesn't die, just the robot doesn't loaded when I change the config file which you mentioned file while in Kuka branch the config file is written for kuka but by the way it is not loaded and just the gripper only is loaded.

If you are trying to run a trained model then you need to change the specific config file under that model file. For example here at this file. For every model in the trained folder directory, best_model folder if you want to run that one, you need to change the respective config file under the best_model folder.

The result is as follows:

Peek 2021-05-13 11-28

SHZ2006 avatar May 13 '21 08:05 SHZ2006

That seems like the wrong model of the file. The kuka model I use has another gripper. It should be this sdf model. Can you share with me your config.yaml file settings? Screen Shot 2021-05-13 at 11 00 21

BarisYazici avatar May 13 '21 09:05 BarisYazici

It was kuka_with_gripper2.sdf but for kuka_with_gripper.sdf also the same. The config file is like this:

`BDQ: batch_size: 256 buffer_size: 10000 epsilon_greedy: true exploration_final_eps: 0.02 exploration_fraction: 0.1 layers:

  • [64, 64]
  • [32]
  • [32] learning_rate: 0.00169477235301313 learning_starts: 1000 num_actions_pad: 16 prioritized_replay: true save_dir: BDQ1mSimplified target_network_update_freq: 1000 tensorboard_logs: null total_timesteps: 5000000 train_freq: 300 DDPG: {save_dir: DDPG, tensorboard_logs: DDPG, total_timesteps: 2000000} DQN: {batch_size: 32, learning_rate: 0.001, prioritized_replay: true, save_dir: DQN4mFull, tensorboard_logs: null, total_timesteps: 4000000} PPO: {learning_rate: 0.001, n_steps: 2000, save_dir: ppo_5m, tensorboard_logs: tensorboard_logs/ppo_5m, total_timesteps: 1000000} SAC: batch_size: 64 buffer_size: 1000000 layers: [64, 64] max_iters: 400 save_dir: SAC_full_rgbd step_size: 0.0003 tensorboard_logs: null total_timesteps: 5000000 TRPO: {batch_size: 64, max_iters: 400, save_dir: trpo_1m, step_size: 0.001, tensorboard_logs: tensorboard_logs/trpo_1m, total_timesteps: 5000000} algorithm: sac curriculum: extent: [0.01, 0.1] init_lambda: 0.0 lift_dist: [0.01, 0.1] max_objects: [3, 5] min_objects: [1, 1] n_steps: 8 robot_height: [0.15, 0.25] success_threshold: 0.7 window_size: 1000 depth_observation: false discount_factor: 0.99 full_observation: true normalize: true reward: {custom: true, delta_z_scale: 1000.0, grasp_reward: 100.0, shaped: true, terminal_reward: 10000.0, time_penalty: 200.0} #models/gripper/wsg50_one_motor_gripper_new.sdf, robot: {discrete: false, max_force: 100, max_translation: 0.03, max_yaw_rotation: 0.15, model_path: models/kuka_iiwa/kuka_with_gripper.sdf , num_actions_pad: 2, step_size: 0.01, yaw_step: 0.1} scene: {data_set: random_urdfs, scene_type: OnFloor} sensor: camera_info: config/camera_info.yaml encoder_dir: encoder_files/new_gripper_encoder randomize: {focal_length: 4, optical_center: 2, rotation: 0.0349, translation: 0.002} transform: config/camera_transform.yaml visualize: false simplified: false simulation: {real_time: false, visualize: false} skip_empty_initial_state: true time_horizon: 150`

SHZ2006 avatar May 13 '21 15:05 SHZ2006