Esempio n. 1
0
 def __init__(self, *args, **kwargs):
     """    Constants:
     omega is always 0, and set a constant for background noise
     """
     
     self.Om = np.array([[1,0,0],[0,1,0],[0,0,1]])
     self.background = 2.0 #background noise
     
     """    Variables:
     These variables will be read along with the action:
     two_theta: detector's rotation about the z-axis -- assume elastic scattering, so omega is always 0
     theta: the angle at which our neutrons strike the plane
     
     These variables are the two dimensions of our problem
     chi: outer ring's rotation about the x-axis
     phi: rotation of the eulerian cradle, varies between z- and y-axis rotation depending on how much chi rotated
     
     """
     
     self.max_two_theta = 180
     self.max_chi = 90
     self.max_phi = 360
     self.min_chi = -90
     self.min_phi = 0
     self.hit = 0
     #Set up hkl and all actions
     super(UBEnv, self).__init__(self.model_path("UB.xml.mako"),*args, **kwargs)
     
     #Two independent bodies
     self.ring = find_body(self.world, "ring") #chi
     self.eu_cradle = find_body(self.world, "eu_cradle") #phi
     self.detector = find_body(self.world, "detector") #theta
     self.pivot = find_joint(self.world, "angular_axis") #pivot that enables angular movement
     Serializable.__init__(self, *args, **kwargs)    
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     super(CartpoleSwingupEnvX,
           self).__init__(self.model_path("cartpole.xml.mako"), *args,
                          **kwargs)
     self.max_cart_pos = 3
     self.max_reward_cart_pos = 3
     self.cart = find_body(self.world, "cart")
     self.pole = find_body(self.world, "pole")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 3
0
 def __init__(self, *args, **kwargs):
     super(CartpoleSwingupEnvX, self).__init__(
         self.model_path("cartpole.xml.mako"),
         *args, **kwargs
     )
     self.max_cart_pos = 3
     self.max_reward_cart_pos = 3
     self.cart = find_body(self.world, "cart")
     self.pole = find_body(self.world, "pole")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 4
0
 def __init__(self, *args, **kwargs):
     self.max_pole_angle = .2
     self.max_cart_pos = 2.4
     self.max_cart_speed = 4.
     self.max_pole_speed = 4.
     super(CartpoleEnv, self).__init__(self.model_path("cartpole.xml.mako"),
                                       *args, **kwargs)
     self.cart = find_body(self.world, "cart")
     self.pole = find_body(self.world, "pole")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 5
0
    def __init__(self, *args, **kwargs):

        #self.dt = .1    # refresh rate
        #self.on_goal = 0

        super(ArmEnv, self).__init__(self.model_path("arm.xml.mako"), *args,
                                     **kwargs)
        self.arm1 = find_body(self.world, "arm1")
        self.arm2 = find_body(self.world, "arm2")
        self.point = find_body(self.world, "point")
        Serializable.__init__(self, *args, **kwargs)
Esempio n. 6
0
 def __init__(self, *args, **kwargs):
     self.max_pole_angle = .2
     self.max_cart_pos = 2.4
     self.max_cart_speed = 4.
     self.max_pole_speed = 4.
     super(CartpoleEnv, self).__init__(
         self.model_path("cartpole.xml.mako"),
         *args, **kwargs
     )
     self.cart = find_body(self.world, "cart")
     self.pole = find_body(self.world, "pole")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 7
0
 def __init__(self, *args, **kwargs):
     # make sure mdp-level step is 100ms long
     kwargs["frame_skip"] = kwargs.get("frame_skip", 2)
     if kwargs.get("template_args", {}).get("noise", False):
         self.link_len = (np.random.rand() - 0.5) + 1
     else:
         self.link_len = 1
     kwargs["template_args"] = kwargs.get("template_args", {})
     kwargs["template_args"]["link_len"] = self.link_len
     super(ArmEnv, self).__init__(self.model_path("arm_env.xml.mako"),
                                  *args, **kwargs)
     self.arm1 = find_body(self.world, "arm1")
     self.arm2 = find_body(self.world, "arm2")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 8
0
 def __init__(self, *args, **kwargs):
     # make sure mdp-level step is 100ms long
     kwargs["frame_skip"] = kwargs.get("frame_skip", 2)
     if kwargs.get("template_args", {}).get("noise", False):
         self.link_len = (np.random.rand()-0.5) + 1
     else:
         self.link_len = 1
     kwargs["template_args"] = kwargs.get("template_args", {})
     kwargs["template_args"]["link_len"] = self.link_len
     super(DoublePendulumEnv, self).__init__(
         self.model_path("double_pendulum.xml.mako"),
         *args, **kwargs
     )
     self.link1 = find_body(self.world, "link1")
     self.link2 = find_body(self.world, "link2")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 9
0
 def __init__(self, goal_len=None, *args, **kwargs):
     # make sure mdp-level step is 100ms long
     kwargs["frame_skip"] = kwargs.get("frame_skip", 2)
     if kwargs.get("template_args", {}).get("noise", False):
         self.link_len = (np.random.rand() - 0.5) + 1
     else:
         self.link_len = 1
     if goal_len is not None:
         self.link_len = goal_len
     kwargs["template_args"] = kwargs.get("template_args", {})
     kwargs["template_args"]["link_len"] = self.link_len
     super(DoublePendulumEnvRand,
           self).__init__(self.model_path("double_pendulum.xml.mako"),
                          *args, **kwargs)
     self.link1 = find_body(self.world, "link1")
     self.link2 = find_body(self.world, "link2")
     Serializable.__init__(self, *args, **kwargs)
 def __init__(self, goal_len = None, *args, **kwargs):
     goal_len = None
     self.max_pole_angle = .2
     if goal_len == None:
         self.max_cart_pos = 2.4
     else:
         self.max_cart_pos = goal_len
     self.max_cart_speed = 4.
     self.max_pole_speed = 4.
     self.reset_range = 0.05
     super(CartpoleEnv_Rand, self).__init__(
         self.model_path("cartpole.xml.mako"),
         *args, **kwargs
     )
     self.cart = find_body(self.world, "cart")
     self.pole = find_body(self.world, "pole")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 11
0
 def __init__(self, *args, **kwargs):
     Serializable.__init__(self, *args, **kwargs)
     self.random_start = kwargs.pop("random_start", True)
     self.random_start_range = kwargs.pop("random_start_range", 1.)
     super(CarParkingEnv, self).__init__(
         self.model_path("car_parking.xml"),
         *args, **kwargs
     )
     self.goal = find_body(self.world, "goal")
     self.car = find_body(self.world, "car")
     self.wheels = [
         body for body in self.world.bodies if "wheel" in _get_name(body)]
     self.front_wheels = [
         body for body in self.wheels if "front" in _get_name(body)]
     self.max_deg = 30.
     self.goal_radius = 1.
     self.vel_thres = 1e-1
     self.start_radius = 5.
Esempio n. 12
0
 def __init__(self, height_bonus=1., goal_cart_pos=0.6, *args, **kwargs):
     super(MountainCarEnvX,
           self).__init__(self.model_path("mountain_car.xml.mako"), *args,
                          **kwargs)
     self.max_cart_pos = 2
     self.goal_cart_pos = goal_cart_pos
     self.height_bonus = height_bonus
     self.cart = find_body(self.world, "cart")
     Serializable.quick_init(self, locals())
Esempio n. 13
0
 def __init__(self, *args, **kwargs):
     Serializable.__init__(self, *args, **kwargs)
     self.random_start = kwargs.pop("random_start", True)
     self.random_start_range = kwargs.pop("random_start_range", 1.)
     super(CarParkingEnv, self).__init__(self.model_path("car_parking.xml"),
                                         *args, **kwargs)
     self.goal = find_body(self.world, "goal")
     self.car = find_body(self.world, "car")
     self.wheels = [
         body for body in self.world.bodies if "wheel" in _get_name(body)
     ]
     self.front_wheels = [
         body for body in self.wheels if "front" in _get_name(body)
     ]
     self.max_deg = 30.
     self.goal_radius = 1.
     self.vel_thres = 1e-1
     self.start_radius = 5.
Esempio n. 14
0
 def __init__(self, *args, **kwargs):
     # make sure mdp-level step is 100ms long
     kwargs["frame_skip"] = kwargs.get("frame_skip", 2)
     if kwargs.get("template_args", {}).get("noise", False):
         self.link_len = (np.random.rand() - 0.5) + 1
     else:
         self.link_len = 1
     kwargs["template_args"] = kwargs.get("template_args", {})
     kwargs["template_args"]["link_len"] = self.link_len
     super(DoublePendulumEnvX,
           self).__init__(self.model_path("double_pendulum.xml.mako"),
                          *args, **kwargs)
     self.link1 = find_body(self.world, "link1")
     self.link2 = find_body(self.world, "link2")
     self.reward_range = (-np.inf, np.inf)
     self.unwrapped = None
     self._configured = False
     self.spec.id = 'DoublePendulumEnvX'
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 15
0
    def __init__(self, *args, **kwargs):
        kwargs["frame_skip"] = kwargs.get("frame_skip", 2)
        if kwargs.get("template_args", {}).get("noise", False):
            self.link_len = (np.random.rand() - 0.5) + 1
        else:
            self.link_len = 1
        kwargs["template_args"] = kwargs.get("template_args", {})
        kwargs["template_args"]["link_len"] = self.link_len

        #self.dt = .1    # refresh rate
        #self.on_goal = 0

        super(ArmEnv, self).__init__(self.model_path("arm_env.xml.mako"),
                                     *args, **kwargs)
        self.arm1 = find_body(self.world, "arm1")
        self.arm2 = find_body(self.world, "arm2")
        self.point = find_body(self.world, "point")
        self.vertices = np.array([0.0, 0.0])
        Serializable.__init__(self, *args, **kwargs)
Esempio n. 16
0
 def __init__(self,
              height_bonus=1.,
              goal_cart_pos=0.6,
              *args, **kwargs):
     super(MountainCarEnv, self).__init__(
         self.model_path("mountain_car.xml.mako"),
         *args, **kwargs
     )
     self.max_cart_pos = 2
     self.goal_cart_pos = goal_cart_pos
     self.height_bonus = height_bonus
     self.cart = find_body(self.world, "cart")
     Serializable.quick_init(self, locals())
Esempio n. 17
0
 def __init__(self, eps_sparse=None, *args, **kwargs):
     self.eps_sparse = eps_sparse  # how far from goal we receive a reward of 1
     # make sure mdp-level step is 100ms long
     kwargs["frame_skip"] = kwargs.get("frame_skip", 2)
     if kwargs.get("template_args", {}).get("noise", False):
         self.link_len = (np.random.rand() - 0.5) + 1
     else:
         self.link_len = 1
     kwargs["template_args"] = kwargs.get("template_args", {})
     kwargs["template_args"]["link_len"] = self.link_len
     super(PendulumEnv, self).__init__(self.model_path("pendulum.xml.mako"),
                                       *args, **kwargs)
     self.link1 = find_body(self.world, "link1")
     Serializable.__init__(self, *args, **kwargs)
Esempio n. 18
0
 def __init__(self,
              opts,
              height_bonus=1.,
              goal_cart_pos=0.6,
              *args,
              **kwargs):
     xmlpath = os.path.join(os.path.dirname(__file__),
                            'mountain_car.xml.mako')
     super(SPMountainCarEnv, self).__init__(xmlpath, *args, **kwargs)
     self.opts = opts
     self.max_cart_pos = 2
     self.goal_cart_pos = goal_cart_pos
     self.height_bonus = height_bonus
     self.cart = find_body(self.world, "cart")
     Serializable.quick_init(self, locals())
     self.total_step_count = 0
     self.total_step_count_test = 0