diff --git a/docs/modules/controllers.rst b/docs/modules/controllers.rst index ab0594440f..f3c7cf7743 100644 --- a/docs/modules/controllers.rst +++ b/docs/modules/controllers.rst @@ -222,19 +222,19 @@ Controller Settings Loading a Controller --------------------- -By default, if no controller configuration is specified during environment creation, then ``JOINT_VELOCITY`` controllers with robot-specific configurations will be used. +By default, user will use the `load_composite_controller_config()` method to create a controller configuration. Using a Default Controller Configuration ***************************************** -Any controller can be used with its default configuration, and can be easily loaded into a given environment by calling its name as shown below (where ``controller_name`` is one of acceptable controller ``type`` strings): +Any controller can be used with its default configuration, and can be easily loaded into a given environment by calling its name as shown below (where ``controller`` is one of acceptable controller ``type`` strings): .. code-block:: python import robosuite as suite - from robosuite import load_controller_config + from robosuite import load_composite_controller_config - # Load the desired controller's default config as a dict - config = load_controller_config(default_controller=controller_name) + # Load the desired controller config with default Basic controller + config = load_composite_controller_config(controller="BASIC") # Create environment env = suite.make("Lift", robots="Panda", controller_configs=config, ... ) @@ -248,13 +248,13 @@ A custom controller configuration can also be used by simply creating a new conf .. code-block:: python import robosuite as suite - from robosuite import load_controller_config + from robosuite import load_composite_controller_config # Path to config file controller_fpath = "/your/custom/config/filepath/here/filename.json" # Import the file as a dict - config = load_controller_config(custom_fpath=controller_fpath) + config = load_composite_controller_config(controller=controller_fpath) # Create environment env = suite.make("Lift", robots="Panda", controller_configs=config, ... ) diff --git a/robosuite/controllers/composite/composite_controller_factory.py b/robosuite/controllers/composite/composite_controller_factory.py index a531c1e5d2..22d0442de4 100644 --- a/robosuite/controllers/composite/composite_controller_factory.py +++ b/robosuite/controllers/composite/composite_controller_factory.py @@ -62,11 +62,11 @@ def refactor_composite_controller_config(controller_config, robot_type, arms): else: new_controller_config = {} new_controller_config["type"] = "BASIC" - new_controller_config["body_parts"] = {} + new_controller_config["body_parts_controller_configs"] = {} for arm in arms: - new_controller_config["body_parts"][arm] = copy.deepcopy(controller_config) - new_controller_config["body_parts"][arm]["gripper"] = {"type": "GRIP"} + new_controller_config["body_parts_controller_configs"][arm] = copy.deepcopy(controller_config) + new_controller_config["body_parts_controller_configs"][arm]["gripper"] = {"type": "GRIP"} return new_controller_config @@ -127,13 +127,13 @@ def load_composite_controller_config(controller: Optional[str] = None, robot: Op validate_composite_controller_config(composite_controller_config) body_parts_controller_configs = composite_controller_config.pop("body_parts_controller_configs", {}) - composite_controller_config["body_parts"] = {} + composite_controller_config["body_parts_controller_configs"] = {} for part_name, part_config in body_parts_controller_configs.items(): if part_name == "arms": for arm_name, arm_config in part_config.items(): - composite_controller_config["body_parts"][arm_name] = arm_config + composite_controller_config["body_parts_controller_configs"][arm_name] = arm_config else: - composite_controller_config["body_parts"][part_name] = part_config + composite_controller_config["body_parts_controller_configs"][part_name] = part_config return composite_controller_config diff --git a/robosuite/controllers/config/default/parts/ik_pose.json b/robosuite/controllers/config/default/parts/ik_pose.json index db6191e617..39c4346c6d 100644 --- a/robosuite/controllers/config/default/parts/ik_pose.json +++ b/robosuite/controllers/config/default/parts/ik_pose.json @@ -4,4 +4,4 @@ "ik_ori_limit": 0.05, "interpolation": null, "ramp_ratio": 0.2 - } \ No newline at end of file + } diff --git a/robosuite/controllers/config/default/parts/joint_position.json b/robosuite/controllers/config/default/parts/joint_position.json index bc25f5cb91..e0539cc5ae 100644 --- a/robosuite/controllers/config/default/parts/joint_position.json +++ b/robosuite/controllers/config/default/parts/joint_position.json @@ -12,4 +12,4 @@ "qpos_limits": null, "interpolation": null, "ramp_ratio": 0.2 - } \ No newline at end of file + } diff --git a/robosuite/controllers/config/default/parts/joint_torque.json b/robosuite/controllers/config/default/parts/joint_torque.json index 8d648428ea..320c808af0 100644 --- a/robosuite/controllers/config/default/parts/joint_torque.json +++ b/robosuite/controllers/config/default/parts/joint_torque.json @@ -7,4 +7,4 @@ "torque_limits": null, "interpolation": null, "ramp_ratio": 0.2 - } \ No newline at end of file + } diff --git a/robosuite/controllers/config/default/parts/joint_velocity.json b/robosuite/controllers/config/default/parts/joint_velocity.json index 4a9c7c86aa..1b06e82f63 100644 --- a/robosuite/controllers/config/default/parts/joint_velocity.json +++ b/robosuite/controllers/config/default/parts/joint_velocity.json @@ -8,4 +8,4 @@ "velocity_limits": [-1,1], "interpolation": null, "ramp_ratio": 0.2 - } \ No newline at end of file + } diff --git a/robosuite/controllers/config/default/parts/osc_pose.json b/robosuite/controllers/config/default/parts/osc_pose.json index 30b20677e7..94098779b8 100644 --- a/robosuite/controllers/config/default/parts/osc_pose.json +++ b/robosuite/controllers/config/default/parts/osc_pose.json @@ -15,4 +15,4 @@ "control_delta": true, "interpolation": null, "ramp_ratio": 0.2 - } \ No newline at end of file + } diff --git a/robosuite/controllers/config/default/parts/osc_position.json b/robosuite/controllers/config/default/parts/osc_position.json index c75e51238c..0eb12b667f 100644 --- a/robosuite/controllers/config/default/parts/osc_position.json +++ b/robosuite/controllers/config/default/parts/osc_position.json @@ -13,4 +13,4 @@ "control_delta": true, "interpolation": null, "ramp_ratio": 0.2 - } \ No newline at end of file + } diff --git a/robosuite/robots/fixed_base_robot.py b/robosuite/robots/fixed_base_robot.py index 27f088c761..7ec1576172 100644 --- a/robosuite/robots/fixed_base_robot.py +++ b/robosuite/robots/fixed_base_robot.py @@ -49,6 +49,7 @@ def _load_controller(self): robot_model=self.robot_model, grippers={self.get_gripper_name(arm): self.gripper[arm] for arm in self.arms}, ) + print("Loaded composite controller: {}".format(self.composite_controller)) self._load_arm_controllers() diff --git a/robosuite/robots/robot.py b/robosuite/robots/robot.py index 9a2bade2a5..ed082ec052 100644 --- a/robosuite/robots/robot.py +++ b/robosuite/robots/robot.py @@ -70,7 +70,10 @@ def __init__( self.composite_controller_config = composite_controller_config else: self.composite_controller_config = load_composite_controller_config(robot=robot_type) - self.part_controller_config = copy.deepcopy(self.composite_controller_config.get("body_parts", {})) + + self.part_controller_config = copy.deepcopy( + self.composite_controller_config.get("body_parts_controller_configs", {}) + ) self.gripper = self._input2dict(None) self.gripper_type = self._input2dict(gripper_type) @@ -145,7 +148,9 @@ def _postprocess_part_controller_config(self): Remove unused parts that are not in the controller. Called by _load_controller() function """ - for part_name, controller_config in self.composite_controller_config.get("body_parts", {}).items(): + for part_name, controller_config in self.composite_controller_config.get( + "body_parts_controller_configs", {} + ).items(): if not self.has_part(part_name): ROBOSUITE_DEFAULT_LOGGER.warn( f'The config has defined for the controller "{part_name}", ' diff --git a/robosuite/scripts/tune_joints.py b/robosuite/scripts/tune_joints.py index a77d7ef06d..b6e94ef934 100644 --- a/robosuite/scripts/tune_joints.py +++ b/robosuite/scripts/tune_joints.py @@ -275,14 +275,13 @@ def print_command(char, info): print_command("t", "Toggle between robot arms in the environment") print_command("r", "Reset active arm joints to all 0s") print_command("up/down", "incr/decrement the active joint angle") - print_command("right/left", "incr/decrement the delta joint angle per up/down keypress") print("") # Setup printing options for numbers np.set_printoptions(formatter={"float": lambda x: "{0:0.3f}".format(x)}) # Define the controller - controller_config = robosuite.load_controller_config(default_controller="JOINT_POSITION") + controller_config = robosuite.load_composite_controller_config(controller="BASIC") # make the environment env = robosuite.make( diff --git a/tests/test_controllers/test_variable_impedance.py b/tests/test_controllers/test_variable_impedance.py index 36fbdbd8d2..109124af87 100644 --- a/tests/test_controllers/test_variable_impedance.py +++ b/tests/test_controllers/test_variable_impedance.py @@ -56,7 +56,7 @@ def test_variable_impedance(): np.random.seed(3) composite_controller_config = load_composite_controller_config(controller=None, robot="Sawyer") - controller_config = composite_controller_config["body_parts"]["right"] + controller_config = composite_controller_config["body_parts_controller_configs"]["right"] controller_config["type"] = controller_name # Manually edit impedance settings controller_config["impedance_mode"] = "variable"