Example #1
0
def build_env(enable_randomizer,
              enable_rendering,
              version=0,
              mode='train',
              control_mode='torque'):

    sim_params = locomotion_gym_config.SimulationParameters()
    sim_params.enable_rendering = enable_rendering
    gym_config = locomotion_gym_config.LocomotionGymConfig(
        simulation_parameters=sim_params)

    robot_class = laikago.Laikago

    sensors = [
        HistoricSensorWrapper(NormalizeSensorWrapper(
            wrapped_sensor=robot_sensors.MotorAngleSensor(
                num_motors=laikago.NUM_MOTORS)),
                              num_history=3),
        HistoricSensorWrapper(NormalizeSensorWrapper(
            wrapped_sensor=robot_sensors.MotorVelocitiySensor(
                num_motors=laikago.NUM_MOTORS)),
                              num_history=3),
        HistoricSensorWrapper(
            NormalizeSensorWrapper(wrapped_sensor=robot_sensors.IMUSensor()),
            num_history=3),
        HistoricSensorWrapper(NormalizeSensorWrapper(
            wrapped_sensor=robot_sensors.ToeTouchSensor(laikago.NUM_LEGS)),
                              num_history=3),
        HistoricSensorWrapper(NormalizeSensorWrapper(
            wrapped_sensor=environment_sensors.LastActionSensor(
                num_actions=laikago.NUM_MOTORS)),
                              num_history=3)
    ]

    task = eval('task.StandupTaskV{}'.format(version))(mode=mode)

    randomizers = []
    if enable_randomizer:
        randomizer = controllable_env_randomizer_from_config.ControllableEnvRandomizerFromConfig(
            verbose=False)
        randomizers.append(randomizer)

    if control_mode == 'torque':
        motor_control_mode = MotorControlMode.TORQUE
    else:
        motor_control_mode = MotorControlMode.POSITION

    init_pose = 'stand'
    env = locomotion_gym_env.LocomotionGymEnv(
        gym_config=gym_config,
        robot_class=robot_class,
        motor_control_mode=motor_control_mode,
        init_pose=init_pose,
        env_randomizers=randomizers,
        robot_sensors=sensors,
        task=task)

    env = observation_dictionary_to_array_wrapper.ObservationDictionaryToArrayWrapper(
        env)
    return env
Example #2
0
def build_env(enable_randomizer,
              enable_rendering,
              mode='train',
              version=0,
              force=True):

    sim_params = locomotion_gym_config.SimulationParameters()
    sim_params.enable_rendering = enable_rendering
    gym_config = locomotion_gym_config.LocomotionGymConfig(
        simulation_parameters=sim_params)

    robot_class = laikago.Laikago

    sensors = [
        sensor_wrappers.HistoricSensorWrapper(
            wrapped_sensor=robot_sensors.MotorAngleSensor(
                num_motors=laikago.NUM_MOTORS),
            num_history=3),
        sensor_wrappers.HistoricSensorWrapper(
            wrapped_sensor=robot_sensors.MotorVelocitiySensor(
                num_motors=laikago.NUM_MOTORS),
            num_history=3),
        sensor_wrappers.HistoricSensorWrapper(
            wrapped_sensor=robot_sensors.IMUSensor(), num_history=3),
        sensor_wrappers.HistoricSensorWrapper(
            wrapped_sensor=environment_sensors.LastActionSensor(
                num_actions=laikago.NUM_MOTORS),
            num_history=3),
        height_sensor.HeightSensor(random_height=True)
    ]

    task = eval('standupheight_task.StandupheightTaskV{}'.format(version))(
        mode=mode, force=force)

    randomizers = []
    if enable_randomizer:
        randomizer = controllable_env_randomizer_from_config.ControllableEnvRandomizerFromConfig(
            verbose=False)
        randomizers.append(randomizer)

    env = locomotion_gym_env.LocomotionGymEnv(gym_config=gym_config,
                                              robot_class=robot_class,
                                              env_randomizers=randomizers,
                                              robot_sensors=sensors,
                                              task=task)

    env = observation_dictionary_to_array_wrapper.ObservationDictionaryToArrayWrapper(
        env)
    return env