def main(): imu = imu_sensor.IMU() enc = encoders.Encoders() fast_loop_freq = Config['pygame']['fast_loop_freq'] # 60 Hz loop speed print_lock = threading.Lock() state_vector_lock = threading.Lock() path_planning_lock = threading.Lock() fast_thread = threading.Thread(target=fast_loop, args=(print_lock, state_vector_lock, path_planning_lock, imu, enc, fast_loop_freq), name="fast_loop") fast_thread.start() slow_thread = threading.Thread(target=slow_loop, args=(print_lock, 'dummy_text'), name="slow_loop") slow_thread.start()
def __init__(self, startPos, startDirection): self.cam = camera.Camera() self.sens = sensors.Sensors() self.enc = encoders.Encoders() self.serv = servos.Servos() self.centeredInSquareLength = 7.5 self.sideDistance = 7.05 self.distanceBetweenSquares = 18 self.speed = 7 self.detectWallDistance = 15 self.nav = navigate.Navigate(startPos, startDirection) self.useColor = False self.colorList = [] self.foundColorList = [] self.foundColorNorth = False self.foundColorEast = False self.foundColorSouth = False self.foundColorWest = False
def main(): imu = imu_sensor.IMU() enc = encoders.Encoders() # lidar = lidar.Lidar() # add when written... print_lock = threading.Lock() state_vector_lock = threading.Lock() path_planning_lock = threading.Lock() fast_thread = threading.Thread(target=fast_loop, args=(print_lock, state_vector_lock, path_planning_lock, imu, enc, fast_loop_freq), name="fast_loop") fast_thread.start() slow_thread = threading.Thread(target=slow_loop, args=(print_lock, 'dummy_text'), name="slow_loop") slow_thread.start()
# This program demonstrates usage of the digital encoders. # After executing the program, manually spin the wheels and observe the output. # See https://sourceforge.net/p/raspberry-gpio-python/wiki/Inputs/ for more details. import encoders import servos import time import RPi.GPIO as GPIO import signal # import pandas as pd #objects for servos, encoders, sensors, and camera enc = encoders.Encoders() serv = servos.Servos() # Pins that the encoders are connected to LENCODER = 17 RENCODER = 18 def ctrlC(signum, frame): print("Exiting") serv.stopServos() GPIO.cleanup() exit() def calibrateSpeeds(interval): freq = 1.3 y = 1.3 while freq <= 1.7 and y <= 1.7: serv.setSpeeds(freq, freq) time.sleep(1) speedTuple2 = enc.getSpeeds() print(str((speedTuple2[0] + speedTuple2[1]) / 2) + " RPS")
def __init__(self): self.interface = gtk.Builder() self.interface.add_from_file(UI_DIR + "/sltv.ui") self.main_window = self.interface.get_object("window1") self.main_window.show_all() self.about = about.About(self) self.sltv = Sltv() self.sltv.connect("stopped", self.stopped) self.sltv.connect("playing", self.playing) self.sltv.connect("error", self.error) self.sltv.connect("pipeline-ready", self.on_pipeline_ready) self.preview_frame = self.interface.get_object("preview_frame") self.preview_box = self.interface.get_object("preview_vbox") self.preview = preview.PreviewUI(self, self.sltv) self.preview_box.pack_start(self.preview.get_widget(), False, False) self.preview_area = PreviewArea() self.preview_frame.add(self.preview_area) self.preview_area.show() self.box = self.interface.get_object("paned") self.settings = settings.SettingsUI(self, self.sltv) self.box.add(self.settings.get_widget()) self.play_button = self.interface.get_object("play_button") self.stop_button = self.interface.get_object("stop_button") self.settings_dialog = gtk.Dialog('Settings', self.main_window) self.settings_dialog.set_default_size(400, 400) self.encoders = self.sltv.encoders self.videoconverters = self.sltv.videoconverters self.encoders_ui = encoders.Encoders(self, self.encoders, self.videoconverters) self.metadata_ui = metadata.MetadataUI(self.sltv, self.settings_dialog) self.hbuttonbox = self.interface.get_object("hbuttonbox1") self.volume = volume.VolumeUI(self, self.sltv) self.volume_button = self.volume.get_widget() self.volume_button.show() self.hbuttonbox.pack_start(self.volume_button) self.sltv.vus = [] meter = fvumeter.FVUMeter() meter.only_draw_peak = True self.sltv.vus.append(meter) meter = fvumeter.FVUMeter() self.sltv.vus.append(meter) self.sltv.vus[0].show() self.sltv.vus[1].show() self.vumeter_box = self.interface.get_object("vumeter_box") if self.vumeter_box: self.vumeter_box.add(self.sltv.vus[0]) self.vumeter_box.add(self.sltv.vus[1]) # pip pip_box = self.interface.get_object("pip_box") self.pip_selector = pip_widget.PIPSelector() self.pip_selector.connect("changed", self.on_pip_changed) pip_box.add(self.pip_selector) pip_box.show_all() # sources self.sources = self.sltv.sources self.audioconvs = self.sltv.audioconvs self.sources_ui = sources.Sources(self, self.sources, self.audioconvs) self.video_source_box = self.interface.get_object("video_source_box") self.sources_view = sources_view.SourcesView(self.sltv, self.sources) self.sources_view.show_all() self.video_source_box.pack_start(self.sources_view, False, False) # audio combobox self.audio_sources_combobox = self.interface.get_object( "audio_sources_combobox") self.audio_sources_combobox.set_model( sources.AudioModel(self.sources).model) cell = gtk.CellRendererText() self.audio_sources_combobox.pack_start(cell, True) self.audio_sources_combobox.add_attribute(cell, "text", 0) self.audio_sources_combobox.connect("changed", self.on_select_audio_source) self.audio_sources_combobox.set_active(0) # outputs self.outputs = self.sltv.outputs self.outputs_ui = outputs.Outputs(self, self.outputs, self.encoders) self.outputs_box = self.interface.get_object("outputs_box") self.outputs_view = outputs_view.OutputsView(self.sltv, self.outputs) self.outputs_view.show_all() self.outputs_box.pack_start(self.outputs_view, False, False) # settings dialog self.settings_dialog.set_has_separator(False) self.settings_dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) self.settings_dialog.connect('delete-event', self.hide_settings) self.settings_dialog.connect('response', self.hide_settings) vbox = self.settings_dialog.get_content_area() vbox.set_border_width(12) notebook = gtk.Notebook() self.settings_notebook = notebook vbox.add(notebook) vbox = gtk.VBox() vbox.set_border_width(12) vbox.pack_start(self.sources_ui.get_widget()) notebook.append_page(vbox, gtk.Label('Sources')) vbox = gtk.VBox() vbox.set_border_width(12) vbox.pack_start(self.encoders_ui.get_widget()) notebook.append_page(vbox, gtk.Label('Encoders')) vbox = gtk.VBox() vbox.set_border_width(12) vbox.pack_start(self.outputs_ui.get_widget()) notebook.append_page(vbox, gtk.Label('Outputs')) vbox = gtk.VBox() vbox.set_border_width(12) vbox.pack_start(self.metadata_ui.get_widget()) notebook.append_page(vbox, gtk.Label('Metadata')) #menu self.settings_menuitem = self.interface.get_object("settings_menuitem") self.quit_menuitem = self.interface.get_object("quit_menuitem") self.about_menu = self.interface.get_object("about_menu") self.play_button.connect("clicked", self.on_play_press) self.stop_button.connect("clicked", self.on_stop_press) self.main_window.connect("delete_event", self.on_window_closed) self.settings_menuitem.connect("activate", self.show_settings) self.quit_menuitem.connect("activate", gtk.main_quit) self.about_menu.connect("activate", self.show_about)