示例#1
0
    def setup_docking_station(cls, size, height, goal_object):

        if goal_object == 'coloured_station':
            face_colours = [
                pyenki.Color(0.839, 0.153, 0.157),
                pyenki.Color(1.000, 0.895, 0.201),
                pyenki.Color(0.173, 0.627, 0.173)
            ]
        elif goal_object == 'station':
            face_colours = [
                pyenki.Color(0, 0.5, 0.5),
                pyenki.Color(0, 0.5, 0.5),
                pyenki.Color(0, 0.5, 0.5)
            ]
        else:
            raise ValueError("Invalid value for goal_object")

        d_object = pyenki.CompositeObject(
            [([(0, 1 * size), (0, 0.5 * size), (2 * size, 0.5 * size),
               (2 * size, 1 * size)], height, [face_colours[0]] * 4),
             ([(0, -0.5 * size), (0, -1 * size), (2 * size, -1 * size),
               (2 * size, -0.5 * size)], height, [face_colours[2]] * 4),
             ([(0, 0.5 * size), (0, -0.5 * size), (0.5 * size, -0.5 * size),
               (0.5 * size, 0.5 * size)], height, [face_colours[1]] * 4)], -1,
            pyenki.Color(0, 0.5, 0.5))

        return d_object
示例#2
0
 def __init__(self, pos, size=3, col=(0.9, 0.9, 0)):
     (r, g, b) = col
     super(MyBall, self).__init__(size, pyenki.Color(r, g, b))
     #self.dir = 1
     #starting pos and angle
     self.id = self.setId("Bola")
     self.pos = pos
     self.angDir = 130
     self.Speed = 0.114 * conf.objectiveSpeed  #holds real speed (u/s)
     self.angle = Math.radians(self.angDir)
     self.dir = 1
     self.neutralSpeed = conf.objectiveSpeed  # holds physics speed
     print("New Ball At", self.pos)
     self.mills = int(round(time.time() * 1000))
     print(self.pos)
示例#3
0
		self.angle += Math.radians(incrementRot)
		#incrementRot =  delta
		'''
        if (debugRbobo):
            print("ID:", self.id, "speed", self.pos[0], self.speed[1], "rot",
                  incrementRot, "speeds", self.leftSpeed, self.rightSpeed)


#w.steps = 100
# task = ()

if conf.roundMap:
    w = pyenki.WorldWithTexturedGround(
        wR, "GroundTextures/tiles.png",
        pyenki.Color(135 / 250., 206 / 250., 235 / 250.))
else:
    w = pyenki.WorldWithTexturedGround(
        wW, wH, "GroundTextures/tiles.png",
        pyenki.Color(135 / 250., 206 / 250., 235 / 250.))

anl = Analise(conf.maxIterations, TarefaZones)
# anl = Analise(conf.maxIterations, TarefaChasing)
# anl = Analise(conf.maxIterations, Testing)
objective = anl.getObjective()
if objective:
    w.addObject(objective)

anl.task.initObjects(w)

for i in range(conf.populationSize):
world = pyenki.World(200)

marxbot = pyenki.Marxbot()
marxbot.position = (0, 0)
# marxbot.left_wheel_target_speed = -10
# marxbot.right_wheel_target_speed = 10
world.add_object(marxbot)

marxbot2 = pyenki.Marxbot()
marxbot2.position = (20, -5)
marxbot2.left_wheel_target_speed = 4
marxbot2.right_wheel_target_speed = 4
world.add_object(marxbot2)

cube = pyenki.RectangularObject(10, 10, 15, -1, pyenki.Color(1.0))
cube.position = (-20, 10)
world.add_object(cube)

cylinder = pyenki.CircularObject(10, 15, -1, pyenki.Color(0.0, 1.0, 0.0))
cylinder.position = (20, 20)
world.add_object(cylinder)


app = QApplication.instance()

if not app:
    app = QApplication(sys.argv)
else:
    print("Running within an existing QApplication")
示例#5
0
import pyenki
import random
import math as Math
from Configuration import Config as conf
import NeuralNetwork as nn

#Global world properties

wL = 200
wH = 100

w = pyenki.World(wL, wH, pyenki.Color(0.5, 0.5, 0.5))
w.steps = 100

#//runInviewer(Enki::World self, camPos, camAltitude, camYaw, camPitch, wallsHeight)
w.runInViewer((wL / 2, wH / 2), wH * 1.05, 0, Math.radians(-89.9), 10)
示例#6
0
marxbot2.goal_angle = -np.pi / 2
world.add_object(marxbot2)

size = 20.0
height = 40.0

d_object = pyenki.CompositeObject([([(0, 1 * size), (0, 0.5 * size),
                                     (2 * size, 0.5 * size),
                                     (2 * size, 1 * size)], height),
                                   ([(0, -0.5 * size), (0, -1 * size),
                                     (2 * size, -1 * size),
                                     (2 * size, -0.5 * size)], height),
                                   ([(0, 0.5 * size), (0, -0.5 * size),
                                     (0.5 * size, -0.5 * size),
                                     (0.5 * size, 0.5 * size)], height)], -1,
                                  pyenki.Color(0, 0.5, 0.5))
world.add_object(d_object)

# Decide the pose of the docking_station
d_object.position = (0, 0)
d_object.angle = 0

## Start the application
app = QApplication.instance()

if not app:
    pyenki.createApp()
else:
    print("Running within an existing QApplication")

# Configure Matplotlib to coexist with the PyEnki Viewer: switch to the Qt5