예제 #1
0
def main(cfg):
    # Initialize digits
    digits = tacto.Sensor(**cfg.tacto)

    # Initialize World
    log.info("Initializing world")
    px.init()

    p.resetDebugVisualizerCamera(**cfg.pybullet_camera)

    robot = SawyerGripper(**cfg.sawyer_gripper)

    # [21, 24]
    digits.add_camera(robot.id, robot.digit_links)

    # Add object to pybullet and digit simulator
    obj = px.Body(**cfg.object)
    digits.add_body(obj)

    np.set_printoptions(suppress=True)

    # run p.stepSimulation in another thread
    t = px.utils.SimulationThread(real_time_factor=1.0)
    t.start()

    robot.reset()

    panel = px.gui.RobotControlPanel(robot)
    panel.start()

    while True:
        color, depth = digits.render()
        digits.updateGUI(color, depth)
        time.sleep(0.1)
예제 #2
0
def main(cfg):
    # Initialize digits
    bg = cv2.imread("conf/bg_digit_240_320.jpg")
    digits = tacto.Sensor(**cfg.tacto, background=bg)

    # Initialize World
    log.info("Initializing world")
    px.init()

    p.resetDebugVisualizerCamera(**cfg.pybullet_camera)

    # Create and initialize DIGIT
    digit_body = px.Body(**cfg.digit)
    digits.add_camera(digit_body.id, [-1])

    # Add object to pybullet and tacto simulator
    obj = px.Body(**cfg.object)
    digits.add_body(obj)

    # Create control panel to control the 6DoF pose of the object
    panel = px.gui.PoseControlPanel(obj, **cfg.object_control_panel)
    panel.start()
    log.info(
        "Use the slides to move the object until in contact with the DIGIT")

    # run p.stepSimulation in another thread
    t = px.utils.SimulationThread(real_time_factor=1.0)
    t.start()

    while True:
        color, depth = digits.render()
        digits.updateGUI(color, depth)

    t.stop()
def main():
    px.init()

    startPos = [0, 0, 0]
    startOrientation = p.getQuaternionFromEuler([0, 0, 0])
    boxId = p.loadURDF("resources/fingerTip.urdf", startPos, startOrientation)

    while True:
        time.sleep(0.01)
        p.stepSimulation()
예제 #4
0
    def __init__(self, config_path=_get_default_config_path()):
        px.init(mode=p.GUI)
        self.cfg = OmegaConf.load(config_path)
        self.robot = SawyerGripper(**self.cfg.sawyer_gripper)
        self.obj = px.Body(**self.cfg.object)
        self.digits = tacto.Sensor(**self.cfg.tacto)
        self.camera = Camera()
        self.viewer = None

        self.digits.add_camera(self.robot.id, self.robot.digit_links)

        self.digits.add_body(self.obj)

        self.reset()
예제 #5
0
def main():
    px.init()

    robot = px.Robot("kuka_iiwa/model.urdf")

    # Run the simulation in another thread
    t = px.utils.SimulationThread(1.0)
    t.start()

    # ControlPanel also takes pybulletX.Body
    panel = px.gui.RobotControlPanel(robot)
    panel.start()

    input("Press any key to exit ...")
예제 #6
0
def main():
    px.init()

    robot = px.Robot("kuka_iiwa/model.urdf", use_fixed_base=True)
    robot.torque_control = True

    while True:
        time.sleep(0.01)

        error = desired_joint_positions - robot.get_states().joint_position
        actions = robot.action_space.new()
        actions.joint_torque = error * P_GAIN
        robot.set_actions(actions)

        p.stepSimulation()
예제 #7
0
    def __init__(self, cfg):
        """ 
        Input: cfg contains the custom configuration of the environment
        cfg.tacto 
        cfg.settings
            show_gui=False, 
            dt=0.005, 
            action_frequency=30, 
            simulation_frequency=240, 
            max_episode_steps=500,
        """
        # Init logger
        self.logger = logging.getLogger(__name__)

        # Init logic parameters
        self.cfg = cfg
        self.show_gui = cfg.settings.show_gui
        self.dt = cfg.settings.dt
        self.action_frequency = cfg.settings.action_frequency
        self.simulation_frequency = cfg.settings.simulation_frequency
        self.max_episode_steps = cfg.settings.max_episode_steps
        self.elapsed_steps = 0

        # Set interaction parameters
        self.action_space = self.get_action_space()
        self.observation_space = self.get_observation_space()

        # Init environment
        self.logger.info("Initializing world")
        mode = p.GUI if self.show_gui else p.DIRECT
        client_id = px.init(mode=mode)
        self.physics_client = px.Client(client_id=client_id)
        p.resetDebugVisualizerCamera(**cfg.pybullet_camera)
        p.setTimeStep(1 / self.simulation_frequency)
예제 #8
0
    def __init__(self, mode: int = None, client_id: int = None):
        # should provide either mode or client_id but not both
        # mode and client_id can't be both None at the same time.
        # This is equiv. to XOR test
        assert (mode is None) != (client_id is None)

        if client_id is None:
            self._initialized_by_us = True
            self._id = px.init(mode=mode)
        else:
            self._initialized_by_us = False
            self._id = client_id
예제 #9
0
def main(cfg):
    # Initialize OmniTact
    omnitact = tacto.Sensor(
        **cfg.tacto, **{"config_path": tacto.get_omnitact_config_path()})

    # Initialize World
    log.info("Initializing world")
    px.init()

    p.resetDebugVisualizerCamera(**cfg.pybullet_camera)
    p.configureDebugVisualizer(
        p.COV_ENABLE_SHADOWS,
        1,
        lightPosition=[50, 0, 80],
    )

    # Create and initialize OmniTact
    body = px.Body(**cfg.omnitact)
    omnitact.add_camera(body.id, [-1])

    obj = px.Body(**cfg.object)
    omnitact.add_body(obj)

    # Create control panel to control the 6DoF pose of the object
    panel = px.gui.PoseControlPanel(obj, **cfg.object_control_panel)
    panel.start()
    log.info(
        "Use the slides to move the object until in contact with the OmniTact")

    # run p.stepSimulation in another thread
    t = px.utils.SimulationThread(real_time_factor=1.0)
    t.start()

    while True:
        color, depth = omnitact.render()
        omnitact.updateGUI(color, depth)

    t.stop()
예제 #10
0
def main(cfg):
    # Initialize digits
    # FIXME(poweic): this has to be done before p.connect if PYOPENGL_PLATFORM set to "egl"
    digits = tacto.Sensor(**cfg.tacto)

    # Initialize World
    log.info("Initializing world")
    px.init()

    p.resetDebugVisualizerCamera(**cfg.pybullet_camera)

    # Add allegro hand
    allegro = px.Body(**cfg.allegro)

    # Add cameras to tacto simulator
    digits.add_camera(allegro.id, cfg.digit_link_id_allegro)

    # Add object to pybullet and tacto simulator
    obj = px.Body(**cfg.object)
    digits.add_body(obj)

    # Create control panel to control the 6DoF pose of the object
    panel = px.gui.PoseControlPanel(obj, **cfg.object_control_panel)
    panel.start()

    log.info(
        "Use the slides to move the object until in contact with the DIGIT")

    # run p.stepSimulation in another thread
    t = px.utils.SimulationThread(real_time_factor=1.0)
    t.start()

    while True:
        color, depth = digits.render()
        digits.updateGUI(color, depth)

    t.stop()