Example #1
0
    def __init__(
            self,
            config,
            resource_directory=os.path.dirname(os.path.abspath(__file__)) +
        '/../rsc/',
            visualizable=False):
        """
        Initialize the raisimpy_gym gym environment.

        Args:
            config (str): path to YAML configuration file.
            resource_directory (str): resource directory path. This directory should contain the URDF and meshes.
            visualizable (bool): if we should visualize or not the simulation.
        """
        # set variables
        self.resource_directory = resource_directory
        self.visualizable = visualizable
        if isinstance(config, str):
            config = load_yaml(config)
        elif not isinstance(config, dict):
            raise TypeError(
                "Expecting the given 'config' argument to be dict or a str (path to the YAML file)."
            )
        self.config = config

        # define other variables
        self.simulation_dt = 0.0025
        self.control_dt = 0.01
        self.extra_info = dict()  # {str: float}
        self.ob_dim, self.action_dim = 0, 0

        self.visualization_counter = 0
        self.visualize_this_step = visualizable
        self.desired_fps = 60.
        self.already_closed = False

        # create world
        self.world = raisim.World()
        self.world.set_time_step(self.simulation_dt)
Example #2
0
    # shadow setting
    manager = vis.get_scene_manager()
    manager.set_shadow_technique(raisim.ogre.ShadowTechnique.SHADOWTYPE_TEXTURE_ADDITIVE)
    manager.set_shadow_texture_settings(2048, 3)

    # beyond this distance, shadow disappears
    manager.set_shadow_far_distance(10)
    # size of contact points and contact forces
    vis.set_contact_visual_object_size(0.03, 0.4)
    # speed of camera motion in freelook mode
    vis.get_camera_man().set_top_speed(5)


if __name__ == '__main__':
    # create raisim world
    world = raisim.World()
    world.set_time_step(0.002)

    # these methods must be called before initApp
    vis = raisim.OgreVis.get()
    vis.set_world(world)
    vis.set_window_size(1800, 1200)
    vis.set_default_callbacks()
    vis.set_setup_callback(setup_callback)
    vis.set_anti_aliasing(8)
    raisim.gui.manual_stepping = True

    # init
    vis.init_app()

    # create raisim objects
Example #3
0
"""

__author__ = ["Jemin Hwangbo (C++)", "Brian Delhaisse (Python)"]
__copyright__ = "Copyright (c), 2019 Robotic Systems Lab, ETH Zurich"
__credits__ = [
    "Robotic Systems Lab, ETH Zurich + Hwangbo (C++ example code)",
    "Brian Delhaisse (Python wrapper + Python example)"
]
__license__ = "MIT"

import os
import time
import numpy as np
import raisimpy as raisim

sim = raisim.World()
sim.set_time_step(0.002)
checker_board = sim.add_ground()

joint_config = np.array([
    0, 0, 0.54, 1, 0, 0, 0, 0.03, 0.4, -0.8, -0.03, 0.4, -0.8, 0.03, -0.4, 0.8,
    -0.03, -0.4, 0.8
])
joint_velocity_target = np.zeros(18)
joint_state = np.zeros(18)
joint_vel = np.zeros(18)
joint_p_gain = np.zeros(18)
joint_d_gain = np.zeros(18)
position = np.zeros(3)
orientation = np.zeros([3, 3])