def __init__(self):
         puertos = (os.popen("ls /dev/ttyACM*").read()).split()
         #for x in puertos:
                 #print(x)
                 #ser = scan(x,q)
         
         #try:
                 
         thread1 = Joystick(1, "Controller")
         thread1.start()
         while 1:
                 print(globalVariables.fila.get()[0])
                 print(globalVariables.fila.get()[1])
Exemple #2
0
    def robotInit(self):
        """Initialization method for the Frobo class.  Initializes objects needed elsewhere throughout the code."""

        # Initialize Joystick
        self.controller = Joystick(Values.CONTROLLER_ID)

        # Initialize Drive Sub-System
        self.drive = FroboDrive(self, Values.DRIVE_LEFT_MAIN_ID,
                                Values.DRIVE_LEFT_SLAVE_ID,
                                Values.DRIVE_RIGHT_MAIN_ID,
                                Values.DRIVE_RIGHT_SLAVE_ID)

        # Initialize Shooter Sub-System
        self.compressor = wpilib.Compressor()
        self.shooter = Shooter(self, Values.SHOOT_FRONT_ID,
                               Values.SHOOT_BACK_ID,
                               Values.SHOOT_SOLENOID_FORWARD_CHANNEL_ID,
                               Values.SHOOT_SOLENOID_REVERSE_CHANNEL_ID)
Exemple #3
0
def main():
    js = Joystick()
    md = MotorDriver()

    KEEP_DRIVING = True

    try:
        while KEEP_DRIVING:
            js.get_event()
            x, y = js.get_left_x_y()
            x_r, y_r = js.get_right_x_y()

            # Halt if Lstick in center
            if y < EPSILON_FWD and y > -EPSILON_FWD\
                  and x < EPSILON_FWD and x > -EPSILON_FWD:
                md.halt()

            # Back/forward
            if y > EPSILON_FWD:  # y is positive when pushed down
                md.go_back()
                if x_r > EPSILON_FWD:
                    md.turn_1pt_back_right()
                elif x_r < -EPSILON_FWD:
                    md.turn_1pt_back_left()

            elif y < -EPSILON_FWD:
                md.go_forward()
                # 1 point Left/Right
                if x_r > EPSILON_FWD:
                    md.turn_1pt_forward_right()
                elif x_r < -EPSILON_FWD:
                    md.turn_1pt_forward_left()

            # Spot Left/Spot Right
            if x > EPSILON_FWD:
                md.turn_right()
            elif x < -EPSILON_FWD:
                md.turn_left()

    except KeyboardInterrupt as e:
        KEEP_DRIVING = False
        md.halt()
        print("\nExiting...")
Exemple #4
0
#!/usr/bin/env python3
import pygame
import time
import os
import sys
from motor_controller import MotorController
from controller import Joystick

if __name__ == '__main__':
    os.environ["SDL_VIDEODRIVER"] = "dummy"
    pygame.init()
    pygame.joystick.init()

    motoCon = MotorController()
    # if controllerJoystickIsUp:
    #   motoCon.forward()
    with Joystick(0) as controller:
        while True:
            controller.update()
            inputs = controller.get_all_vals()
            if inputs['button_0']:
                motoCon.forward()
            elif inputs['button_1']:
                motoCon.stop()
            elif inputs['button_2']:
                motoCon.reverse()
            motoCon.set_steering(inputs['axis_0'])
            motoCon.print_stat()
            time.sleep(0.1)
            
 def __init__(self, cmdr, id = None):
     if id == None:
         Joystick.__init__(self, "G940")
     else:
         Joystick.__init__(self, id)
     Steuerung.__init__(self, cmdr)
 def __init__(sef, cmdr, id = None):
     if id == None:
         Joystick.__init__(self, "Driving Force")
     else:
         Joystick.__init__(self, id)
     Steuerung.__init__(self, cmdr)
 def __init__(self, cmdr, id = None):
     if id == None:
         Joystick.__init__(self, "T.Flight Hotas")
     else:
         Joystick.__init__(self, id)
     Steuerung.__init__(self, cmdr)
Exemple #8
0
 def __init__(self):
     self.joystick = Joystick()
     self.id = 0
     self.dir = ""
     self.isRecording = False
     self.sct = mss.mss()
Exemple #9
0
        resized = img.resize((160, 120))
        resized.save('%s/%s' % (self.dir, self.get_image_name(id)))

    def capture_joystick(self, joystick, id):
        image_name = self.get_image_name(id)
        throttle = joystick.getThrottle()
        steering = joystick.getSteering()
        brake = joystick.getBrake()
        with open('%s/record_%d.json' % (self.dir, id), 'w') as f: 
            f.write('{"cam/image_array":"%s","user/throttle":%i,"user/steering":%i, "user/brake":%i, "user/mode":"user"}' % (image_name, throttle, steering, brake))

    def is_recording(self):
        return self.isRecording

if __name__ == "__main__":
    joystick = Joystick()
    limit = 10000
    print('Limiting recording to', limit)

    print ('\a')
    if os.path.isfile('log/meta.json'):
        with open('log/meta.json', 'w') as f: 
            f.write('{"inputs":["cam/image_array","user/angle","user/throttle","user/mode"],"types":["image_array","float","float","str"]}')
    
    try:
        with mss.mss() as sct:
            counter = 0
            prevSec = datetime.now().time().second
            while True: 
                captureJoystick(joystick, counter)
                captureScreen(sct, counter)