StanfordVL / OmniGibson

OmniGibson: a platform for accelerating Embodied AI research built upon NVIDIA's Omniverse engine. Join our Discord for support: https://discord.gg/bccR5vGFEx
https://behavior.stanford.edu/omnigibson/
MIT License
514 stars 52 forks source link

Investigate faster IK using something like IKFast maybe? #119

Open mjlbach opened 1 year ago

mjlbach commented 1 year ago

Replacing the IK controller with a joint controller brings up the average FPS for a basic scene from ~12 FPS to ~60 FPS on a 3090.

import ray
import os
import time
import json

import numpy as np

def collect_episode_batch():
    print(f"Beginning collect episode batch", flush=True)
    import omnigibson as og

    #Work around an omni bug, manually set GPU but don't set CUDA_VISIBLE_DEVICES (which is set by ray)
    active_gpu = 0
    print(f"Initializing OG on {active_gpu}", flush=True)
    og.initialize({"active_gpu": active_gpu})

    cfg = dict()

    # Define scene
    cfg["scene"] = {
        "type": "InteractiveTraversableScene",
        "scene_model": "Rs_int",
    }
    # Define robots
    cfg["robots"] = [
        {
            "type": "Tiago",
            "name": "skynet_robot",
            "obs_modalities": ["rgb", "depth"],
            #  "controller_config": {
            #    "arm_right": {
            #      "name": "JointController",
            #      "motor_type": "velocity",
            #      "command_input_limits": "default",
            #      "command_output_limits": "default",
            #      "use_delta_commands": False
            #     },
            #    "arm_left": {
            #      "name": "JointController",
            #      "motor_type": "velocity",
            #      "command_input_limits": "default",
            #      "command_output_limits": "default",
            #      "use_delta_commands": False
            #     }
            # },
        },
    ]

    # Define task
    cfg["task"] = {
        "type": "DummyTask",
        "termination_config": dict(),
        "reward_config": dict(),
    }

    # Create the environment
    env = og.Environment(cfg)
    print("Environment initialized", flush=True)

    # Step!
    times = []
    for idx in range(1000):
        start_step = time.time()
        env.step(env.action_space.sample())
        step_time = time.time() - start_step
        times.append(step_time)
        mean_time = np.mean(times)
        print(f"{mean_time}, {1/mean_time}")
        # print(idx, flush=True)

    return times

if __name__ == "__main__":
    collect_episode_batch()
cremebrule commented 1 year ago

This is due to random actions resulting in the IK controller often ending up near a singularity, which significantly slows down the lula IK solver for some reason. @cgokmen are you guys using a different IK solver that we could maybe try using instead?

hang-yin commented 2 months ago

Will use CuRobo