Skip to content
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

Fix part controller demo #546

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ eggs/
.eggs/
lib/
lib64/
parts/
!robosuite/controllers/parts
sdist/
var/
Expand Down
14 changes: 7 additions & 7 deletions docs/modules/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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, ... )
Expand All @@ -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, ... )
Expand Down
kevin-thankyou-lin marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to change the key from body_parts to body_parts_controller_config I think if don't do this. This PR will have less changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think updating is fine for consistency?

Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,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

Expand Down
7 changes: 7 additions & 0 deletions robosuite/controllers/config/default/parts/ik_pose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "IK_POSE",
"ik_pos_limit": 0.02,
"ik_ori_limit": 0.05,
"interpolation": null,
"ramp_ratio": 0.2
}
15 changes: 15 additions & 0 deletions robosuite/controllers/config/default/parts/joint_position.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "JOINT_POSITION",
"input_max": 1,
"input_min": -1,
"output_max": 0.05,
"output_min": -0.05,
"kp": 50,
"damping_ratio": 1,
"impedance_mode": "fixed",
"kp_limits": [0, 300],
"damping_ratio_limits": [0, 10],
"qpos_limits": null,
"interpolation": null,
"ramp_ratio": 0.2
}
10 changes: 10 additions & 0 deletions robosuite/controllers/config/default/parts/joint_torque.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "JOINT_TORQUE",
"input_max": 1,
"input_min": -1,
"output_max": 0.1,
"output_min": -0.1,
"torque_limits": null,
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/default/parts/joint_velocity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 3.0,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
18 changes: 18 additions & 0 deletions robosuite/controllers/config/default/parts/osc_pose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "OSC_POSE",
"input_max": 1,
"input_min": -1,
"output_max": [0.05, 0.05, 0.05, 0.5, 0.5, 0.5],
"output_min": [-0.05, -0.05, -0.05, -0.5, -0.5, -0.5],
"kp": 150,
"damping_ratio": 1,
"impedance_mode": "fixed",
"kp_limits": [0, 300],
"damping_ratio_limits": [0, 10],
"position_limits": null,
"orientation_limits": null,
"uncouple_pos_ori": true,
"control_delta": true,
"interpolation": null,
"ramp_ratio": 0.2
}
16 changes: 16 additions & 0 deletions robosuite/controllers/config/default/parts/osc_position.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "OSC_POSITION",
"input_max": 1,
"input_min": -1,
"output_max": [0.05, 0.05, 0.05],
"output_min": [-0.05, -0.05, -0.05],
"kp": 150,
"damping_ratio": 1,
"impedance_mode": "fixed",
"kp_limits": [0, 300],
"damping_ratio_limits": [0, 10],
"position_limits": null,
"control_delta": true,
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_baxter.json
kevin-thankyou-lin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1, 1],
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_iiwa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_jaco (copy).json
kevin-thankyou-lin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_jaco.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_kinova3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_panda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_sawyer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/default_ur5e.json
kevin-thankyou-lin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 0.03,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
7 changes: 7 additions & 0 deletions robosuite/controllers/config/parts/ik_pose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "IK_POSE",
"ik_pos_limit": 0.02,
"ik_ori_limit": 0.05,
"interpolation": null,
"ramp_ratio": 0.2
}
15 changes: 15 additions & 0 deletions robosuite/controllers/config/parts/joint_position.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "JOINT_POSITION",
"input_max": 1,
"input_min": -1,
"output_max": 0.05,
"output_min": -0.05,
"kp": 50,
"damping_ratio": 1,
"impedance_mode": "fixed",
"kp_limits": [0, 300],
"damping_ratio_limits": [0, 10],
"qpos_limits": null,
"interpolation": null,
"ramp_ratio": 0.2
}
10 changes: 10 additions & 0 deletions robosuite/controllers/config/parts/joint_torque.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "JOINT_TORQUE",
"input_max": 1,
"input_min": -1,
"output_max": 0.1,
"output_min": -0.1,
"torque_limits": null,
"interpolation": null,
"ramp_ratio": 0.2
}
11 changes: 11 additions & 0 deletions robosuite/controllers/config/parts/joint_velocity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type" : "JOINT_VELOCITY",
"input_max": 1,
"input_min": -1,
"output_max": 0.5,
"output_min": -0.5,
"kp": 3.0,
"velocity_limits": [-1,1],
"interpolation": null,
"ramp_ratio": 0.2
}
18 changes: 18 additions & 0 deletions robosuite/controllers/config/parts/osc_pose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "OSC_POSE",
"input_max": 1,
"input_min": -1,
"output_max": [0.05, 0.05, 0.05, 0.5, 0.5, 0.5],
"output_min": [-0.05, -0.05, -0.05, -0.5, -0.5, -0.5],
"kp": 150,
"damping_ratio": 1,
"impedance_mode": "fixed",
"kp_limits": [0, 300],
"damping_ratio_limits": [0, 10],
"position_limits": null,
"orientation_limits": null,
"uncouple_pos_ori": true,
"control_delta": true,
"interpolation": null,
"ramp_ratio": 0.2
}
16 changes: 16 additions & 0 deletions robosuite/controllers/config/parts/osc_position.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "OSC_POSITION",
"input_max": 1,
"input_min": -1,
"output_max": [0.05, 0.05, 0.05],
"output_min": [-0.05, -0.05, -0.05],
"kp": 150,
"damping_ratio": 1,
"impedance_mode": "fixed",
"kp_limits": [0, 300],
"damping_ratio_limits": [0, 10],
"position_limits": null,
"control_delta": true,
"interpolation": null,
"ramp_ratio": 0.2
}
2 changes: 1 addition & 1 deletion robosuite/controllers/parts/controller_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def load_part_controller_config(custom_fpath=None, default_controller=None):

# Store the default controller config fpath associated with the requested controller
custom_fpath = os.path.join(
os.path.dirname(__file__), "..", "controllers/config/parts/{}.json".format(default_controller.lower())
os.path.dirname(__file__), "..", "config/default/parts/{}.json".format(default_controller.lower())
)

# Assert that the fpath to load the controller is not empty
Expand Down
16 changes: 14 additions & 2 deletions robosuite/demos/demo_control.py
kevin-thankyou-lin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,22 @@
joint_dim = 6 if options["robots"] == "UR5e" else (16 if options["robots"] == "GR1" else 7)

# Choose controller
controller_name = choose_controller()
controller_name = choose_part_controller()
part_controller_config = suite.load_part_controller_config(default_controller=controller_name)
kevin-thankyou-lin marked this conversation as resolved.
Show resolved Hide resolved
# explicitly set the gripper type
part_controller_config["gripper"] = dict(
type="GRIP",
)

# Load the desired controller
options["controller_configs"] = suite.load_part_controller_config(default_controller=controller_name)
controller_config = dict(
type="BASIC",
body_parts_controller_configs=dict(
left=part_controller_config, # refer to arm
right=part_controller_config, # refer to arm
),
)
options["controller_configs"] = controller_config

# Define the pre-defined controller actions to use (action_dim, num_test_steps, test_value)
controller_settings = {
Expand Down
1 change: 1 addition & 0 deletions robosuite/robots/fixed_base_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Loading
Loading