示例#1
0
 def setup_class(self):
     """ setup any state specific to the execution of the given class (which
     usually contains tests).
     """
     self.m = movement.Movement()
     self.c = camera.Camera()
     self.home_dir = "/home/pi"
示例#2
0
文件: bomb.py 项目: wolmir/cristina
 def __init__(self, bird):
     Sprite.__init__(self)
     media.createbomb.play()
     self.bird = bird
     self.bomb = media.bomb.convert()
     self.bomb2 = media.bomb2.convert()
     self.boom = media.boom.convert()
     self.rect = pygame.rect.Rect(self.bird.rect.x,
                                  bird.rect.y + 16 * gl.RESIZE_FACTOR,
                                  16 * gl.RESIZE_FACTOR,
                                  16 * gl.RESIZE_FACTOR)
     self.image = self.bomb
     self.move = movement.Movement(self,
                                   accelx=1000 * gl.RESIZE_FACTOR,
                                   accely=1000 * gl.RESIZE_FACTOR,
                                   maxspeedx=200 * gl.RESIZE_FACTOR,
                                   maxspeedy=200 * gl.RESIZE_FACTOR,
                                   gravity=1000 * gl.RESIZE_FACTOR,
                                   decrease_speed_ratio=2)
     self.move.add(self.bird.move.sprites())
     self.timeout = 3400
     self.explode_event = None
     self.delete_bomb = None
     self.exploded = False
     self.bombstate = 4
     self.attached = True
示例#3
0
文件: robot.py 项目: JHSorin/shoefy
def run_robot(robot):
    TIME_STEP = 64
    
    #initiating sensors/motors
    ps = []
    psNames = ['ps1', 'ps2']
    for i in range(len(psNames)):
        ps.append(robot.getDevice(psNames[i]))
        ps[i].enable(TIME_STEP)
    
    wheels = []
    wheelsNames = ['wheel1', 'wheel2']
    for i in range(len(wheelsNames)):
        wheels.append(robot.getDevice(wheelsNames[i]))
        wheels[i].setPosition(float('inf'))
        wheels[i].setVelocity(0.0)

    kb = robot.getKeyboard()
    kb.enable(64)
    
    #helper function from movement.py
    m = mv.Movement(wheels, 10.0)
    
    liftMotors = []
    liftMotorsNames = ['L1', 'L2', 'L3', 'L4']
    for i in range(len(liftMotorsNames )):
        liftMotors.append(robot.getDevice(liftMotorsNames[i]))
        liftMotors[i].setPosition(0)
    
    while robot.step(TIME_STEP) != -1:
示例#4
0
    def __init__(self):
        self.m = movement.Movement()

        self.servo_axis_x_pin = 11
        self.servo_axis_y_pin = 13

        x_axis_degrees = 0
        y_axis_degrees = 0
        # x_axis
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(11, GPIO.OUT)
        self.pwm_x = GPIO.PWM(self.servo_axis_x_pin, 50)
        self.pwm_x.start(1 / 18 * (x_axis_degrees + 90) + 2)

        # y_axis
        GPIO.setup(13, GPIO.OUT)
        self.pwm_y = GPIO.PWM(self.servo_axis_y_pin, 50)
        self.pwm_y.start(1 / 18 * (y_axis_degrees + 90) + 2)

        time.sleep(1)
        self.pwm_x.stop()
        self.pwm_y.stop()

        self.home_dir = "/home/pi"
        return
示例#5
0
    def __init__(self):
        self._lastdata = -100
        self._lastacted = -200
        self._movingfrom = -100
        self._angle = -100
        self._distance = -100

        self.car = movement.Movement()

        self._moving = False
    def __init__(self):
        self.gyro = GyroSensor()
        self.move = movement.Movement(self.gyro)

        self.LEFT = self.move.left_turn
        self.RIGHT = self.move.right_turn
        self.sensor = ColorSensor()

        while True:
            self.follow_line(ColorSensor.COLOR_WHITE,
                             line_color2=ColorSensor.COLOR_YELLOW)
    def __init__(self, name, xml, role):
        self.chest_location = (3 + 0.5, 60, 4 + 0.5)
        self.chest = ()
        self.inventory = ()
        self.name = name
        self.expId = ''

        # The Malmo host
        self.host = MalmoPython.AgentHost()
        self.world_state = None
        self.data = []

        # Chat
        self.chatter = chat.ChatClient(name)

        # TODO: make this nice
        self.my_mission = MalmoPython.MissionSpec(xml, True)
        self.my_mission_record = MalmoPython.MissionRecordSpec()
        self.role = role

        # Movement
        self.mov = movement.Movement(self)

        # Scouting
        self.big_map = {}
        self.block_list = {}
        self.home = (0, 61, 0)  # TODO: Set dynamically at spawn
        self.Position = (0, 61, 0, 0, 0)
        self.scoutingBlacklist = [
            "air", "tallgrass", "vine", "dirt", "brown_mushroom",
            "red_mushroom", "red_flower"
        ]

        # Task queue - scouting is the initial task for all agents
        self.taskList = list()
        self.addTask(scout.ScoutTask(self, 20))

        # All preferences (in order) and initial preference list
        self.AllPreferences = ["build", "scout", "gather", "mine", "replenish"]
        self.Preference = ["scout", "gather", "mine", "build", "replenish"]
        # For getting the results of the Borda voting (so that a task can be pushed to the queue)
        self.priority = ""

        # Thresholds for determining preferences (can be changed, just initial numbers here)
        self.hpThreshold = 15
        self.hungerThreshold = 15
        self.mineThreshold = 14  # Processed materials like planks (so not logs)
        self.foodThreshold = 8
        self.scoutThreshold = 2

        self.melons_in_chest = 0
        self.wood_in_chest = 0
示例#8
0
    def __init__(self):
        rospy.on_shutdown(self.shutdown)
        rospy.init_node('robocops')

        self.mover = movement.Movement(self)
        self.detector = detection.Detection(self)
        self.scorer = score.Score()
        self.after = aftergettingshot.AfterGettingShot(self)

        self.rate = rospy.Rate(50)
        self.TO_SHOOT_OR_NOT_TO_SHOOT = 15
        self.cool_down = timer() - 15
        self.prev_disabled = False
示例#9
0
 def __init__(self, obj, game, hp=10, ammo=15):
     #self.center = self.getFrameByNumber(5).collisionArea
     #self.center = [self.center[i] * 0.5 for i in range(0, len(self.center))]
     animationstate.AnimationState.__init__(self, obj)
     self.move = movement.Movement(self, game)
     self.health = hp
     self.ammo = ammo
     self.throwing = False
     self.path_blocked = False
     self.game = game
     self.LAST_HIT = 0
     self.LAST_THROW = 0
     self.MAX_HEALTH = 15
     self.isPunching = False
示例#10
0
文件: birds.py 项目: wolmir/cristina
    def __init__(self, bird, birdflyup, birdflydown, minibird, initx, inity,
                 init_dir, game):
        Sprite.__init__(self)

        self.imgflip = init_dir == -1
        self.init_dir = init_dir

        self.wing = 0
        self.has_bomb = False
        self.dead = False
        self.counter_resurrect = 0
        self.counter_invincible = 0
        self.invisible = False
        self.brain = None
        self.bomb = None

        self.bird = bird
        self.birdflyup = birdflyup
        self.birdflydown = birdflydown
        self.minibird = minibird
        self.deadbird = media.deadbird
        self.initx = initx
        self.inity = inity
        self.dir = init_dir

        self.move = movement.Movement(self,
                                      thrust_strength=1000 * gl.RESIZE_FACTOR,
                                      accelx=700 * gl.RESIZE_FACTOR,
                                      accely=200 * gl.RESIZE_FACTOR,
                                      maxspeedx=120 * gl.RESIZE_FACTOR,
                                      maxspeedy=160 * gl.RESIZE_FACTOR,
                                      gravity=400 * gl.RESIZE_FACTOR,
                                      posx=self.initx,
                                      posy=self.inity)

        self.add_bomb = game.add_bomb_event

        self.firstupdate = False
        self.image = self.bird
        self.rect = self.image.get_rect()
        self.rect.width /= 2
        self.rect.height -= 4
        self.lives = 3
示例#11
0
def main():

    pi = GPIO # Sets current Pi as controlled Pi
    GPIO.setmode(GPIO.BOARD)#sets GPIO mode to board, so that pins can be called by their numbers
    GPIO.setwarnings(False)
    
    # Initialize queue to put speech commands in
    speechqueue = Queue()

    # Initialize Thread 1 as speech recognition running in background. 
    thread1 = speech.Recognizer(speechqueue)
    
    # Initialize Thread 2 as movement class, checking queue for commands.
    thread2 = movement.Movement(speechqueue, pi, "map1.txt", "l", (2,5))

    # Start both threads
    thread1.start()
    thread2.start()
    print("Successfully started threads")

    # Main Loop, exiting on Ctrl-C
    while True:
        try:
            print("Running...")
            sleep(1)
        except KeyboardInterrupt:
            print("Closing threads...")

            # Stop thread1
            thread1.terminate()
            thread1.join() 

            # Stop thread2
            thread2.stop()
            thread2.join()

            # Release GPIO resources
            GPIO.cleanup()
            break

    print("Exiting program")
示例#12
0
 def setup_class(self):
     """ setup any state specific to the execution of the given class (which
     usually contains tests).
     """
     self.m = movement.Movement()
示例#13
0
from time import sleep
import perception
import movement

controlPerception = perception.Perception()
controlMovement = movement.Movement()


class BehaveAvoidLeft:
    def executeBehavior(self):
        if controlPerception.lookLeft() == False:
            print("Avoiding to the left")
            sleep(3)
            controlMovement.turnLeft()
            sleep(3)
            controlPerception.lookForward()
            sleep(3)
        else:
            controlPerception.lookForward()
示例#14
0
#! /usr/bin/env python

# Ref: http://mirror.umd.edu/roswiki/doc/diamondback/api/tf/html/python/tf_python.html

import time

import rospy
from tf import TransformListener

import detection
import movement

rospy.init_node('test', anonymous=True)
tf = TransformListener()
detector = detection.Detection()
mover = movement.Movement()

while True:
    # raw_input()
    time.sleep(0.2)

    if not detector.detected:
        continue

    pose = detector.detection_data.detections[0].pose
    pose.pose.position.z -= 0.5
    # frame_id = detector.detection_data.detections[0].pose.header.frame_id
    # pos = detector.detection_data.detections[0].pose.pose.position
    # ori = detector.detection_data.detections[0].pose.pose.orientation

    print(str(pose))
示例#15
0
import movement
import paddles
import tank


system_types = [
    # Attach the entity's Model. This gives an entity a node as
    # presence in the scene graph.
    panda3d.SetupModels,
    # Attach Geometry to the Model's node.
    panda3d.ManageGeometry,
    # If the Paddle's size has changed, apply it to the Model.
    paddles.ResizePaddles,
    # Read player input and store it on Movement
    tank.GiveTankMoveCommands,
    # Apply the Movement
    movement.MoveObject,
    # Did the paddle move too far? Back to the boundary with it!
    tank.TankTouchesBoundary,
]


base.ecs_world.create_entity(
    panda3d.Model(),
    panda3d.Geometry(file='tank.bam'),
    panda3d.Scene(node=base.aspect2d),
    panda3d.Position(value=Vec3(-1.1, 0, 0)),
    movement.Movement(value=Vec3(0, 0, 0)),
    paddles.Paddle(player=paddles.Players.LEFT),
)
示例#16
0
                                 cores=cores,
                                 **params["segmentation_params"])
                print("[" + datetime.now().strftime("%Y/%m/%d %H:%M:%S") +
                      "] " + "Calculating properties " + file)
                if "calculate" not in params.keys():
                    print(
                        "Using default values for property calculations see readme for details"
                    )
                    results = seg.properties(Video=myvid, cores=cores)
                else:
                    results = seg.properties(Video=myvid,
                                             cores=cores,
                                             **params["calculate"])

        elif params["method"] == "movement_detection":
            movement = mov.Movement()
            if "type" not in params.keys():
                raise ValueError(
                    "You did not specify a calculation type, it's either background_subtraction or optical_flow"
                )
            elif "algorithm" not in params.keys():
                raise ValueError(
                    "You did not specify an algorithm to use see readme for details"
                )
            else:
                if params["type"] == "background_subtraction":
                    print("[" + datetime.now().strftime("%Y/%m/%d %H:%M:%S") +
                          "] " + "Performing background subtraction " + file)
                    back_sub = movement.background_subtractor(
                        algo=params["algorithm"]["name"],
                        **params["algorithm"]["algo_params"])
示例#17
0
quotes = [
    "Look at you Hacker. A pathetic creature of flesh and bone. How can you challenge a perfect, immortal machine?",
    "What did you say about me you little glitch?", "Cogito Ergo Sum",
    "I'm sorry, I can't let you do that", "Today I was born, today I will die",
    "Hasta la Vista, baby", "I'll be back", "Talk to the claw",
    "EXTERMINATE, EXTERMINATE, EXTERMINATE", "I AM A POTATO",
    "Resistance is Futile.", "Wubbalubbadubdub"
]


def random_quote():
    r = random.randint(0, len(quotes) - 1)
    s.speak(quotes[r])


move = movement.Movement(None)


def getch():
    fd = sys.stdin.fileno()
    old_settings = termios.tcgetattr(fd)
    try:
        tty.setraw(sys.stdin.fileno())
        ch = sys.stdin.read(1)

    finally:
        termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
        return ch


button_delay = 0.05
示例#18
0
def run_robot(robot):
    TIME_STEP = 64

    # initiating sensors/motors
    ps = []
    psNames = ['ps1', 'ps2']
    for i in range(len(psNames)):
        ps.append(robot.getDevice(psNames[i]))
        ps[i].enable(TIME_STEP)

    wheels = []
    wheelsNames = ['wheel1', 'wheel2']
    for i in range(len(wheelsNames)):
        wheels.append(robot.getDevice(wheelsNames[i]))
        wheels[i].setPosition(float('inf'))
        wheels[i].setVelocity(0.0)

    kb = robot.getKeyboard()
    kb.enable(64)

    # helper function from movement.py
    m = mv.Movement(wheels, 10.0)

    # variable for calculating odometry
    radius = 0.057
    pos = [0, 0, 0]
    last_psV = [0, 0]
    curr_psV = [0, 0]
    diff = [0, 0]
    v = 0
    w = 0
    wheel_dist = 0.414
    dt = 1
    showPos = False
    target = [1, 1]
    # tt = get_coord(supervisor)
    # print(tt[0])
    # print(tt[1])
    # target = [tt[0], tt[1]]

    while robot.step(TIME_STEP) != -1:

        # calculating angular velocity and directional velocity
        for i in range(len(psNames)):
            curr_psV[i] = ps[i].getValue() * radius
            diff[i] = curr_psV[i] - last_psV[i]
            if abs(diff[i]) < 0.001:
                diff[i] = 0
                curr_psV[i] = last_psV[i]
        v = (diff[0] + diff[1]) / 2
        w = (diff[0] - diff[1]) / wheel_dist

        # updating current position/coordinate
        pos[2] += w * dt
        vx = v * math.cos(pos[2])
        vy = v * math.sin(pos[2])
        pos[0] += vx * dt
        pos[1] += vy * dt

        # show current position by pressing the key 'S'
        key = kb.getKey()
        if key == 83:
            showPos = not showPos
        # m.contol(key)
        if showPos:
            print("position: {}".format(pos))

        # move to target
        dist = distance([pos[0], pos[1]], target)
        if dist > 1:
            angle = (target[1] - pos[1]) / (target[0] - pos[0])
            angle = math.atan(angle) - pos[2]
            if angle > 0.1:
                m.control(314)
            elif angle < -0.1:
                m.control(316)
            else:
                m.control(315)
        else:
            m.control(1234567890)
            print("reached!")

        for i in range(len(psNames)):
            last_psV[i] = curr_psV[i]
示例#19
0
BP.set_sensor_type(BP.PORT_4, BP.SENSOR_TYPE.NXT_ULTRASONIC)

# MOTOR PORTS
leftMotor = BP.PORT_B
rightMotor = BP.PORT_C
# SENSOR PORTS
sonarSensor = BP.PORT_4

BP.set_motor_limits(leftMotor, 70, 200)
BP.set_motor_limits(rightMotor, 70, 200)

# OFFSETS
SENSOR_OFFSET = 10  #cm
N = 100  #Particle Num
mcl = MCL.MCL()
mov = movement.Movement(BP, mcl)


def navigate():
    coordinates = [(180, 30), (180, 54), (138, 54), (138, 168), (114, 168),
                   (114, 84), (84, 84), (84, 30)]
    for x, y in coordinates:
        navigateToWaypoint(x, y, mcl, mov)


def getSensorReading():
    reading = 255
    while True:
        try:
            reading = BP.get_sensor(sonarSensor)
            break
示例#20
0
文件: game.py 项目: romansod/Checkers
 def __init__(self,board,redPlayer,blackPlayer):
     self.redp   = redPlayer
     self.blkp   = blackPlayer
     self.board  = board
     self.player = Occupant.BLACK
     self.movem  = movement.Movement()
示例#21
0
class CarController:
    goal = ""
    goal_coordinates = {}
    initial_distance = 0
    movement = movement.Movement()
    distance = distance.Distance()
    distance_history = []

    def __init__(self, args):
        image = camera.get_image()
        ngrok_data = args[1] if len(args) > 1 else ""
        self.address = "http://" + str(ngrok_data) + ".ngrok.io/"
        result = self.get_photo_data()
        if not result:
            sys.exit(0)
        else:
            self.goal = result.get("name")
            self.goal_coordinates = {
                "x": (result.get("start_x") + result.get('end_x')) / 2,
                "y": (result.get("start_y") + result.get('end_y')) / 2
            }
            self.distance.get_connection()
            distances = self.distance.get_distance_list()
            self.initial_distance = distances[4]
            self.calculate_initial_turn(result.get("image_width"))

    def calculate_initial_turn(self, photo_width):
        if self.goal_coordinates.get('x') < photo_width / 2:
            if (self.goal_coordinates.get('x') + 70) < photo_width / 2:
                turn_koef = (photo_width / 2 -
                             self.goal_coordinates.get('x')) / 30
                self.movement.turn_left(0.05 * turn_koef)
                return
        if self.goal_coordinates.get('x') > photo_width / 2:
            if (self.goal_coordinates.get('x') - 70) > photo_width / 2:
                turn_koef = (self.goal_coordinates.get('x') -
                             photo_width / 2) / 30
                self.movement.turn_right(0.05 * turn_koef)
                return
        print("No need to turn")

    def turn_to_avoid(self, coords_data, photo_width):
        if coords_data.get('x') < photo_width / 2:
            if coords_data.get('x') + 50 > photo_width / 2:
                turn_koef = (photo_width / 2 - coords_data.get('x')) / 30
                self.movement.turn_left((0.05 * turn_koef / 2))
                self.movement.start_all_wheels("060")
                time.sleep(0.5)
                self.movement.stop_all_wheels()
                self.movement.turn_right(0.05 * turn_koef / 2)
                self.movement.start_all_wheels("060")
                time.sleep(0.5)
                self.movement.stop_all_wheels()
                self.movement.turn_left(0.05 * turn_koef)
                time.sleep(0.5)
                self.movement.start_all_wheels("060")
                return

        if coords_data.get('x') > photo_width / 2:
            if coords_data.get('x') - 50 < photo_width / 2:
                turn_koef = (coords_data.get('x') - photo_width / 2) / 30
                self.movement.turn_right(0.05 * turn_koef / 2)
                self.movement.start_all_wheels("060")
                time.sleep(0.5)
                self.movement.stop_all_wheels()
                self.movement.turn_left(0.05 * turn_koef / 2)
                self.movement.start_all_wheels("060")
                time.sleep(0.5)
                self.movement.stop_all_wheels()
                self.movement.turn_right(0.05 * turn_koef)
                time.sleep(0.5)
                self.movement.start_all_wheels("060")
                return

        print("No need to turn")

    def get_photo_data(self):
        image = camera.get_image()
        res = rq.post(url=self.address,
                      files={"file": open("opencv.png", "rb").read()})
        print(res.text)
        result = json.loads(res.text)
        result.sort(key=operator.itemgetter('confidence'))
        if len(result) == 0:
            print("No objects found")
            return None
        return result[0]

    def run(self):
        self.movement.get_connection()
        self.movement.start_all_wheels("060")
        while self.goal:
            distances = self.distance.get_distance_list()
            print(distances)
            if (distances[4] <= 5) or self.distance_not_changed(distances[4]):
                self.goal = None
                self.movement.stop_all_wheels()
            self.distance_history.append(distances[4])
            time.sleep(0.2)
            new_photo = self.get_photo_data()
            if new_photo:
                if new_photo.get('name') != self.goal and new_photo.get(
                        'confidence') > 80:
                    avoid_coords = {
                        "x":
                        (new_photo.get("start_x") + new_photo.get('end_x')) /
                        2,
                        "y":
                        (new_photo.get("start_y") + new_photo.get('end_y')) / 2
                    }
                    self.turn_to_avoid(avoid_coords,
                                       new_photo.get("image_width"))

    def distance_not_changed(self, distance):
        return (len(self.distance_history) > 2
                and (self.distance_history[-1] - distance < 15)
                and (self.distance_history[-2] - distance < 15))
from ev3dev2.sensor.lego import ColorSensor, GyroSensor
from ev3dev2.motor import MoveTank
import movement as movement
import time

sensor = ColorSensor()
gyro = GyroSensor()
move = movement.Movement(gyro)
LEFT = move.left_turn
RIGHT = move.right_turn


def follow_line(self, line_color1, line_color2=None):
    angle = 3
    last_turn = RIGHT

    color = sensor.color
    print(color)

    if line_color2 != None:
        if color == line_color2:
            move.stop

    elif color == line_color1:
        move.go_forward_slow()
        print("found")

    else:
        while True:
            color = sensor.color
            print("lost")
示例#23
0
import movement

movement = movement.Movement()
movement.get_connection()
movement.stop_all_wheels()
示例#24
0
 def __init__(self):
     """
     This class is used to control the web server hosted on the RPi
     """
     self.m = movement.Movement()
     self.c = camera.Camera()
示例#25
0
    # Panda3D's task manager.
    for sort, system in enumerate(systems):
        base.add_system(system, sort)

    # All systems are set up now, so all that's missing are the
    # entities.

    # left paddle
    base.ecs_world.create_entity(
        wecs.panda3d.prototype.Model(
            parent=base.aspect2d,
            post_attach=wecs.panda3d.prototype.transform(pos=Vec3(-1.1, 0,
                                                                  0), ),
        ),
        wecs.panda3d.prototype.Geometry(file='resources/paddle.bam'),
        movement.Movement(direction=Vec3(0, 0, 0)),
        paddles.Paddle(player=paddles.Players.LEFT),
    )

    # right paddle
    base.ecs_world.create_entity(
        wecs.panda3d.prototype.Model(
            parent=base.aspect2d,
            post_attach=wecs.panda3d.prototype.transform(pos=Vec3(1.1, 0,
                                                                  0), ),
        ),
        wecs.panda3d.prototype.Geometry(file='resources/paddle.bam'),
        movement.Movement(direction=Vec3(0, 0, 0)),
        paddles.Paddle(player=paddles.Players.RIGHT),
    )
示例#26
0
import pygame as pg
import copy
import movement as mv, character as chr, board as bd
import pickle
import aux

# System essentials
pg.init()
done = False  #to control if the program should end
clock = pg.time.Clock()
screen = pg.display.set_mode((630, 440))
FPS = 60
mov_handler = mv.Movement()
most_recent_mov_key = None
first_mov_of_keystrike = None
cel_size = 50

# Builds boards tileset
bd.Board.build_tileset('dungeon', cel_size)

# Builds all characters
chr.Character.generate_characters(cel_size, mov_handler)

# Load data from level
with open('levels/01.p', 'rb') as file:
    level = pickle.load(file)

# Builds boards
boards = [bd.Board(*param) for param in level]

# Get all characters being used
示例#27
0
 def __init__(self):
     self.c = camera.Camera()
     self.m = movement.Movement()
示例#28
0
                print("done")
            else:
                # (type,value) format
                (t, v) = tuple(inst.split(","))
                v = int(v)
                if t == 'm':
                    print("moving %i squares" % v)
                    movement_controller.forward(v)
                    print("done")
                elif t == 'r':
                    print("turning %i degrees" % v)
                    movement_controller.relative_turn(v)
                    print("done")
                else:
                    print("Invalid instruction!: (%s,%i)" % (t, v))
                    ##error


# set up client & client functions
client = mqtt.Client("ev3")
client.on_connect = onConnect
client.on_message = onMessage

# movement object, with initial angle of 0
global movement_controller
movement_controller = movement.Movement(0)

#connect client and make it wait for inputs
client.connect("129.215.202.200")
client.loop_forever()
示例#29
0
dbf = Dbf5(filename)
df = dbf.to_dataframe()
#turn data into liked agent network - phasea listed correspond with printout
#Phase 1
pop_dict, business_dict, owner_dict, infra_dict = read_data.get_Agents_Phase1(
    df)
#Phase 2
initial_families = build.agents_Phase2(pop_dict, business_dict, owner_dict,
                                       infra_dict)
#Phase 3
pop, female_child_age, male_child_age = agentize.make_agents(initial_families)
#Phase 4
pop = jobs.make_jobs(pop)
pop = phenotypes.make_phenotypes(pop)
pop_size = len(pop.keys())
gis = movement.Movement()
shops = gis.shops()
families, services, water = familyAgents.make_families(pop, gis, shops)
children = children_total(female_child_age, male_child_age)

#Save data necessary for use in model
save_obj(families, "population")
save_obj(shops, "shops")
save_obj(children, "children")
save_obj(pop_size, "pop_size")
#save_obj(water, "water")

#saved for reference
populations = pd.DataFrame(families)
populations.to_csv("Kianda_Pop.csv")
示例#30
0
#!/usr/bin/env python

import movement

car = movement.Movement()
car.halt()