Example #1
0
 def parse_file(file_name, directory):
     if len(sys.argv) > 1:
         robot = Robot(wait_for_all=True, log_level=10)
         parser = DemoParser(file_name, directory)
         robot.run(parser)
     else:
         raise RuntimeError(
             "Please input the file path you want to display")
Example #2
0
                        resolution = 0.5
                    else:
                        resolution = 0.75
                    print("resolution: %sÂș" % resolution)

                    distances = []
                    angles = np.linspace(0, np.pi, int(num_samples / 2))
                    for sample_index in range(0, num_samples, 2):
                        distances.append(
                            parse_16bit(data[sample_index],
                                        data[sample_index + 1]))

                    distances = np.array(distances)

                    scan_plot.update(distances * np.cos(angles),
                                     distances * np.sin(angles))
                    await asyncio.sleep(0.5)

                    print(num_commands)
                    if num_commands > 2:
                        plotter.active_window_resizing = False
                        scan_plot.window_resizing = False
                    num_commands += 1
    plotter.plot()
    # robot.exit()


scan_plot = RobotPlot("lms200", marker='.', linestyle='')
plotter = LivePlotter(1, scan_plot)
Robot.run(plotter, loop_fn=run)
Example #3
0
from remote.socket_client import NaborisSocketClient, CLI
from remote.logitech import Logitech
from atlasbuggy.robot import Robot

socket = NaborisSocketClient(debug=True)
cli = CLI(socket)
logitech = Logitech(socket)

Robot.run(socket, cli, logitech)
Example #4
0
from atlasbuggy.robot import Robot
from atlasbuggy.ui.plotters.liveplotter import LivePlotter
# from atlasbuggy.ui.plotters.staticplotter import StaticPlotter
from naboris import Naboris
from naboris.serial_simulator import NaborisSimulator

serial_file_name, serial_directory = "23;53", "2017_May_29"

naboris = Naboris()
plotter = LivePlotter(1)
simulator = NaborisSimulator(naboris, serial_file_name, serial_directory,
                             plotter)

Robot.run(simulator, plotter)
Example #5
0
    def take(self, subscriptions):
        self.video = self.subscriptions[self.video_tag].stream
        self.video_feed = self.subscriptions[self.video_tag].queue

    async def update(self):
        if len(self.client_writers) > 0:
            while not self.video_feed.empty():
                frame = self.video_feed.get()
                bytes_frame = self.video.numpy_to_bytes(frame)
                length = len(bytes_frame).to_bytes(4, 'big')
                preamble = b'\x54'
                message = preamble + length + bytes_frame
                self.write_all(message, append_newline=False)
                self.logger.debug(length)
        await asyncio.sleep(1 / self.video.fps)


robot = Robot(log_level=10)

capture = VideoPlayer(file_name="21_25_23.mp4",
                      directory="videos/naboris/2017_Jun_10",
                      loop_video=True)
socket = MyServer()
viewer = CameraViewer()

socket.subscribe(Feed(socket.video_tag, capture))
viewer.subscribe(Update(viewer.capture_tag, capture))

robot.run(viewer, capture, socket)
Example #6
0
class CameraSimulator(VideoPlayer):
    def __init__(self, video_name, video_directory, serial_simulator):
        super(CameraSimulator, self).__init__(video_name, video_directory)
        self.serial_simulator = serial_simulator

    def update(self):
        while self.serial_simulator.current_frame < self.current_frame:
            if not self.serial_simulator.next():
                self.exit()


data_sets = {
    "my room": (("20;50", "2017_May_28"), ),
    "hallway": (("16;23", "2017_May_28"), )
}

serial_file_name, serial_directory = data_sets["hallway"][0]

video_name = serial_file_name.replace(";", "_")
video_directory = "naboris/" + serial_directory

naboris = Naboris()
serial_file = NaborisSimulator(naboris, serial_file_name, serial_directory)
capture = CameraSimulator(video_name, video_directory, serial_file)
pipeline = NaborisPipeline(naboris, enabled=True, capture=capture)
viewer = CameraViewer(capture, pipeline, enabled=True, enable_slider=True)
capture.link_viewer(viewer)

Robot.run(capture, viewer, pipeline)
Example #7
0
import argparse
from leona.camera import RPiCam
from leona.cli import CMDline
from leona.pipeline import Pipeline
from leona import Leona

# from atlasbuggy.cameras.picamera.pivideo import PiVideoRecorder as Recorder
# from atlasbuggy.cameras.cvcamera.cvvideo import CvVideoRecorder as Recorder
from atlasbuggy.robot import Robot

parser = argparse.ArgumentParser()
parser.add_argument("-pipe", "--pipeline", help="enable pipeline", action="store_true")
args = parser.parse_args()

log = args.log

robot = Robot(write=log)

camera = RPiCam()
leona = Leona()
pipeline = Pipeline(args.pipeline)
cmdline = CMDline()

camera.give()
pipeline.give(actuators=leona.actuators, capture=camera)
cmdline.give(leona=leona)

robot.run(camera, leona, pipeline, cmdline)
Example #8
0
from atlasbuggy.robot import Robot

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

log = args.log

logger = Logger(enabled=log)
recorder = Recorder(logger.input_name.replace(";", "_") + ".mp4",
                    ("naboris", logger.input_dir),
                    enabled=log,
                    debug=True)
camera = NaborisCam(logger, recorder)
naboris = Naboris(logger, camera)
pipeline = NaborisPipeline(naboris.actuators, args.pipeline, camera)
cmdline = NaborisCLI(naboris)
website = NaborisWebsite("templates", "static", naboris.actuators, camera,
                         pipeline, cmdline)
socket = NaborisSocketServer(cmdline)

Robot.run(socket, pipeline, naboris, cmdline, website, camera)
Example #9
0
from atlasbuggy.website.socket import SocketServer
from atlasbuggy.robot import Robot


class SocketTest(SocketServer):
    def __init__(self):
        super(SocketTest, self).__init__(debug=True)

    def received(self, writer, data):
        self.write(writer, "ECHO: %s" % data)


socket = SocketTest()

Robot.run(socket)
Example #10
0
from atlasbuggy.camera.viewer import CameraViewer
from atlasbuggy.robot import Robot
from atlasbuggy.subscriptions import *

from naboris.inception.pipeline import InceptionPipeline
from remote.socket_client import NaborisSocketClient, CLI, Commander

robot = Robot(log_level=10)

socket = NaborisSocketClient(address=("naboris", 5000), )
pipeline = InceptionPipeline(enabled=True)
viewer = CameraViewer(enable_trackbar=False)
cli = CLI(enabled=False)
commander = Commander()

pipeline.subscribe(Update(pipeline.capture_tag, socket))
viewer.subscribe(Update(viewer.capture_tag, pipeline))
cli.subscribe(Subscription(cli.client_tag, socket))
commander.subscribe(Subscription(commander.client_tag, socket))
commander.subscribe(
    Update(commander.pipeline_tag,
           pipeline,
           service=commander.results_service_tag))

robot.run(socket, viewer, pipeline, cli, commander)
Example #11
0
from atlasbuggy.website.socket import SocketClient
from atlasbuggy.ui.cmdline import CommandLine
from atlasbuggy.robot import Robot


class CLI(CommandLine):
    def __init__(self, socket_client):
        super(CLI, self).__init__(False, True)

        self.socket_client = socket_client

    def handle_input(self, line):
        if line == "eof":
            self.socket_client.write_eof()
        else:
            self.socket_client.write(line + "\n")


class SocketTest(SocketClient):
    def __init__(self):
        super(SocketTest, self).__init__("socket test")

    def received(self, data):
        print(data)

socket = SocketTest()

Robot.run(CLI(socket), socket)
Example #12
0
        super(CameraSimulator, self).__init__(video_name, video_directory)
        self.serial_simulator = serial_simulator
        self.pipeline = pipeline
        self.pipeline.capture = self

    def update(self):
        while self.serial_simulator.current_frame < self.current_frame:
            if not self.serial_simulator.next():
                self.exit()
            self.pipeline.update_pipeline(self.frame)


data_sets = {
    "my room": (("20;50", "2017_May_28"), ),
    "hallway": (("16;23", "2017_May_28"), )
}

serial_file_name, serial_directory = data_sets["hallway"][0]

video_name = serial_file_name.replace(";", "_")
video_directory = "naboris/" + serial_directory

naboris = Naboris()
serial_file = NaborisSimulator(naboris, serial_file_name, serial_directory)
pipeline = NaborisPipeline(naboris, enabled=True, generate_database=True)
capture = CameraSimulator(video_name, video_directory, serial_file, pipeline)
viewer = CameraViewer(capture, pipeline, enabled=True, enable_slider=True)
capture.link_viewer(viewer)

Robot.run(capture, viewer)
Example #13
0
with_video = False


def update():
    cam_plot_1.append(time.time() - viewer.start_time,
                      viewer.capture.num_frames)


def update_cam():
    cam_plot_2.append(time.time() - viewer.start_time,
                      len(np.where(capture.frame > 128)[0]))


cam_plot_1 = RobotPlot("cam data 1")
cam_plot_2 = RobotPlot("cam data 2")
plotter = LivePlotter(2, cam_plot_1, cam_plot_2, enabled=True)

if with_video:
    capture = VideoPlayer("21_52_42.mp4", "naboris/2017_May_27")
    viewer = CameraViewer(capture, slider_ticks=capture.slider_ticks)
    capture.link_slider(viewer.slider_name)
else:
    recorder = CvVideoRecorder(enabled=True, debug=True)
    capture = CvCamera(capture_number=0, video_recorder=recorder)
    viewer = CameraViewer(capture)

viewer.update = update
capture.update = update_cam

Robot.run(capture, viewer, plotter)