Example #1
0
    def test_frame(self):
        # Given
        s = visual.sphere()
        a = visual.arrow()
        f = visual.frame(s, a)

        # Then
        axis = (1.0, 0, 0)
        assert_allclose(s.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(a.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(f.axis, axis, rtol=0, atol=1e-15)

        # When
        axis = (0, 1.0, 0.0)
        f.axis = axis

        # Then
        assert_allclose(s.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(a.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(f.axis, axis, rtol=0, atol=1e-15)

        # When
        pos = (1., 1.0, 1.0)
        f.pos = pos

        # Then
        assert_allclose(s.pos, pos, rtol=0, atol=1e-15)
        assert_allclose(a.pos, pos, rtol=0, atol=1e-15)
        assert_allclose(f.pos, pos, rtol=0, atol=1e-15)
Example #2
0
    def test_frame(self):
        # Given
        s = visual.sphere()
        a = visual.arrow()
        f = visual.frame(s, a)

        # Then
        axis = (1.0, 0, 0)
        assert_allclose(s.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(a.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(f.axis, axis, rtol=0, atol=1e-15)

        # When
        axis = (0, 1.0, 0.0)
        f.axis = axis

        # Then
        assert_allclose(s.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(a.axis, axis, rtol=0, atol=1e-15)
        assert_allclose(f.axis, axis, rtol=0, atol=1e-15)

        # When
        pos = (1., 1.0, 1.0)
        f.pos = pos

        # Then
        assert_allclose(s.pos, pos, rtol=0, atol=1e-15)
        assert_allclose(a.pos, pos, rtol=0, atol=1e-15)
        assert_allclose(f.pos, pos, rtol=0, atol=1e-15)
Example #3
0
    def __init__(self,
                 wp_list,
                 np_file='/tmp/magnetic_ground_truth.np',
                 width=800,
                 height=600):
        self.debug = True

        self.width = width
        self.height = height

        self.wp_list = wp_list

        self.f = mlab.figure(size=(self.width, self.height))
        visual.set_viewer(self.f)

        v = mlab.view(135, 180)

        self.balls = []
        self.trajectories = []

        colors = list(RoiSimulator.color_codes)
        color_black = colors.pop(0)
        color_red = colors.pop(0)

        wp_curve = visual.curve(color=color_red,
                                radius=RoiSimulator.curve_radius)
        hist_pos = []

        for i in xrange(len(self.wp_list)):
            ball = visual.sphere(color=color_black,
                                 radius=RoiSimulator.ball_radius)
            wp = self.wp_list[i]

            ball.x = wp[1]
            ball.y = wp[0]
            ball.z = wp[2]

            self.balls.append(ball)

            arr = visual.vector(float(wp[1]), float(wp[0]), float(wp[2]))
            hist_pos.append(arr)

        wp_curve.extend(hist_pos)

        x = np.linspace(0, self.width, 1)
        y = np.linspace(0, self.height, 1)

        z = np.loadtxt(np_file)
        z *= 255.0 / z.max()

        # HARDCODED
        # Todo: REMOVE THIS CODE ON THE FINAL RELEASE
        for xx in xrange(0, 200):
            for yy in xrange(400, 600):
                z[yy][xx] = 0
        mlab.surf(x, y, z)
    def __init__(self, hex_list, np_file='/tmp/magnetic_ground_truth.np', robot_height=40, width=800, height=600,
                 start_point=(0, 0, 0), message='experiment default message...'):
        self.debug = False
        self.animator = None
        self.movement_mode = 0
        self.start_point = start_point
        self.robot_height = robot_height
        self.message = message

        self.start_time = int(time.time() * 1000)

        self.width = width
        self.height = height

        self.f = mlab.figure(size=(self.width, self.height))
        visual.set_viewer(self.f)

        v = mlab.view(270, 180)
        #print v

        engine = mlab.get_engine()
        self.s = engine.current_scene
        self.s.scene.interactor.add_observer('KeyPressEvent', self.keypress_callback)

        self.robots = []

        colors = list(PathBatterySimulator.color_codes)

        for key, local_hex_list in sorted(hex_list['internal_routes'].items()):
            color = colors.pop(0)

            ball = visual.sphere(color=color, radius=PathBatterySimulator.ball_radius)
            ball.x = self.start_point[0]
            ball.y = self.start_point[1]
            ball.z = self.start_point[2]

            r, g, b = color
            rt = r + (0.25 * (1 - r))
            gt = g + (0.25 * (1 - g))
            bt = b + (0.25 * (1 - b))
            curve_color = (rt, gt, bt)

            curve = visual.curve(color=curve_color, radius=PathBatterySimulator.curve_radius)

            r_ball = RobotBall(key, local_hex_list, hex_list['external_routes'][key], ball, curve)
            self.robots.append(r_ball)

        x = np.linspace(0, self.width, 1)
        y = np.linspace(0, self.height, 1)

        z = np.loadtxt(np_file)
        z *= 255.0/z.max()
        mlab.surf(x, y, z)

        self.master_cmd = MasterCommand(self.robots)
Example #5
0
    def __init__(self,
                 hex_list,
                 np_file='/tmp/magnetic_ground_truth.np',
                 robot_height=40,
                 width=800,
                 height=600,
                 start_point=(0, 0, 0)):
        self.debug = False
        self.animator = None
        self.movement_mode = 0
        self.start_point = start_point
        self.robot_height = robot_height

        self.width = width
        self.height = height

        self.f = mlab.figure(size=(self.width, self.height))
        visual.set_viewer(self.f)

        v = mlab.view(270, 180)
        #print v

        engine = mlab.get_engine()
        s = engine.current_scene
        s.scene.interactor.add_observer('KeyPressEvent',
                                        self.keypress_callback)

        self.robots = []

        colors = list(PathRobustSimulator.color_codes)

        for key, local_hex_list in sorted(hex_list['internal_routes'].items()):
            color = colors.pop(0)

            ball = visual.sphere(color=color,
                                 radius=PathRobustSimulator.ball_radius)
            ball.x = self.start_point[0]
            ball.y = self.start_point[1]
            ball.z = self.start_point[2]

            curve = visual.curve(color=color,
                                 radius=PathRobustSimulator.curve_radius)

            r_ball = RobotBall(key, local_hex_list,
                               hex_list['external_routes'][key], ball, curve)
            self.robots.append(r_ball)

        x = np.linspace(0, self.width, 1)
        y = np.linspace(0, self.height, 1)

        z = np.loadtxt(np_file)
        z *= 255.0 / z.max()
        mlab.surf(x, y, z)

        self.master_cmd = MasterCommand(self.robots)
Example #6
0
    def test_sphere(self):
        # When
        s = visual.sphere()

        # Then

        # The discrete representation of the sphere makes the bounds a bit
        # smaller than one would expect.
        assert_allclose(s.polydata.bounds, (-0.5, 0.5, -0.5, 0.5, -0.5, 0.5), rtol=1e-2)
        self.assertEqual(s.radius, 0.5)

        # When
        s = visual.sphere(pos=(1.0, 1.0, 1.0))
        # Then
        assert_allclose(s.polydata.bounds, (0.5, 1.5, 0.5, 1.5, 0.5, 1.5), rtol=1e-2)

        # When
        s = visual.sphere(x=1.0)
        # Then
        assert_allclose(s.polydata.bounds, (0.5, 1.5, -0.5, 0.5, -0.5, 0.5), rtol=1e-2)
Example #7
0
    def test_sphere(self):
        # When
        s = visual.sphere()

        # Then

        # The discrete representation of the sphere makes the bounds a bit
        # smaller than one would expect.
        assert_allclose(s.polydata.bounds,
                        (-0.5, 0.5, -0.5, 0.5, -0.5, 0.5), rtol=1e-2)
        self.assertEqual(s.radius, 0.5)

        # When
        s = visual.sphere(pos=(1.0, 1.0, 1.0))
        # Then
        assert_allclose(s.polydata.bounds,
                        (0.5, 1.5, 0.5, 1.5, 0.5, 1.5), rtol=1e-2)

        # When
        s = visual.sphere(x=1.0)
        # Then
        assert_allclose(s.polydata.bounds,
                        (0.5, 1.5, -0.5, 0.5, -0.5, 0.5), rtol=1e-2)
Example #8
0
    def __init__(self,
                 wp_list,
                 hex_list,
                 robot_height=40,
                 np_file='/tmp/magnetic_ground_truth.np',
                 width=800,
                 height=600,
                 start_point=(0, 0, 0)):
        self.debug = True
        self.movement_mode = 0
        self.start_point = start_point
        self.robot_height = robot_height

        self.width = width
        self.height = height

        self.wp_list = wp_list
        self.index_list = []
        self.history = []
        self.last_positions = []

        self.f = mlab.figure(size=(self.width, self.height))
        visual.set_viewer(self.f)

        self.balls = []
        self.trajectories = []

        colors = list(PathSimulator.color_codes)

        for i in xrange(len(self.wp_list)):
            color = colors.pop(0)
            ball = visual.sphere(color=color, radius=PathSimulator.ball_radius)
            ball.x = self.start_point[0]
            ball.y = self.start_point[1]
            ball.z = self.start_point[2]

            self.balls.append(ball)
            self.trajectories.append(
                visual.curve(color=color, radius=PathSimulator.curve_radius))
            self.index_list.append(0)
            self.history.append([])
            self.last_positions.append(self.start_point)

        x = np.linspace(0, self.width, 1)
        y = np.linspace(0, self.height, 1)

        self.z = np.loadtxt(np_file)
        self.z *= 255.0 / self.z.max()
        mlab.surf(x, y, self.z)
    def __init__(self, wp_list, np_file='/tmp/magnetic_ground_truth.np', width=800, height=600):
        self.debug = True

        self.width = width
        self.height = height

        self.wp_list = wp_list

        self.f = mlab.figure(size=(self.width, self.height))
        visual.set_viewer(self.f)

        self.balls = []
        self.trajectories = []

        colors = list(RoiSimulator.color_codes)
        color_black = colors.pop(0)
        color_red = colors.pop(0)

        wp_curve = visual.curve(color=color_red, radius=RoiSimulator.curve_radius)
        hist_pos = []

        for i in xrange(len(self.wp_list)):
            ball = visual.sphere(color=color_black, radius=RoiSimulator.ball_radius)
            wp = self.wp_list[i]

            ball.x = wp[1]
            ball.y = wp[0]
            ball.z = wp[2]

            self.balls.append(ball)

            arr = visual.vector(float(wp[1]), float(wp[0]), float(wp[2]))
            hist_pos.append(arr)

        wp_curve.extend(hist_pos)

        x = np.linspace(0, self.width, 1)
        y = np.linspace(0, self.height, 1)

        z = np.loadtxt(np_file)
        z *= 255.0/z.max()
        mlab.surf(x, y, z)
Example #10
0
def main():
    # Creating parameters for box size
    side = 4.0
    thk = 0.3
    s2 = 2 * side - thk
    s3 = 2 * side + thk
    # Creating the 6 walls
    wallR = box(pos=(side, 0, 0), size=(thk, s3, s2), color=(1, 0, 0))
    wallL = box(pos=(-side, 0, 0), size=(thk, s3, s2), color=(1, 0, 0))
    wallB = box(pos=(0, -side, 0), size=(s3, thk, s3), color=(0, 0, 1))
    wallT = box(pos=(0, side, 0), size=(s3, thk, s3), color=(0, 0, 1))
    wallBK = box(pos=(0, 0, -side), size=(s2, s2, thk), color=(0.7, 0.7, 0.7))
    # Creating the ball
    ball = sphere(radius=0.4, color=(0, 1, 0))
    ball.vector = vector(-0.15, -0.23, 0.27)

    side = side - thk * 0.5 - ball.radius

    ball.t = 0.0
    ball.dt = 0.5

    def anim():
        #Creating the animation function which will be called at
        #uniform timeperiod through the iterate function
        ball.t = ball.t + ball.dt
        ball.pos = ball.pos + ball.vector * ball.dt
        if not (side > ball.x > -side):
            ball.vector.x = -ball.vector.x
        if not (side > ball.y > -side):
            ball.vector.y = -ball.vector.y
        if not (side > ball.z > -side):
            ball.vector.z = -ball.vector.z

    a = iterate(20, anim)
    show()
    return a
Example #11
0
def main():
    # Creating parameters for box size
    side = 4.0
    thk = 0.3
    s2 = 2*side - thk
    s3 = 2*side + thk
    # Creating the 6 walls
    wallR = box( pos = (side, 0, 0), size = (thk, s3, s2), color = (1, 0, 0))
    wallL = box( pos = (-side, 0, 0), size = (thk, s3, s2), color = (1, 0, 0))
    wallB = box( pos = (0, -side, 0), size = (s3, thk, s3), color = (0, 0, 1))
    wallT = box( pos = (0, side, 0), size = (s3, thk, s3), color = (0, 0, 1))
    wallBK = box( pos = (0, 0, -side), size = (s2, s2, thk), color = (0.7,0.7,0.7))
    # Creating the ball
    ball = sphere(radius = 0.4, color = (0, 1, 0))
    ball.vector = vector(-0.15, -0.23, 0.27)

    side = side -thk*0.5 - ball.radius

    ball.t = 0.0
    ball.dt = 0.5

    def anim():
        #Creating the animation function which will be called at
        #uniform timeperiod through the iterate function
        ball.t = ball.t + ball.dt
        ball.pos = ball.pos + ball.vector*ball.dt
        if not (side > ball.x > -side):
            ball.vector.x = -ball.vector.x
        if not (side > ball.y > -side):
            ball.vector.y = -ball.vector.y
        if not (side > ball.z > -side):
            ball.vector.z =  -ball.vector.z

    a = iterate(20, anim)
    show()
    return a
Example #12
0
    box (pos = (xx,yy,zz), length=x, height=y, width=z,
         color=(red,green,blue))

def wirecube(s):
    c = curve(color = (1,1,1), radius=1)
    pts = [(-s, -s, -s),(-s, -s, s), (-s, s, s),
           (-s, s, -s), (-s, -s, -s), (s, -s, -s),
           (s, s, -s), (-s, s, -s), (s, s, -s),
           (s, s, s), (-s, s, s), (s, s, s),
           (s, -s, s), (-s, -s, s), (s, -s, s),(s, -s, -s)]
    for pt in pts:
        c.append(pt)

side = 150.0
cube = box(size = (side,side,side), representation = 'w' )
i = 0
while i < 100:
    random_box()
    i = i + 1

arrow(axis=(0,12,0), radius_shaft=3.5, color = (1,0,0))

ball = sphere(pos=(-side/2.,-side/2.,-side/2.),color=(1,1,0),radius=3)
disk = cylinder(pos=(side/2.,side/2.,-side/2.),color=(.3,.3,1),axis=(1,1,0),radius=5)
xx = arange(0,4*pi,pi/10.)
spring=curve(color=(1,.7,.1), radius=0.4)
for y in xx:
    spring.append([20+cos(2*y), y/2.-30, -20+sin(2*y)+30])

show()
Example #13
0
#CONSTANTES
#Ancho de la mesa
ancho = 1.2
#Largo de la mesa
largo = 2.4
#Grosor de los muros del billar
grosor = 0.1
#Radio bola 1
r1 = 0.05
#Radio bola 2
r2 = 0.05
#Radio bola 3
r3 = 0.05

#Creando bola 1
bola1 = visual.sphere(radius=r1, color=(1.0, 1.0, 1.0))
bola1.pos = [0., 0., 0.]
bola1.t = 0
bola1.dt = 1

#Creando bola 2
bola2 = visual.sphere(radius=r2, color=(1.0, 1.0, 1.0))
bola2.pos = [0., 0., 0.]
bola2.t = 0
bola2.dt = 1

#Creando bola 1
bola3 = visual.sphere(radius=r3, color=(1.0, 1.0, 1.0))
bola3.pos = [0., 0., 0.]
bola3.t = 0
bola3.dt = 1
Example #14
0
	def __init__(self,Dlist): # czerwony + , niebieski -
		self.VisPoints = [ [visual.sphere(x=D.r1[0],y=D.r1[1],z=D.r1[2],color=visual.color.red,radius=D.l/2**0.5),visual.sphere(x=D.r2[0],y=D.r2[1],z=D.r2[2],color=visual.color.blue,radius=D.l/2**0.5)] for D in Dlist]
Example #15
0
    pts = [(-s, -s, -s), (-s, -s, s), (-s, s, s), (-s, s, -s), (-s, -s, -s),
           (s, -s, -s), (s, s, -s), (-s, s, -s), (s, s, -s), (s, s, s),
           (-s, s, s), (s, s, s), (s, -s, s), (-s, -s, s), (s, -s, s),
           (s, -s, -s)]
    for pt in pts:
        c.append(pt)


side = 150.0
cube = box(size=(side, side, side), representation='w')
i = 0
while i < 100:
    random_box()
    i = i + 1

arrow(axis=(0, 12, 0), radius_shaft=3.5, color=(1, 0, 0))

ball = sphere(pos=(-side / 2., -side / 2., -side / 2.),
              color=(1, 1, 0),
              radius=3)
disk = cylinder(pos=(side / 2., side / 2., -side / 2.),
                color=(.3, .3, 1),
                axis=(1, 1, 0),
                radius=5)
xx = arange(0, 4 * pi, pi / 10.)
spring = curve(color=(1, .7, .1), radius=0.4)
for y in xx:
    spring.append([20 + cos(2 * y), y / 2. - 30, -20 + sin(2 * y) + 30])

show()
    def __init__(self,
                 hex_list,
                 np_file='/tmp/magnetic_ground_truth.np',
                 robot_height=40,
                 width=800,
                 height=600,
                 start_point=(0, 0, 0),
                 message='experiment default message...',
                 battery=99999):
        self.debug = False
        self.animator = None
        self.movement_mode = 0
        self.start_point = start_point
        self.robot_height = robot_height
        self.message = message

        self.start_time = int(time.time() * 1000)
        self.timestep = 0

        self.width = width
        self.height = height

        self.f = mlab.figure(size=(self.width, self.height))
        visual.set_viewer(self.f)

        v = mlab.view(270, 180)
        #print v

        engine = mlab.get_engine()
        self.s = engine.current_scene
        self.s.scene.interactor.add_observer('KeyPressEvent',
                                             self.keypress_callback)

        self.robots = []

        colors = list(PathBatterySimulator.color_codes)

        for key, local_hex_list in sorted(hex_list['internal_routes'].items()):
            color = colors.pop(0)

            ball = visual.sphere(color=color,
                                 radius=PathBatterySimulator.ball_radius)
            ball.x = self.start_point[0]
            ball.y = self.start_point[1]
            ball.z = self.start_point[2]

            r, g, b = color
            rt = r + (0.25 * (1 - r))
            gt = g + (0.25 * (1 - g))
            bt = b + (0.25 * (1 - b))
            curve_color = (rt, gt, bt)

            curve = visual.curve(color=curve_color,
                                 radius=PathBatterySimulator.curve_radius)

            r_ball = RobotBall(key,
                               local_hex_list,
                               hex_list['external_routes'][key],
                               ball,
                               curve,
                               battery=battery)
            self.robots.append(r_ball)

        x = np.linspace(0, self.width, 1)
        y = np.linspace(0, self.height, 1)

        z = np.loadtxt(np_file)
        z *= 255.0 / z.max()

        # HARDCODED
        # Todo: REMOVE THIS CODE ON THE FINAL RELEASE
        for xx in xrange(0, 200):
            for yy in xrange(400, 600):
                z[yy][xx] = 0

        mlab.surf(x, y, z)

        self.master_cmd = MasterCommand(self.robots)

        self.robot_pos = open('/tmp/robot_log.txt', 'a')
#CONSTANTES
#Ancho de la mesa
ancho = 1.2
#Largo de la mesa
largo = 2.4
#Grosor de los muros del billar
grosor = 0.1
#Radio bola 1
r1 = 0.05
#Radio bola 2
r2 = 0.05
#Radio bola 3
r3 = 0.05

#Creando bola 1
bola1 = visual.sphere( radius=r1, color=(1.0, 1.0, 1.0) )
bola1.pos = [ 0., 0., 0. ]
bola1.t = 0
bola1.dt = 1

#Creando bola 2
bola2 = visual.sphere( radius=r2, color=(1.0, 1.0, 1.0) )
bola2.pos = [ 0., 0., 0. ]
bola2.t = 0
bola2.dt = 1

#Creando bola 1
bola3 = visual.sphere( radius=r3, color=(1.0, 1.0, 1.0) )
bola3.pos = [ 0., 0., 0. ]
bola3.t = 0
bola3.dt = 1
Example #18
0
#!/usr/bin/env python
"""A simple example demonstrating the creation of actors and animating
the in a scene using visual modeule."""
# Author: Raashid Baig <*****@*****.**>
# License: BSD Style.

from math import sqrt

from tvtk.tools.visual import sphere, iterate, show, vector, curve

#Creating the actors for the scene
giant = sphere(pos=(-1.0e11, 0, 0), radius=2e10, color=(1, 0, 0), mass=2e30)

dwarf = sphere(pos=(1.5e11, 0, 0), radius=1e10, color=(1, 1, 0), mass=1e30)

giant.p = vector(0, 0, -1e4) * giant.mass
dwarf.p = -1 * giant.p

# creating the curve which will trace the paths of actors
for a in [giant, dwarf]:
    a.orbit = curve(radius=2e9, color=a.color)

dt = 86400


def anim():
    #Creating the animation function which will be called at
    #uniform timeperiod through the iterate function
    dist = dwarf.pos - giant.pos
    force = 6.7e-11 * giant.mass * dwarf.mass * \
        dist/(sqrt(dist[0]**2 + dist[1]**2 + dist[2]**2))**3
Example #19
0
#!/usr/bin/env python
"""A simple example demonstrating the creation of actors and animating
the in a scene using visual modeule."""
# Author: Raashid Baig <*****@*****.**>
# License: BSD Style.

from math import sqrt

from tvtk.tools.visual import sphere, iterate, show, vector, curve

#Creating the actors for the scene
giant = sphere(pos=(-1.0e11, 0, 0),
               radius=2e10,
               color=(1, 0, 0),
               mass=2e30)

dwarf = sphere(pos=(1.5e11, 0, 0),
               radius=1e10,
               color=(1, 1, 0),
               mass=1e30)

giant.p = vector(0, 0, -1e4) * giant.mass
dwarf.p = -1*giant.p

# creating the curve which will trace the paths of actors
for a in [giant, dwarf]:
    a.orbit = curve(radius=2e9, color=a.color)

dt = 86400

def anim():
    def __init__(self,random_minerals=True,random_location=True, mineral_location= Location.CENTER,
                 reward = Reward.RELATIVE, grayscale = False, flat = False,
                 mineral_scale = 1.5, start_shift = 0, camera_height = 4,
                 actions = [Action.LEFT,Action.RIGHT,Action.FORWARDS,Action.BACKWARDS,Action.CW,Action.CCW],
                 decorations = False, camera_tilt =  0,start_pos=-23.5,
                 width = 900, height = (500-46),resize_scale=15,
                 x_collision_scale = 1,y_collision_scale = 1,k=5,silver=(.5,.5,.7), random_colors = False,random_lighting=False):
        
        self.random_minerals = random_minerals
        self.random_location = random_location
        self.mineral_location = mineral_location
        self.reward = reward
        self.grayscale = grayscale
        self.flat = flat
        self.actions = actions.copy()
        self.actions_index_dict = self.get_action_index_dictionary()
        self.camera_height = camera_height
        self.decorations = decorations
        self.camera_tilt = camera_tilt
        self.start_pos = start_pos
        self.resize_scale = resize_scale
        mlab.close(all=True)
        self.width = width
        self.height = height + 46
        self.f = mlab.figure(size=(self.width,self.height),bgcolor = (1,1,1))
        
        self.f.scene._lift()
        self.square_width = 23.5
        self.start_shift = start_shift
        self.x_collision_scale = x_collision_scale
        self.y_collision_scale = y_collision_scale
        self.k = k
        self.k_max_iterations = 10
        self.silver = silver
        self.random_colors = random_colors
        self.random_lighting = random_lighting
        visual.set_viewer(self.f)  
        a_side = 34.5
        tape_height = .2
        #distance between minerals
        self.d = 14.5 / np.sqrt(2)
        #color for silver
        #silver = (.8,.8,.8)
        floor_color = (.4,.4,.4)
        #reate field
        self.floor_3_3 = visual.box(x=0,y=0,z=-1, length = 23.5*3,height = 23.5*3,width = 2,color = floor_color)  
        #get mineral location
        locations = self.get_mineral_locations()
        #self.gold_mineral = visual.box(x=locations[0][0],y=locations[0][1],z=1, length=4,height=4,width=4, color = (1,1,0))
        mineral_radius = 2.75 * mineral_scale
        self.gold_mineral = visual.sphere(x=locations[0][0],y=locations[0][1],z=mineral_radius,radius =mineral_radius,color = (1,1,0) )
        self.silver_mineral_1 = visual.sphere(x=locations[1][0],y=locations[1][1],z=mineral_radius,radius =mineral_radius,color = self.silver)
        self.silver_mineral_2 = visual.sphere(x=locations[2][0],y=locations[2][1],z=mineral_radius,radius =mineral_radius,color = self.silver)

        #randomly pick the red or blue side
        r = np.round(np.random.random(1)[0])
        b = 1 - r
        tape_color = (r,0,b)
        #23.5 is the diameter of a square
        #place the crater tape
        
        self.vertical_lander_tape = visual.box(x=-self.square_width*3/2 + 1,y=a_side/2 - self.square_width*3/2,z=tape_height,length = 2, height = a_side, width = tape_height,color=tape_color)
        self.h_lander_tape = visual.box(x=-self.square_width*3/2 + a_side/2,y=-a_side/2,z=tape_height,length = 2, height = a_side * np.sqrt(2), width = tape_height,color=tape_color)
        self.h_lander_tape.rotate(45,axis = [0,0,1],origin = [self.h_lander_tape.x,self.h_lander_tape.y,self.h_lander_tape.z])
        self.marker_left = visual.box(x=self.square_width/2 + 1, y =self.square_width,z=tape_height,length=2,height = self.square_width,width=tape_height,color=tape_color)
        self.marker_right = visual.box(x=3*self.square_width/2 -1, y =self.square_width,z=tape_height,length=2,height = self.square_width,width=tape_height,color=tape_color)
        self.marker_bottom = visual.box(x=self.square_width,y=self.square_width/2 + 1, z = tape_height,length=self.square_width,height=2,width=tape_height,color=tape_color)
        self.marker_top = visual.box(x=self.square_width,y=3*self.square_width/2 - 1, z = tape_height,length=self.square_width,height=2,width=tape_height,color=tape_color)

        #add bars
        if self.decorations:
            bar_width = 1.5
            bar_height = 1
            middle_height = 12 - bar_height*2
            middle_color = floor_color
            bar_length = self.square_width * 3
            bar_color = (0,0,0)
            self.bar1 = visual.box(x=self.square_width*1.5-bar_width/2,y=0,z=tape_height, width= bar_width, height=bar_height,length=bar_length, color = bar_color)
            self.bar1.rotate(90,axis=[0,0,1],origin=self.bar1.pos)
            
            self.bar1m = visual.box(x=self.square_width*1.5-bar_width/2,y=0,z=bar_height+middle_height/2, width= middle_height, height=bar_width,length=bar_length, color = middle_color)
            self.bar1m.rotate(90,axis=[0,0,1],origin=self.bar1m.pos)
            
            self.bar1t = visual.box(x=self.square_width*1.5-bar_width/2,y=0,z=bar_height+middle_height, width= bar_height, height=bar_width,length=bar_length, color = bar_color)
            self.bar1t.rotate(90,axis=[0,0,1],origin=self.bar1t.pos)

            
            self.bar2 = visual.box(x=-self.square_width*1.5+bar_width/2,y=0,z=tape_height, width= bar_width, height=bar_height,length=bar_length, color = bar_color)
            self.bar2.rotate(90,axis=[0,0,1],origin=self.bar2.pos)
            
            self.bar2m = visual.box(x=-self.square_width*1.5+bar_width/2,y=0,z=bar_height+middle_height/2, width= middle_height, height=bar_width,length=bar_length, color = middle_color)
            self.bar2m.rotate(90,axis=[0,0,1],origin=self.bar2m.pos)
            
            self.bar2t = visual.box(x=-self.square_width*1.5+bar_width/2,y=0,z=bar_height+middle_height, width= bar_height, height=bar_width,length=bar_length, color = bar_color)
            self.bar2t.rotate(90,axis=[0,0,1],origin=self.bar2t.pos)
            
            
            
            self.bar3 = visual.box(x=0,y=self.square_width*1.5-bar_width/2,z=tape_height, width= bar_width, height=bar_height,length=bar_length, color = bar_color)
            
            self.bar3m = visual.box(x=0,y=self.square_width*1.5-bar_width/2,z=bar_height+middle_height/2, width= middle_height, height=bar_width,length=bar_length, color = middle_color)

            self.bar3t = visual.box(x=0,y=self.square_width*1.5-bar_width/2,z=bar_height+middle_height, width= bar_height, height=bar_width,length=bar_length, color = bar_color)

            
            self.bar4 = visual.box(x=0,y=-self.square_width*1.5+bar_width/2,z=tape_height, width= bar_width, height=bar_height,length=bar_length, color = bar_color)
            
            self.bar4m = visual.box(x=0,y=-self.square_width*1.5+bar_width/2,z=bar_height+middle_height/2, width= middle_height, height=bar_width,length=bar_length, color = middle_color)

            self.bar4t = visual.box(x=0,y=-self.square_width*1.5+bar_width/2,z=bar_height+middle_height, width= bar_height, height=bar_width,length=bar_length, color = bar_color)
            
            if self.random_colors:
                height_scale = 40
                new_height =  bar_height * height_scale
                self.bar1t.width= new_height
                self.bar1t.rotate(90,axis=[0,0,1],origin=self.bar1t.pos)
                self.bar2t.width= new_height
                self.bar2t.rotate(90,axis=[0,0,1],origin=self.bar2t.pos)
                self.bar3t.width = new_height
                self.bar4t.width = new_height
                
                self.randomize_colors()
                
                
            
        self.x, self.y, self.pos_angle = self.get_start_position()
        self.init_position()
        if self.random_lighting:
            self.randomize_lighting()
        self.move_distance = 2
        self.turn_angle = 5
    def __init__(self):
        mlab.close(all=True)
        self.width = 900
        self.height = 500
        self.f = mlab.figure(size=(self.width, self.height), bgcolor=(1, 1, 1))
        self.f.scene._lift()
        visual.set_viewer(self.f)
        self.square_width = 23.5
        a_side = 34.5
        tape_height = .2
        #distance between minerals
        d = 14.5 / np.sqrt(2)
        #color for silver
        silver = (.8, .8, .8)
        #reate field
        self.floor_3_3 = visual.box(x=0,
                                    y=0,
                                    z=-1,
                                    length=23.5 * 3,
                                    height=23.5 * 3,
                                    width=2,
                                    color=(.4, .4, .4))
        #randomize starting locations
        locations = [[-d, d], [0, 0], [d, -d]]
        #np.random.shuffle(locations)
        #place minerals

        #self.gold_mineral = visual.box(x=locations[0][0],y=locations[0][1],z=1, length=4,height=4,width=4, color = (1,1,0))
        mineral_radius = 2.75 * 2
        self.gold_mineral = visual.sphere(x=locations[0][0],
                                          y=locations[0][1],
                                          z=mineral_radius,
                                          radius=mineral_radius,
                                          color=(1, 1, 0))
        self.silver_mineral_1 = visual.sphere(x=locations[1][0],
                                              y=locations[1][1],
                                              z=mineral_radius,
                                              radius=mineral_radius,
                                              color=silver)
        self.silver_mineral_2 = visual.sphere(x=locations[2][0],
                                              y=locations[2][1],
                                              z=mineral_radius,
                                              radius=mineral_radius,
                                              color=silver)

        #randomly pick the red or blue side
        r = np.round(np.random.random(1)[0])
        b = 1 - r
        tape_color = (r, 0, b)
        #23.5 is the diameter of a square
        #place the crater tape
        self.vertical_lander_tape = visual.box(
            x=-self.square_width * 3 / 2 + 1,
            y=a_side / 2 - self.square_width * 3 / 2,
            z=tape_height,
            length=2,
            height=a_side,
            width=tape_height,
            color=tape_color)
        self.h_lander_tape = visual.box(x=-self.square_width * 3 / 2 +
                                        a_side / 2,
                                        y=-a_side / 2,
                                        z=tape_height,
                                        length=2,
                                        height=a_side * np.sqrt(2),
                                        width=tape_height,
                                        color=tape_color)
        self.h_lander_tape.rotate(45,
                                  axis=[0, 0, 1],
                                  origin=[
                                      self.h_lander_tape.x,
                                      self.h_lander_tape.y,
                                      self.h_lander_tape.z
                                  ])
        self.marker_left = visual.box(x=self.square_width / 2 + 1,
                                      y=self.square_width,
                                      z=tape_height,
                                      length=2,
                                      height=self.square_width,
                                      width=tape_height,
                                      color=tape_color)
        self.marker_right = visual.box(x=3 * self.square_width / 2 - 1,
                                       y=self.square_width,
                                       z=tape_height,
                                       length=2,
                                       height=self.square_width,
                                       width=tape_height,
                                       color=tape_color)
        self.marker_bottom = visual.box(x=self.square_width,
                                        y=self.square_width / 2 + 1,
                                        z=tape_height,
                                        length=self.square_width,
                                        height=2,
                                        width=tape_height,
                                        color=tape_color)
        self.marker_top = visual.box(x=self.square_width,
                                     y=3 * self.square_width / 2 - 1,
                                     z=tape_height,
                                     length=self.square_width,
                                     height=2,
                                     width=tape_height,
                                     color=tape_color)

        #mlab.view(focalpoint=[d,d,0],distance=64, elevation=-80)
        self.x = -(self.square_width - 5) * np.random.random() - 5
        self.y = -(self.square_width - 5) * np.random.random() - 5
        self.update_position()

        self.move_distance = 2.5