Skip to content

Commit

Permalink
Support setting max_velocity and max_acceleration for arms (#237)
Browse files Browse the repository at this point in the history
* support setting max_velocity and max_acceleration for arms

* fix a conflict in dataset_generator
  • Loading branch information
younggyoseo authored Jul 2, 2024
1 parent 8fc31bf commit 4c35bc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions rlbench/dataset_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def run(i, lock, task_index, variation_count, results, file_lock, tasks, args):
rlbench_env = Environment(
action_mode=MoveArmThenGripper(JointVelocity(), Discrete()),
obs_config=obs_config,
arm_max_velocity=args.arm_max_velocity,
arm_max_acceleration=args.arm_max_acceleration,
headless=True)
rlbench_env.launch()

Expand Down Expand Up @@ -287,6 +289,8 @@ def parse_args():
parser.add_argument('--processes', type=int, default=1, help='The number of parallel processes during collection.')
parser.add_argument('--episodes_per_task', type=int, default=10, help='The number of episodes to collect per task.')
parser.add_argument('--variations', type=int, default=-1, help='Number of variations to collect per task. -1 for all.')
parser.add_argument('--arm_max_velocity', type=float, default=1.0, help='Max arm velocity used for motion planning.')
parser.add_argument('--arm_max_acceleration', type=float, default=1.0, help='Max arm acceleration used for motion planning.')
return parser.parse_args()


Expand Down
11 changes: 10 additions & 1 deletion rlbench/environment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib
from functools import partial
from os.path import exists, dirname, abspath, join
from typing import Type, List

Expand Down Expand Up @@ -38,7 +39,9 @@ def __init__(self,
visual_randomization_config: VisualRandomizationConfig = None,
dynamics_randomization_config: DynamicsRandomizationConfig = None,
attach_grasped_objects: bool = True,
shaped_rewards: bool = False
shaped_rewards: bool = False,
arm_max_velocity: float = 1.0,
arm_max_acceleration: float = 4.0,
):

self._dataset_root = dataset_root
Expand All @@ -54,6 +57,8 @@ def __init__(self,
self._dynamics_randomization_config = dynamics_randomization_config
self._attach_grasped_objects = attach_grasped_objects
self._shaped_rewards = shaped_rewards
self._arm_max_velocity = arm_max_velocity
self._arm_max_acceleration = arm_max_acceleration

if robot_setup not in SUPPORTED_ROBOTS.keys():
raise ValueError('robot_configuration must be one of %s' %
Expand Down Expand Up @@ -97,6 +102,10 @@ def launch(self):

arm_class, gripper_class, _ = SUPPORTED_ROBOTS[
self._robot_setup]
arm_class = partial(
arm_class,
max_velocity=self._arm_max_velocity,
max_acceleration=self._arm_max_acceleration)

# We assume the panda is already loaded in the scene.
if self._robot_setup != 'panda':
Expand Down

0 comments on commit 4c35bc6

Please sign in to comment.