Ejemplo n.º 1
0
def run():
    robot = Robot(write=False)

    float_generator = FloatGenerator()
    float_consumer = FloatConsumer()
    hex_byte_consumer = HexByteConsumer()
    float_and_hex_consumer = HexAndFloatConsumer(enabled=False)

    float_consumer.subscribe(
        Feed(float_consumer.float_generator_tag, float_generator))
    hex_byte_consumer.subscribe(
        Feed(hex_byte_consumer.float_generator_tag, float_generator,
             hex_byte_consumer.hex_byte_service_tag))
    # float_and_hex_consumer.subscribe(Feed(
    #     float_and_hex_consumer.float_tag,
    #     float_generator
    # ))
    # float_and_hex_consumer.subscribe(Feed(
    #     float_and_hex_consumer.hex_tag,
    #     float_generator,
    #     float_and_hex_consumer.hex_byte_service_tag
    # ))

    float_generator.subscribe(
        Feed(float_generator.multiplier_tag, float_consumer))

    robot.run(float_generator, float_consumer, hex_byte_consumer,
              float_and_hex_consumer)
Ejemplo n.º 2
0
def main():
    robot = Robot(write=False)

    viewer = CameraViewer()
    video = VideoPlayer(
        file_name="07_39_40.mp4",
        log_level=10,
        width=800,
        height=500,
    )
    rat = Ratslam("config.txt", log_level=10)
    plotter = LivePlotter(1)

    viewer.subscribe(Update(viewer.capture_tag, video))
    rat.subscribe(Update(rat.capture_tag, video))
    rat.subscribe(Subscription(rat.plotter_tag, plotter))

    robot.run(viewer, video, rat, plotter)
Ejemplo n.º 3
0
from atlasbuggy import Robot
from atlasbuggy.subscriptions import *
from atlasbuggy.camera import CameraViewer
from atlasbuggy.camera import VideoPlayer

robot = Robot(write=False)

viewer = CameraViewer()
video = VideoPlayer(file_name="...", width=800, height=500)

viewer.subscribe(Update(viewer.capture_tag, video))

robot.run(video, viewer)
Ejemplo n.º 4
0
# file_path = "images/training_data/Screen Shot 2017-07-28 at 11.37.48 AM.png"
# file_path = "images/training_data/rotated Screen Shot 2017-07-28 at 11.41.38 AM.png"
# file_path = "../../obstacle_detection/cnn_depth_tensorflow/data/nyu_datasets/00021.jpg"
# file_path = "../../obstacle_detection/cnn_depth_tensorflow/data/nyu_datasets/00086.jpg"
# file_path = "images/IMG_0715.jpg"
# file_path = "images/Rolls Day ?/IMG_5753.JPG"
# file_path = "images/Sharing/20170422_090847.jpg"
# file_path = "images/Sharing/18110186_1356939561050895_1563625801_o.jpg"
file_path = "images/Sharing/IMG_5996.JPG"

if not os.path.isfile(file_path):
    raise FileNotFoundError(file_path)
image = cv2.imread(file_path)

robot = Robot(write=False)
# depth_pipeline = MasazIDepthPipeline("depth_models/coarse", "depth_models/fine", enabled=True)
depth_pipeline = MonodepthPipeline("kitti_resnet")
depth_pipeline.height, depth_pipeline.width = image.shape[0:2]

t0 = time.time()
depth = depth_pipeline.pipeline(image)
t1 = time.time()

print("took %0.4fs" % (t1 - t0))

cv2.imwrite("output.png", depth)

# cv2.imshow("depth", depth)
# cv2.waitKey(-1)
Ejemplo n.º 5
0
        self.pipeline_tag = "pipeline"
        self.pipeline_service_tag = "results"
        self.require_subscription(self.pipeline_tag, Feed, MyPipeline, self.pipeline_service_tag)

    def take(self, subscriptions):
        self.pipeline_feed = subscriptions[self.pipeline_tag].get_feed()

    async def run(self):
        while self.is_running():
            while not self.pipeline_feed.empty():
                results = await self.pipeline_feed.get()
                self.pipeline_feed.task_done()
                self.logger.info("results: %s" % results)
            await asyncio.sleep(0.1)

robot = Robot(write=False)

recorder = VideoRecorder()
camera = CameraStream(capture_number=0, width=800, height=500)
viewer = CameraViewer(enable_trackbar=False)
pipeline = MyPipeline()
dummy = DummyConsumer()

recorder.subscribe(Feed(recorder.capture_tag, pipeline))
# recorder.subscribe(Feed(recorder.capture_tag, camera))
viewer.subscribe(Update(viewer.capture_tag, pipeline))
pipeline.subscribe(Update(pipeline.capture_tag, camera))
dummy.subscribe(Feed(dummy.pipeline_tag, pipeline, dummy.pipeline_service_tag))

robot.run(viewer, camera, pipeline, recorder, dummy)
Ejemplo n.º 6
0
from atlasbuggy import Robot
from atlasbuggy.subscriptions import Feed
from HSA import SecurityBot, HSAServer, HSAWebSocket

robot = Robot()

securitybot = SecurityBot()
server = HSAServer()
websocket = HSAWebSocket()

securitybot.subscribe(Feed(securitybot.server_tag, server))

robot.run(securitybot, server, websocket)
Ejemplo n.º 7
0
from atlasbuggy import Robot
from multirobot import MultiRobotManager

robot = Robot(log_level=10)
multibot = MultiRobotManager()
robot.run(multibot)
Ejemplo n.º 8
0
        self.producer_feed = None  # the object that acts a pipe between Producer and Consumer
        self.require_subscription(
            self.producer_tag, Update,
            Producer)  # signal that this is a required subscription

    def take(self, subscriptions):
        self.producer_feed = subscriptions[
            self.producer_tag].get_feed()  # obtain the pipe

    def run(self):
        while self.is_running():
            if not self.producer_feed.empty(
            ):  # wait for producer to post something
                counter = self.producer_feed.get()  # get posted content
                self.logger.info("I consumed '%s'" %
                                 counter)  # print to terminal
            time.sleep(0.5)  # wait for 0.5 seconds

    def stop(self):
        self.logger.info("Good bye!")


robot = Robot(write=False)

producer = Producer()
consumer = Consumer()

consumer.subscribe(Update(consumer.producer_tag, producer))

robot.run(producer, consumer)
Ejemplo n.º 9
0
    # ----- other overrideable methods -----

    async def update(self):
        self.logger.info("update")

    def time_started(self):
        # change the start time behavior. If you want the timer to start later, return None
        # and set self.start_time.
        return None

    def receive_log(self, log_level, message, line_info):
        # if LogParser subscribes to this stream, it will give log messages that match
        # this stream's name
        self.logger.info(message)


robot = Robot(write=False, log_level=20)

static = OrderDemoStatic()
asynchronous = OrderDemoAsync()
threaded = OrderDemoThreaded()

important_methods = ImportantMethods()
important_methods.subscribe(Subscription(important_methods.some_tag, static))

# robot.run(static)
# robot.run(asynchronous)
# robot.run(threaded)
robot.run(important_methods)
Ejemplo n.º 10
0
        #         self.get_counter()
        #
        #         time.sleep(0.5)  # some time consuming operation
        #
        #         self.producer_feed.task_done()
        #     time.sleep(0.05)

        while self.is_running():
            while not self.producer_feed.empty():
                self.get_counter()
                self.producer_feed.task_done()
            time.sleep(0.05)

    def get_counter(self):
        counter = self.producer_feed.get(
        )  # wait for producer to post something
        self.logger.info("I consumed '%s'" % counter)  # print to terminal

    def stop(self):
        self.logger.info("Good bye!")


robot = Robot(write=False, log_level=10)

producer = Producer()
consumer = Consumer()

consumer.subscribe(Feed(consumer.producer_tag, producer))

robot.run(producer, consumer)
Ejemplo n.º 11
0
        else:
            self.logger.warning("Unrecognized whoiam ID '%s in logs! Packet: %s" % (whoiam, packet))


class MiniCommandLine(CommandLine):
    def __init__(self, enabled=True, log_level=None):

        self.reader_writer = None
        self.reader_writer_tag = "reader_writer"
        self.require_subscription(self.reader_writer_tag, Subscription, ReaderWriterRobot)

        super(MiniCommandLine, self).__init__(enabled, log_level)

    def handle_input(self, line):
        if line == "0" or line == "off":
            self.reader_writer.interface.off()
        elif line == "1" or line == "on":
            self.reader_writer.interface.on()
        if line == "2" or line == "toggle":
            self.reader_writer.interface.toggle()


robot = Robot()

reader_writer = ReaderWriterRobot()
cmdline = MiniCommandLine()

cmdline.subscribe(Subscription(cmdline.reader_writer_tag, reader_writer))

robot.run(reader_writer, cmdline)
Ejemplo n.º 12
0
from naboris.texture.pipeline import TexturePipeline
from atlasbuggy import Robot

Robot()
pipeline = TexturePipeline()
pipeline.train()
Ejemplo n.º 13
0
# from naboris.inception.pipeline import InceptionPipeline

parser = argparse.ArgumentParser()
parser.add_argument("-l",
                    "--log",
                    help="disable logging",
                    action="store_false")
parser.add_argument("-d",
                    "--debug",
                    help="enable debug prints",
                    action="store_true")
args = parser.parse_args()

log = args.log

robot = Robot(write=log)

video_file_name = robot.log_info["file_name"].replace(";", "_")[:-3] + "mp4"
video_directory = "videos/" + robot.log_info["directory"].split("/")[-1]

camera = PiCamera(file_name=video_file_name, directory=video_directory)
leona = Leona()
pipeline = LeonaPipeline(enabled=True)
cmdline = CMDline()

leona.subscribe(Feed(leona.pipeline_tag, pipeline, leona.results_service_tag))

cmdline.subscribe(Subscription(cmdline.leona_tag, leona))
cmdline.subscribe(Subscription(cmdline.capture_tag, camera))
pipeline.subscribe(Update(pipeline.capture_tag, camera))
Ejemplo n.º 14
0

class DummyCommandLine(DataStream):
    def __init__(self):
        super(DummyCommandLine, self).__init__(True)

    def handle_input(self, line):
        print(line)


def key_press_fn(event):
    if event.key == "q":
        plotter.exit()


robot = Robot(log_level=10)

simulator = LogParser("logs/2017_Aug_01/22;49;47.log.xz",
                      enabled=False,
                      update_rate=0.001)
plotter = LivePlotter(1,
                      matplotlib_events=dict(key_press_event=key_press_fn),
                      close_when_finished=True,
                      enabled=True)
naboris = Naboris()
capture = VideoPlayer(file_name="videos/naboris/2017_Aug_01/22_49_47-1.mp4",
                      enabled=True,
                      loop_video=True)
viewer = CameraViewer(enabled=True, enable_trackbar=True)
# pipeline = NaborisPipeline(enabled=True)
pipeline = InceptionPipeline(enabled=False)
Ejemplo n.º 15
0
from atlasbuggy import Robot
from atlasbuggy.logparser import LogParser
from atlasbuggy.subscriptions import *
from .serial_cmdline import ReaderWriterRobot

robot = Robot()

simulator = LogParser("fill with the path to your log file", enabled=True, update_rate=0.001)
reader_writer = ReaderWriterRobot()

simulator.subscribe(Subscription("reader_writer", reader_writer))

robot.run(simulator)