def test_serialize_connections(self):
        bot = robot({
            "name": "TestRobot1",
            "connections": {
                "camera": {
                    "adaptor": "zorg_network_camera.Camera",
                },
            },
            "devices": {
                "camera_one": {
                    "connection": "camera",
                    "driver": "zorg_network_camera.Feed",
                    "url": "http://192.168.10.12/image.jpg",
                },
            },
            "work": None,
        })

        self.assertTrue(len(bot.serialize_connections()))
Esempio n. 2
0
    def test_serialize_connections(self):
        bot = robot({
            "name": "TestRobot1",
            "connections": {
                "camera": {
                    "adaptor": "zorg_network_camera.Camera",
                },
            },
            "devices": {
                "camera_one": {
                    "connection": "camera",
                    "driver": "zorg_network_camera.Feed",
                    "url": "http://192.168.10.12/image.jpg",
                },
            },
            "work": None,
        })

        self.assertTrue(len(bot.serialize_connections()))
Esempio n. 3
0
    count = 0

    while True:

        my.speech.speak(count)
        print(count)

        count = count + 1

        # Wait 1 second before doing it again
        time.sleep(1)

robot = zorg.robot({
    "connections": {
        "serial": {
            "adaptor": "zorg_emic.Serial",
            "port": "/dev/ttyAMA0",
        },
    },
    "devices": {
        "speech": {
            "connection": "serial",
            "driver": "zorg_emic.Emic2",
        }
    },
    "name": "example", # Give your robot a unique name
    "work": work, # The method (on the main level) where the work will be done
})

robot.start()
Esempio n. 4
0
def main():
    robot = zorg.robot({
        "name": "Salvius",
        "connections": {
            "camera": {
                "adaptor": "zorg_network_camera.Camera",
                "url": "http://192.168.1.6/image.jpg"
            },
            "chatterbot": {
                "adaptor": "salvius.communication.Conversation",
                "io_adapter": "chatterbot.adapters.io.JsonAdapter"
            },
            "serial": {
                "adaptor": "zorg_emic.Serial",
                "port": "/dev/ttyAMA0",
            },
            "sphinx": {
                "adaptor": "salvius.speech.SpeechRecognition",
                "recognizer_function": "recognize_sphinx"
            },
            "analytics": {
                "adaptor": "iot_analytics.apps.zorg.GoogleAnalytics",
                "property_id": "UA-12573345-12",
                "client_id": "salvius",
            },
        },
        "devices": {
            "camera_one": {
                "connection": "camera",
                "driver": "zorg_network_camera.Feed"
            },
            "camera_ocr": {
                "connection": "camera",
                "driver": "zorg_network_camera.OCR"
            },
            "communication": {
                "connection": "chatterbot",
                "driver": "salvius.communication.ApiDriver"
            },
            "speech_synthesis": {
                "connection": "serial",
                "driver": "zorg_emic.Emic2",
            },
            "speech_synthesis2": {
                "connection": "chatterbot",
                "driver": "salvius.speech.SpeechSynthesis",
            },
            "speech_recognition": {
                "connection": "sphinx",
                "driver": "salvius.speech.ApiDriver",
            },
            "touch_sensor": {
                "connection": "analytics",
                "driver": "iot_analytics.apps.zorg.drivers.Event",
            }
        },
        "work": work,
    })

    api = zorg.api("zorg.api.Http", {})

    try:
        robot.start()
        api.start()
    except (KeyboardInterrupt, EOFError, SystemExit):
        pass
Esempio n. 5
0
def work (my):
    while True:

        # Toggle the led
        my.led.toggle()
        print("Blink")

        # Wait 1 second before doing it again
        time.sleep(1)

robot = zorg.robot({
    "connections": {
        "firmata": {
            "adaptor": "zorg_firmata.Firmata",
            "port": "/dev/ttyUSB0",
        },
    },
    "devices": {
        "led": {
            "connection": "firmata",
            "driver": "zorg_gpio.Led",
            "pin": 13, # 13 is the on-board LED
        }
    },
    "name": "example", # Give your robot a unique name
    "work": work, # The method (on the main level) where the work will be done
})

robot.start()
Esempio n. 6
0
import zorg
import time


def buzz(my):
    while True:
        my.buzzer.toggle()
        time.sleep(0.5)

robot = zorg.robot({
    "name": "Test",
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "buzzer": {
            "connection": "edison",
            "driver": "zorg_gpio.Buzzer",
            "pin": 4, # Digital pin 4
        },
    },
    "work": buzz,
})

robot.start()
Esempio n. 7
0
    robot.touch_sensor.send(
        category='button',
        action='pressed',
        label='momentary',
        value='30'
    )
    print("button press detected")

    # Wait 1 second before doing it again
    time.sleep(1)

robot = zorg.robot({
    "connections": {
        "analytics": {
            "adaptor": "iot_analytics.apps.zorg.GoogleAnalytics",
            "property_id": "UA-12573345-12",
            "client_id": "d944d45c-9c92-46a2-97be-9ba07d922227",
        },
    },
    "devices": {
        "touch_sensor": {
            "connection": "analytics",
            "driver": "iot_analytics.apps.zorg.drivers.Event",
        }
    },
    "name": "example", # Give your robot a unique name
    "work": work, # The method (on the main level) where the work will be done
})

robot.start()
Esempio n. 8
0
import zorg
import time


def work(my):
    while True:
        reading = my.button.is_pressed()
        print("touched:", reading)
        time.sleep(0.5)


robot = zorg.robot({
    "name": "Test",
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "button": {
            "connection": "edison",
            "driver": "zorg_gpio.Button",
            "pin": 4,  # Digital pin 4
        },
    },
    "work": work,
})

robot.start()
Esempio n. 9
0
'''


def work(my):
    while True:
        print(my.ocr.read())
        time.sleep(1)


robot = zorg.robot({
    "name": "CameraBot",
    "connections": {
        "camera": {
            "adaptor": "zorg_network_camera.Camera",
            "url": "http://salvius.org/images/news02.jpg",
        },
    },
    "devices": {
        "ocr": {
            "connection": "camera",
            "driver": "zorg_network_camera.OCR"
        },
    },
    "work": work,
})

api = zorg.api("zorg.api.Http", {})

robot.start()
api.start()
Esempio n. 10
0
import zorg
import time


def work(my):
    while True:
        angle = my.potentiometer.read_angle()
        print(angle, "degrees")
        time.sleep(0.5)

robot = zorg.robot({
    "name": "Test",
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "potentiometer": {
            "connection": "edison",
            "driver": "zorg_grove.RotaryAngleSensor",
            "pin": 0, # Analog pin 0
        },
    },
    "work": work,
})

robot.start()
Esempio n. 11
0
    while True:

        my.speech.speak(count)
        print(count)

        count = count + 1

        # Wait 1 second before doing it again
        time.sleep(1)


robot = zorg.robot({
    "connections": {
        "serial": {
            "adaptor": "zorg_emic.Serial",
            "port": "/dev/ttyAMA0",
        },
    },
    "devices": {
        "speech": {
            "connection": "serial",
            "driver": "zorg_emic.Emic2",
        }
    },
    "name": "example",  # Give your robot a unique name
    "work": work,  # The method (on the main level) where the work will be done
})

robot.start()
Esempio n. 12
0
    while True:
        print(my.camera_one.get_url())
        print(my.camera_two.get_brightness())
        time.sleep(1)


robot = zorg.robot({
    "name": "CameraBot",
    "connections": {
        "camera": {
            "adaptor": "zorg_network_camera.Camera",
            "url": "http://192.168.10.12/image.jpg",
        },
    },
    "devices": {
        "camera_one": {
            "connection": "camera",
            "driver": "zorg_network_camera.Feed"
        },
        "camera_two": {
            "connection": "camera",
            "driver": "zorg_network_camera.LightSensor"
        },
    },
    "work": work,
})

api = zorg.api("zorg.api.Http", {})

robot.start()
api.start()
Esempio n. 13
0
import time
import zorg


def blink_led(my):
    while True:
        my.led.toggle()
        time.sleep(100)

robot = zorg.robot({
    "name": "Test",
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "led": {
            "connection": "edison",
            "driver": "zorg_gpio.Led",
            "pin": 4, # Digital pin 4
        },
    },
    "work": blink_led,
})

robot.start()
Esempio n. 14
0
    
    sleep(2.0)
    
    my.lcd.backlight_color(155,255,0)
    my.lcd.print_string("Yellow")
    
    
robot = zorg.robot({
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "led": {
            "connection": "edison",
            "driver": "zorg_gpio.Led",
            "pin": 13, # 13 is the on-board LED
        },
        "lcd": {
            "connection": "edison",
            "driver": "zorg_grove.LCD",
            "address":  0x62,
        }
    },
    "name": "example", # Give your robot a unique name
    "work": work, # The method (on the main level) where the work will be done
})

robot.start()
Esempio n. 15
0
    #     # Wait 1 seconds before doing it again
    #     time.sleep(1)


robot = zorg.robot({
    "connections": {
        "ArduinoLeonardo": {
            "adaptor": "zorg_firmata.Firmata",
            # "port": "/dev/ttyACM0",
            "port": "/dev/tty.usbmodem14101",
        },
    },
    "devices": {
        "left_servo": {
            "connection": "ArduinoLeonardo",
            "driver": "zorg_grove.Servo",
            "port_id": "/dev/tty.usbmodem14101",
            "pin": 9,  # 9 is a pwm pin
        },
        # "right_servo": {
        #     "connection": "ArduinoLeonardo",
        #     "driver":     "zorg_grove.Servo",
        #     "pin":        10,  # 10 is a pwm pin
        # }
    },
    "name": "Servo Robot",  # Give your robot a unique name
    "work": work,  # The method where the work will be done
})

thread = Thread(target=keyboard_reader, args=(data, stop, fd))
# thread.start()
print(" --> next")
Esempio n. 16
0
def main():
    robot = zorg.robot({
        "name": "Salvius",
        "connections": {
            "camera": {
                "adaptor": "zorg_network_camera.Camera",
                "url": "http://192.168.1.6/image.jpg"
            },
            "chatterbot": {
                "adaptor": "salvius.communication.Conversation",
                "io_adapter": "chatterbot.adapters.io.JsonAdapter"
            },
            "serial": {
                "adaptor": "zorg_emic.Serial",
                "port": "/dev/ttyAMA0",
            },
            "sphinx": {
                "adaptor": "salvius.speech.SpeechRecognition",
                "recognizer_function": "recognize_sphinx"
            },
            "analytics": {
                "adaptor": "iot_analytics.apps.zorg.GoogleAnalytics",
                "property_id": "UA-12573345-12",
                "client_id": "salvius",
            },
        },
        "devices": {
            "camera_one": {
                "connection": "camera",
                "driver": "zorg_network_camera.Feed"
            },
            "camera_ocr": {
                "connection": "camera",
                "driver": "zorg_network_camera.OCR"
            },
            "communication": {
                "connection": "chatterbot",
                "driver": "salvius.communication.ApiDriver"
            },
            "speech_synthesis": {
                "connection": "serial",
                "driver": "zorg_emic.Emic2",
            },
            "speech_synthesis2": {
                "connection": "chatterbot",
                "driver": "salvius.speech.SpeechSynthesis",
            },
            "speech_recognition": {
                "connection": "sphinx",
                "driver": "salvius.speech.ApiDriver",
            },
            "touch_sensor": {
                "connection": "analytics",
                "driver": "iot_analytics.apps.zorg.drivers.Event",
            }
        },
        "work": work,
    })

    api = zorg.api("zorg.api.Http", {})

    try:
        robot.start()
        api.start()
    except (KeyboardInterrupt, EOFError, SystemExit):
        pass
Esempio n. 17
0
    angle = 0

    while True:
        my.servo.set_angle(angle)

        angle += 45

        if angle > 135:
            angle = 0

        time.sleep(100)

robot = zorg.robot({
    "name": "Test",
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "led": {
            "connection": "edison",
            "driver": "zorg_gpio.Servo",
            "pin": 5, # Digital/PWM pin 5
        },
    },
    "work": move_servo,
})

robot.start()
    while True:
        my.servo.set_angle(angle)

        angle += 45

        if angle > 135:
            angle = 0

        time.sleep(100)


robot = zorg.robot({
    "name": "Test",
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "led": {
            "connection": "edison",
            "driver": "zorg_gpio.Servo",
            "pin": 5,  # Digital/PWM pin 5
        },
    },
    "work": move_servo,
})

robot.start()
Esempio n. 19
0
        time.sleep(1)

robot = zorg.robot({
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison"
        }
    },
    "devices": {
        "lock": {
            "driver": "zorg_gpio.Servo",
            "connection": "edison",
            "pin": 5
        },
        "led": {
            "driver": "zorg_gpio.Led",
            "connection": "edison",
            "pin": 4
        },
        "mic": {
            "driver": "zorg_gpio.AnalogSensor",
            "connection": "edison",
            "pin": 1
        }
    },
    "name": "Smith",
    "work": work
})

api = zorg.api("zorg.api.Http", {})
Esempio n. 20
0
robot = zorg.robot({
    "name": "Salvius",
    "connections": {
        "camera": {
            "adaptor": "zorg_network_camera.Camera",
            "url": "http://192.168.1.6/image.jpg"
        },
        "chatterbot": {
            "adaptor": "communication.Conversation"
        }
        #"raspberry_pi": {
            # "adaptor": "zorg-raspi.RasPi",
        #},
    },
    "devices": {
        "camera_one": {
            "connection": "camera",
            "driver": "zorg_network_camera.Feed"
        },
        "camera_ocr": {
            "connection": "camera",
            "driver": "zorg_network_camera.OCR"
        },
        "communication": {
            "connection": "chatterbot",
            "driver": "communication.ApiDriver"
        },
    },
    "work": work,
})
Esempio n. 21
0
import time
import zorg


def blink_led(my):
    while True:
        my.led.toggle()
        time.sleep(100)


robot = zorg.robot({
    "name": "Test",
    "connections": {
        "edison": {
            "adaptor": "zorg_edison.Edison",
        },
    },
    "devices": {
        "led": {
            "connection": "edison",
            "driver": "zorg_gpio.Led",
            "pin": 4,  # Digital pin 4
        },
    },
    "work": blink_led,
})

robot.start()
Esempio n. 22
0
def work(my):
    while True:

        # Check the state of the button
        print("Button is pressed?:", my.button.is_pressed())
        #print("Button was bumped?", my.button.is_bumped())

        # Wait 1 second before doing it again
        time.sleep(0.5)

robot = zorg.robot({
    "connections": {
        "firmata": {
            "adaptor": "zorg_firmata.Firmata",
            "port": "/dev/ttyACM0",
        },
    },
    "devices": {
        "button": {
            "connection": "firmata",
            "driver": "zorg_gpio.Button",
            "pin": 7, # 7 is a digital pin
        }
    },
    "name": "example", # Give your robot a unique name
    "work": work, # The method where the work will be done
})

robot.start()
Esempio n. 23
0
        # Wait 1 seconds before doing it again
        time.sleep(1)

        # Move the servo to 100 degrees
        my.servo.set_angle(100)

        print("Servo angle set to", my.servo.get_angle())

        # Wait 1 seconds before doing it again
        time.sleep(1)

robot = zorg.robot({
    "connections": {
        "ArduinoLeonardo": {
            "adaptor": "zorg_firmata.Firmata",
            "port": "/dev/ttyACM0",
        },
    },
    "devices": {
        "servo": {
            "connection": "ArduinoLeonardo",
            "driver": "zorg_grove.Servo",
            "pin": 9, # 9 is a pwm pin
        }
    },
    "name": "Servo Robot", # Give your robot a unique name
    "work": work, # The method where the work will be done
})

robot.start()
Esempio n. 24
0
def work(my):
    while True:
        print(my.camera_one.get_url())
        print(my.camera_two.get_brightness())
        time.sleep(1)

robot = zorg.robot({
    "name": "CameraBot",
    "connections": {
        "camera": {
            "adaptor": "zorg_network_camera.Camera",
            "url": "http://192.168.10.12/image.jpg",
        },
    },
    "devices": {
        "camera_one": {
            "connection": "camera",
            "driver": "zorg_network_camera.Feed"
        },
        "camera_two": {
            "connection": "camera",
            "driver": "zorg_network_camera.LightSensor"
        },
    },
    "work": work,
})

api = zorg.api("zorg.api.Http", {})

robot.start()
api.start()
Esempio n. 25
0
        # Toggle the led
        print("Reading:", my.light_sensor.read())

        if my.light_sensor.has_changed():
            print("Light sensor reading has changed past threshold.")
        else:
            print("Light sensor reading unchanged.")

        # Wait 1 second before doing it again
        time.sleep(1)

robot = zorg.robot({
    "connections": {
        "firmata": {
            "adaptor": "zorg_firmata.Firmata",
            "port": "/dev/ttyUSB0",
        },
    },
    "devices": {
        "light_sensor": {
            "connection": "firmata",
            "driver": "zorg_gpio.LightSensor",
            "pin": 5, # 5 is an analog pin
        }
    },
    "name": "example", # Give your robot a unique name
    "work": work, # The method where the work will be done
})

robot.start()
Esempio n. 26
0
/api/robots/CameraBot/devices/camera_one/commands/get_url
'''


def work(my):
    while True:
        print(my.ocr.read())
        time.sleep(1)

robot = zorg.robot({
    "name": "CameraBot",
    "connections": {
        "camera": {
            "adaptor": "zorg_network_camera.Camera",
            "url": "http://salvius.org/images/news02.jpg",
        },
    },
    "devices": {
        "ocr": {
            "connection": "camera",
            "driver": "zorg_network_camera.OCR"
        },
    },
    "work": work,
})

api = zorg.api("zorg.api.Http", {})

robot.start()
api.start()