Beispiel #1
0
 def __init__(self):
     defaultPlayer.Player.__init__(self)
     self.leftMotion = motion.Motion("./players/perso_2/right",
                                     self,
                                     speed=0.1,
                                     invert=True)
     self.rightMotion = motion.Motion("./players/perso_2/right",
                                      self,
                                      speed=0.1)
     self.upMotion = motion.Motion("./players/perso_2/fly", self, speed=0.4)
     self.downMotion = motion.Motion("./players/perso_2/down", self, yi=5)
     self.SAMotion = motion.Motion("./players/perso_2/attaque",
                                   self,
                                   speed=0.2)
     self.downMotion.setRollEnabled(False)
Beispiel #2
0
def create_motions(parts_cell, mode):
    list_list_motion = []
    bRough = 0
    for part in parts_cell:
        list_motion = []
        for elem in part:
            npoints_traj = elem.npoints_traj
            if mode == "radiation":
                size_motion = npoints_traj * 3 - 1
            else:
                size_motion = npoints_traj

            if elem.type == und_type:  # structure.type == "undulator"
                #size_motion = size_motion*elem.field_file_rep - (elem.field_file_rep - 1)*(2-bRough)
                size_motion = size_motion
                if elem.field_map:
                    size_motion = size_motion * elem.field_map.field_file_rep - (
                        elem.field_map.field_file_rep - 1) * (2 - bRough)
            motion = mtn.Motion(N=size_motion)
            #print "length memory motion:",  len(motion.memory_motion)
            motion.bRough = 0
            motion.mode = mode
            motion.type_element = elem.type
            list_motion.append(motion)
        list_list_motion.append(list_motion)
    return list_list_motion
Beispiel #3
0
 def __init__(self):
     defaultPlayer.Player.__init__(self)
     self.leftMotion = motion.Motion("./players/perso_3/thanos_deplacement",
                                     self,
                                     speed=0.1,
                                     invert=True)
     self.rightMotion = motion.Motion(
         "./players/perso_3/thanos_deplacement", self, speed=0.1)
     self.upMotion = motion.Motion("./players/perso_3/thanos_saut",
                                   self,
                                   speed=0.4)
     self.downMotion = motion.Motion("./players/perso_3/thanos_repos",
                                     self,
                                     yi=5)
     self.SAMotion = motion.Motion("./players/perso_3/thanos_attaque1",
                                   self,
                                   speed=0.2)
     self.downMotion.setRollEnabled(False)
Beispiel #4
0
 def __init__(self):
     self.evt = event.Event()
     self.motion = motion.Motion()  #actuator class
     self.sonic = sonic_sensor.SonicSensor()
     self.camera = camera.Camera()  #sencer class
     self.uploader = uploader.Uploader()  #sencer class
     self.motion.evt += self.camera.execute
     self.motion.evt += self.uploader.execute
     self.sonic.evt += self.camera.execute
     self.sonic.evt += self.uploader.execute
Beispiel #5
0
 def write_floor(self, cursor, zone_label, zone_attr):
     if zone_label not in zone_attr.floors:
         return
     floor_motion = motion.Motion(True)
     floor_motion.pos = list(cursor)
     block_offset = [0, 0, 0]
     draw_obj = DrawObject(floor_motion, zone_attr.floors[zone_label],
                           DrawObject.FLOOR)
     floor_bounds = [Bounds(0, 1), Bounds(0, 1), Bounds(-0.05, 0.05)]
     map_obj = map_object.MapObject(floor_motion, floor_bounds,
                                    block_offset, draw_obj)
     block = self.blocks[tuple(cursor)]
     block.coords = tuple(cursor)
     block.objects.append(map_obj)
Beispiel #6
0
    def _setup_camera(self):
        import picamera
        import motion

        self._camera = picamera.PiCamera(framerate=_FRAMERATE,
                                         resolution=_RESOLUTION)
        self._camera.led = False
        self._camera.rotation = _ROTATE

        self._motion_recording = None
        self._motion_channel = 1
        self._motion_recording_flag = False
        self._motion_detector = motion.Motion(self._camera)
        self._motion_recording = picamera.PiCameraCircularIO(
            self._camera,
            splitter_port=self._motion_channel,
            seconds=_MOTION_RECORDING_TIME)
Beispiel #7
0
    def __init__(self):
        # indication led
        config = configparser.ConfigParser()
        config.read("../carty.ini")
        self.indication_led = int(config["MAIN"]["INDICATION_LED"])
        gpio.setmode(gpio.BCM)
        gpio.setup(self.indication_led, gpio.OUT)
        gpio.output(self.indication_led, gpio.LOW)

        # hardware modules
        self.motion = motion.Motion()
        self.lights = lights.Lights()

        # mode
        self.mode = Mode.realtime
        self.cached_commands = []
        self.command_time = 0
        self.prev_command = ""
    def __init__(self, ip="127.0.0.1", port=9559):
        connection_url = "tcp://" + ip + ":" + str(port)
        print("Connecting to nao-qi at {0} ...".format(connection_url))
        self.app = qi.Application(["--qi-url=" + connection_url])
        self.app.start()
        self.session = self.app.session

        self.audio = audio.Audio(self.session)
        self.vision = vision.Vision(self.session)
        self.touch = touch.Touch(self.session)
        self.motion = motion.Motion(self.session)
        self.behavior = behavior.Behavior(self.session)
        self.tablet = tablet.Tablet(self.session)

        self.audio.set_callback(self.send)  # Set send fallback
        self.vision.set_callback(self.send)  # Set send fallback
        self.touch.set_callback(self.send)  # Set send fallback
        self.motion.set_callback(self.send)  # Set send fallback
        self.behavior.set_callback(self.send)  # Set send fallback
Beispiel #9
0
    def write_wall(self, cursor, zone_label, zone_attr, wall_type):
        if zone_label not in zone_attr.outer:
            return
        offset_map = {
            'u': [0, 0, 0],
            'l': [0, 0, 0],
            'd': [0, 1, 0],
            'r': [1, 0, 0],
        }

        bounds_map = {
            'u': [Bounds(0, 1), Bounds(0, 0),
                  Bounds(0, 1)],
            'l': [Bounds(0, 0), Bounds(0, 1),
                  Bounds(0, 1)],
            'd': [Bounds(0, 1), Bounds(0, 0),
                  Bounds(0, 1)],
            'r': [Bounds(0, 0), Bounds(0, 1),
                  Bounds(0, 1)],
        }

        wall_motion = motion.Motion(True)
        block_offset = offset_map[wall_type]
        wall_motion.pos = [a + b for a, b in zip(block_offset, list(cursor))]
        draw_obj = None
        if wall_type is 'u' or wall_type is 'd':
            draw_obj = DrawObject(wall_motion, zone_attr.outer[zone_label],
                                  DrawObject.X)
        if wall_type is 'l' or wall_type is 'r':
            draw_obj = DrawObject(wall_motion, zone_attr.outer[zone_label],
                                  DrawObject.Y)
        map_obj = map_object.MapObject(wall_motion, bounds_map[wall_type],
                                       block_offset, draw_obj)
        block = self.blocks[tuple(cursor)]
        block.coords = tuple(cursor)
        block.objects.append(map_obj)
Beispiel #10
0
import time
from flask import Flask, render_template
import motion
from ultrasonic import Ultrasonic

app = Flask(__name__)
ctrl = motion.Motion()
sensor = Ultrasonic(trig_pin=29, echo_pin=31)

def index():
    return render_template("index.html")

def forward():
    print "Onward!"
    ctrl.forward(100)
    time.sleep(1)
    ctrl.stop()
    return "Onward!"

def backward():
    print "Backwards!"
    ctrl.backward(100)
    time.sleep(1)
    ctrl.stop()
    return "Backwards!"

def left():
    print "Left"
    ctrl.left(75)
    time.sleep(1)
    ctrl.stop()
 def provide_sensor_motion(self):
     _motion = motion.Motion(self.provide_driver_default())
     _motion.add_pipeline("movement",
                          self.provide_pipeline_motion_movement_1())
     return _motion
Beispiel #12
0
 def __init__(self):
     self.motion = motion.Motion()
Beispiel #13
0
def _lightBlink(colour):
    hub.light.blink(colour, [200, 200])


print(pybricks.version)

hub = TechnicHub()
sensor = ColorDistanceSensor(Port.A)
colour.initColoursForSensor(sensor)
controller = ColorDistanceSensor(Port.B)
leftMotor = Motor(Port.C, Direction.COUNTERCLOCKWISE, gears=[12, 20])
rightMotor = Motor(Port.D, gears=[12, 20])
driveBase = DriveBase(leftMotor, rightMotor, 49.7, 98.1)

motion = motion.Motion(sensor, driveBase)
terrain = navigation.Terrain()

try:
    print("Battery is %smV" % hub.battery.voltage())
    _lightBlink(PBColor.WHITE)
    _waitForController()
    _lightOff()
    home = motion.position.copy()
    while True:
        try:
            motion.seek()
            print("Found!")
            found = motion.identify()
            print("Identified: " + str(found))
            _lightBlink(found)
Beispiel #14
0
 def __init__(self):
     self.evt = event.Event()
     self.motion = motion.Motion()  #sencor class
     self.shoot = shoot.Shoot()  #actuator class
     self.upload = upload.Upload()  #actuator class
     self.led = led.led()