Exemple #1
0
# ---------------- Initialize Pygame Pieces -----------------
robotX = 800
robotY = 800

robot = Robot(screen, robotX, robotY)

y_change = 0
x_change = 0

barrierList = []

# ---------------- Initialize Receiver/Server -----------------
IP = '192.168.0.21'
PORT = 1234
r = Receiver(IP, PORT)

# ---------------- Initialize Variables -----------------
temp_data = 0
accel_data = ''
gyro_data = ''
sonar_data = 0

c = Controller()

# ---------------- Begin Mainloop -----------------
running = True
while running:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
Exemple #2
0
# Initialize Pygame attributes
robotX = 800
robotY = 800

robot = Robot(screen, robotX, robotY)

y_change = 0
x_change = 0

barrierList = []

# Initialize Server/Receiver
IP = "192.168.0.2"
PORT = 1234
r = Receiver(IP, PORT)

# Initialize Sensor values
accel = 0
sonar = 0
imu = 0

#Initialize XBox Controller
pygame.joystick.init()

joystick = pygame.joystick.Joystick(0)
joystick.init()

LEFT_X = 0
LEFT_Y = 1
RIGHT_X = 3
Exemple #3
0
from getData import Receiver

# Make sure IP and PORT match server side IP and PORT
IP = '192.168.2.2'
PORT = 10001
r = Receiver(IP, PORT)
r.client.connect()

while True:
    r.receive()
    print(r.datalist)
cockpit_height = height / 3
cockpit_width = width
cockpit_x = sim_x
cockpit_y = sim_y + sim_height

compass_height = sim_height
compass_width = sim_width
compass_x = sim_x
compass_y = cockpit_y + sim_height

# ---------------- Initialize Receiver/Server -----------------
if server_online:
    # Make sure IP and PORT match server side IP and PORT
    IP = '192.168.2.2'
    PORT = 20001
    r = Receiver(IP, PORT)
    r.client.connect()

# ---------------- Initialize Pygame -----------------
pygame.init()


def barrierExists(barrierList, x, y):
    for barrier in barrierList:
        if barrier.x == x and barrier.y == y:
            return True
    return False


def displayText(surface, text, font, x, y, color, background):
    txt = font.render(text, True, color, background)
# Initialize Pygame attributes
robotX = 800
robotY = 800

robot = Robot(screen, robotX, robotY)

y_change = 0
x_change = 0

barrierList = []

# Initialize Server/Receiver
IP = "192.168.0.21"
PORT = 1234
r = Receiver(IP, PORT)

# Initialize Sensor values
accel = 0
sonar = 0
imu = 0

running = True
while running:

    screen.fill((0, 0, 0))

    if r.server.disconnect_counter == 1:
        r.server.receiveConnection()

    r.receive()
Exemple #6
0
    def __init__(self):
        # Toggle simulation elements
        server_online = False
        pygame_running = True
        controller_connected = False
        data_status = 'GUI'

        print(time.time())

        # Color List
        white = (255, 255, 255)
        green = (0, 255, 0)
        blue = (0, 0, 128)
        black = (0, 0, 0)

        # ---------------- Initialize Pygame -----------------
        pygame.init()

        # ---------------- Initialize Pygame Pieces -----------------
        if pygame_running:

            screen = pygame.display.set_mode((1400, 900))

            robotX = 800
            robotY = 800
            robot_angle = 0
            scanner_angle = 0

            robot = Robot(screen, robotX, robotY, 35, 35, (255, 255, 255))
            scanner = Robot(screen, robotX, robotY, 20, 20, (0, 0, 255))

            y_change = 0
            x_change = 0

            barrierList = []

            font = pygame.font.Font('freesansbold.ttf', 32)
            font_24 = pygame.font.Font('freesansbold.ttf', 24)

        # ---------------- Initialize Receiver/Server -----------------
        if server_online:
            # Make sure IP and PORT match server side IP and PORT
            IP = '192.168.2.2'
            PORT = 10001
            r = Receiver(IP, PORT)
            r.client.connect()

        # ---------------- Initialize Variables -----------------
        temp_data = 0
        accel_data = ''
        gyro_data = ''
        sonar_data = 0
        ir_data = 1

        message = ''

        # ---------------- Initialize Controller -----------------
        if controller_connected:
            c = Controller()

        # Set control mode to either "user-controlled" or "automated
        control_mode = "user-controlled"

        # ------------------- Configure Robot --------------------

        arm_vert_axis = 0
        arm_horiz_axis = 0

        claw_open = True
Exemple #7
0
        robot_height = robot_width = sim_height / 3
        scanner_height = scanner_width = sim_height / 3

        robot = LaneRobot(sim_surface, robotX, robotY, robot_height,
                          robot_width, (255, 255, 255))

    font = pygame.font.Font('freesansbold.ttf', 32)
    font_24 = pygame.font.Font('freesansbold.ttf', 24)

# ---------------- Initialize Receiver/Server -----------------
if server_online:
    # Make sure IP and PORT match server side IP and PORT
    IP = '192.168.2.2'
    PORT = 10000
    r = Receiver(IP, PORT)
    r.client.connect()

# ---------------- Initialize Variables -----------------
temp_data = 0
accel_data = '0'
gyro_data = '0'
sonar_data = '0'
front_dist = '0'
back_dist = '0'
left_dist = '0'
right_dist = '0'
ir_data = 1

ax = ''
ay = ''
    cockpit = Cockpit(cockpit_surface, cockpit_x, cockpit_y, cockpit_height,
                      cockpit_width)
    compass = Compass(compass_surface, compass_x, compass_y, compass_height,
                      compass_width)
    orientation = 0

    font_14 = pygame.font.Font('freesansbold.ttf', 14)
    font_18 = pygame.font.Font('freesansbold.ttf', 18)
    font_24 = pygame.font.Font('freesansbold.ttf', 24)

# ---------------- Initialize Receiver/Server -----------------
if server_online:
    # Make sure IP and PORT match server side IP and PORT
    IP = '192.168.2.2'
    PORT = 20001
    r = Receiver(IP, PORT)
    r.client.connect()

# ---------------- Initialize Variables -----------------
temp_data = 0
accel_data = '0'
gyro_data = '0'
sonar_data = '0'
front_dist = '20'
backleft_dist = '5'
backright_dist = '5'
left_dist = '3'
right_dist = '4'
ir_data = 1
arm_data = 'up'