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

OSC controller with control_delta=False does not work in 1.5.0 #562

Open
YukiShirai opened this issue Nov 15, 2024 · 1 comment
Open

OSC controller with control_delta=False does not work in 1.5.0 #562

YukiShirai opened this issue Nov 15, 2024 · 1 comment
Assignees

Comments

@YukiShirai
Copy link

System Info

Robosuite 1.5.0
Ubuntu 22.04

Information

I have been trying to run OSC controllers with control_delta=False in robosuite in 1.5.0. However, it does not move as I expected. I attached two codes below.

While I debug robosuite, I noticed that input_type is set to delta even with control_delta=False. Thus, the robot was running with delta motion while users provide position in base frame.

Once I force to set input_type=absolute, now this line complains. I think there is something wrong in action space if I force to set input_type=absolute.

When I run the very similar implementation in robosuite 1.4.1, which is attached below, I observe the expected motion, meaning that the robot moves +0.1 m along all x, y, z axes from the initialized position.

Reproduction

import robosuite as suite
import numpy as np
from robosuite.controllers.composite.composite_controller_factory import refactor_composite_controller_config

arm_controller_config = suite.load_part_controller_config(
    default_controller='OSC_POSITION',
)

options = {}

options['env_name'] = 'Door'
options['robots'] = 'UR5e'
robot = options['robots'][0] if isinstance(
    options['robots'], list,
) else options['robots']
options['initialization_noise'] = None
options['controller_configs'] = refactor_composite_controller_config(
    arm_controller_config, robot, ['right', 'left'],
)


arm_controller_config['control_delta'] = False


env = suite.make(
    **options,
    use_camera_obs=False,  # Set to True if you want camera observations
    has_offscreen_renderer=False,
    has_renderer=True,  # Enable on-screen rendering
    control_freq=200,  # Control frequency in Hz
)

obs = env.reset()
env.viewer.set_camera(camera_id=0)


target_move = 0.1  # 0.1 meters along x-axis
target = obs["robot0_eef_pos"] + np.array([target_move, target_move, target_move])

# Run a few steps to reach the target position
for i in range(1000):

    # Set desired action in absolute frame
    action = np.zeros(4)
    action[:3] = target

    # Send action to the environment
    obs, reward, done, info = env.step(action)

    # Render the environment for visualization
    env.render()


# Close the environment
env.close()
  1. Please try to run the above code in robosuite 1.5.0. The robot keeps moving and never converges to its desired state, which is +0.1 m in x, y, z axis from the initialized position.
import robosuite as suite
from robosuite.controllers import load_controller_config
import numpy as np

# Load controller configuration for OSC_POSITION
controller_config = load_controller_config(default_controller="OSC_POSITION")
controller_config['control_delta'] = False
# Create the environment with OSC_POSITION as the controller
env = suite.make(
    env_name="Lift",  # You can replace "Lift" with any other suitable task/environment
    robots="Panda",  # Choose your robot, e.g., Panda, Sawyer
    controller_configs=controller_config,
    use_camera_obs=False,  # Set to True if you want camera observations
    has_offscreen_renderer=False,
    has_renderer=True,  # Enable on-screen rendering
    control_freq=200,  # Control frequency in Hz
)

# Reset the environment
obs = env.reset()
env.viewer.set_camera(camera_id=0)  # Optional: Adjust the camera view if using GUI

# Define the movement in x-axis (positive or negative for direction)
target_x_move = 0.1  # 0.1 meters
target = obs["robot0_eef_pos"] + np.array([target_x_move, target_x_move, target_x_move])
# Run a few steps to reach the target position
for i in range(1000):  # Adjust range to control duration
    # Get the current position of the robot end-effector
    # current_pos = obs["robot0_eef_pos"]

    # Set desired action in absolute frame
    action = np.zeros(4)
    action[:3] = target

    # Send action to the environment
    obs, reward, done, info = env.step(action)

    # Render the environment for visualization
    env.render()

# Close the environment
env.close()
  1. Please try to run the above code in robosuite 1.4.1. In this code, the robot could successfully move to its desired state.

Expected behavior

The robot end-effector should converge to 0.1 m in all axes from the initialized position using robosuite 1.5.0.

@kevin-thankyou-lin
Copy link
Contributor

Thanks for raising this issue @YukiShirai! For now, I'd recommend using osc_pose and setting a fixed rotation.

@snasiriany: could you look into this one? The new osc.py logic doesn't handle osc position correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants