Esempio n. 1
0
    def run(self):
        
        nodes = []
        for i in range(self.config['nodes']):
            nodes.append(Node(i))
        
        comm = Communicator(nodes)

        for node in nodes:
            node.initPaxos(nodes, comm, self.config)
            node.start()

        
        for node in nodes:
            node.join()
Esempio n. 2
0
rc_motors = RCmotors("X8", 200, 320, 50)

leds = [LEDcommand(index, index + 1) for index in range(3)]
blue_led = BlueLEDcommand(3)
servo = ServoCommand(4, 1, start_pos=0)
motors = MotorCommand(5, rc_motors)
tilt_servo = ServoCommand(6, 2, start_pos=0)
pan_servo = ServoCommand(7, 3, start_pos=0)


encoder = RCencoder(0, rc_motors)
gps = GPS(1, 6, 4)
imu = IMU(2, 2, 11)

communicator = Communicator(*leds, blue_led, servo, motors, pan_servo, tilt_servo, uart_bus=1)

while True:
    communicator.read_command()
    
    if imu.recved_data():
        sensor_updated = True
        communicator.write_packet(imu)

    if gps.recved_data():
        sensor_updated = True
        communicator.write_packet(gps)
        pyb.LED(3).toggle()

#    if encoder.recved_data():
#        sensor_updated = True
Esempio n. 3
0
uart = UART(6, 9600, read_buf_len=1000)
pps_pin = pyb.Pin.board.X8
extint = pyb.ExtInt(pps_pin, pyb.ExtInt.IRQ_FALLING,
                    pyb.Pin.PULL_UP, pps_callback)

indicator = pyb.LED(4)
increase = True

sensor_queue = SensorQueue(tmp36,
                           mcp9808,
                           accel,
                           gps
                           )
command_pool = CommandPool(servo1, motor_a)

communicator = Communicator(sensor_queue, command_pool)

while True:
    if new_data:
        while uart.any():
            gps.update(chr(uart.readchar()))
            
    new_data = False
    
    communicator.write_packet()
    communicator.read_command()
    
    if increase:
        indicator.intensity(indicator.intensity() + 5)
    else:
        indicator.intensity(indicator.intensity() - 5)
Esempio n. 4
0
from turret.turret_objects import *
from comm import Communicator

blue_led = BlueLEDcommand(1)

lidar = LidarSensor(0, uart_bus=1)

communicator = Communicator(blue_led, uart_bus=3)

while True:
    #    communicator.read_command()

    if lidar.recved_data():
        communicator.write_packet(lidar)
        print(lidar)

#    pyb.delay(1)

    if communicator.should_reset():
        print("\nresetting")
        lidar.reset()

        communicator.write_packet(lidar)

    if communicator.should_stop():
        print("\nstopping")
        lidar.stop()

        while not communicator.should_reset():
            communicator.read_command()
            pyb.delay(5)
Esempio n. 5
0
from turret.turret_objects import *
from comm import Communicator

blue_led = BlueLEDcommand(1)

lidar = LidarSensor(0, uart_bus=1)

communicator = Communicator(blue_led, uart_bus=3)

while True:
    #    communicator.read_command()

    if lidar.recved_data():
        communicator.write_packet(lidar)
        print(lidar)

    #    pyb.delay(1)

    if communicator.should_reset():
        print("\nresetting")
        lidar.reset()

        communicator.write_packet(lidar)

    if communicator.should_stop():
        print("\nstopping")
        lidar.stop()

        while not communicator.should_reset():
            communicator.read_command()
            pyb.delay(5)
Esempio n. 6
0
def standby():
    pyb_leds[0].off()
    pyb_leds[1].off()
    pyb_leds[2].on()


leds = [LEDcommand(index, index + 1) for index in range(3)]  # 3 normal LEDs
blue_led = BlueLEDcommand(3)
stepper = StepperCommand(4)

setting_up_sensors()

gps = GPS(1, uart_bus=2, timer_num=4)
imu = IMU(2, bus=1, reset_pin="Y7", timer_num=11)

communicator = Communicator(*leds, blue_led, stepper, uart_bus=4)

sensor_updated = False

comm_ready()

pyb.delay(500)
communicator.signal_stop()  # micropython will be in standby at the start
standby()


def reset():
    print("\nResetting sensors")
    gps.reset()
    imu.reset()
    stepper.reset()
Esempio n. 7
0
def standby():
    pyb_leds[0].off()
    pyb_leds[1].off()
    pyb_leds[2].on()

leds = [LEDcommand(index, index + 1) for index in range(3)]  # 3 normal LEDs
blue_led = BlueLEDcommand(3)
stepper = StepperCommand(4)

setting_up_sensors()

gps = GPS(1, uart_bus=2, timer_num=4)
imu = IMU(2, bus=2, reset_pin="X7", timer_num=11)

communicator = Communicator(*leds, blue_led, stepper, uart_bus=4)

sensor_updated = False

comm_ready()

pyb.delay(500)
communicator.signal_stop()  # micropython will be in standby at the start
standby()

while True:
    communicator.read_command()

    if imu.recved_data():
        sensor_updated = True
        communicator.write_packet(imu)