#nedeni ise bu modulun her kutuphanede çalışması,çok daha gelişmiş bir esneklik sağlaması ve özelliklerinin olması
#wxPyhton bazı hatalar için düzeltmeler içeriyor ve ayrıca wxWidgets'tan çeşitli iyileştirmeler ekliyor
import atexit  #Atexit modülü, temizleme işlevlerini kaydetmek için tek bir işlev tanımlar.
#hata tespiti için bir arabirimdir.
atexit.register(
    gopigo.stop
)  # aktarılacak tüm isteğe bağlı argümanlar, register() için bağımsız değişken olarak aktarılmalıdır.

left_led = 0
right_led = 0
trim_val = gopigo.trim_read()  #trim=düzeltmek
#işlevi, yeni satırları, boşlukları (kırılmayan alanlar da dahil) ve sağlanan dizenin başlangıcından
#ve sonundan itibaren sekmeleri kaldırır. Bu boşluk karakterleri dizedeki ortada oluşursa, bunlar korunur.
v = gopigo.volt()
#GoPiGo'ya V'de bağlı olan pil takımının voltajını okuyun
f = gopigo.fw_ver()
#GoPiGo'nun ürün yazılımı sürümünü okuyun.
#0,9'olabilir.
#1.0, en yeni bellenimdir
slider_val = gopigo.trim_read()


#slider, kullanıcının göstergeyi hareket ettirerek değer ayarlayabileceği bir Tkinter nesnesidir.
#trim fonksiyonu barkodlardaki yazılımlar sayesinde tekerleklerden birinin hızını bir miktar arttırabilir veya azaltabilir, böylece çok fazla dönüş yapmaz
class gopigo_control_app(
        wx.Frame
):  #Çerçeve, boyutu ve konumu kullanıcı tarafından değiştirilebilen (genellikle) bir pencere.
    slider = 0

    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(475, 600))
 def firmware_button_OnButtonClick(self, event):
     global f
     f = gopigo.fw_ver()
     self.firmware_label.SetLabel(str(f))
Пример #3
0
    no_auto_detect = True

import gopigo
try:
    import wx
except ImportError:
    raise ImportError,"The wxPython module is required to run this program"

import atexit
atexit.register(gopigo.stop)    

left_led=0
right_led=0
trim_val=gopigo.trim_read()
v=gopigo.volt()
f=gopigo.fw_ver()
slider_val=gopigo.trim_read()

class gopigo_control_app(wx.Frame):
    slider=0
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title,size=(475,600))
        self.parent = parent
        self.initialize()
        # Exit
        exit_button = wx.Button(self, label="Exit", pos=(240+75,550))
        exit_button.Bind(wx.EVT_BUTTON, self.onClose)
        
        # robot = "/home/pi/Desktop/GoBox/Troubleshooting_GUI/dex.png"
        # png = wx.Image(robot, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        # wx.StaticBitmap(self, -1, png, (0, 0), (png.GetWidth()-320, png.GetHeight()-20))
Пример #4
0
 def firmware_button_OnButtonClick(self,event):
     global f
     f=gopigo.fw_ver()
     self.firmware_label.SetLabel(str(f))
Пример #5
0
def do_command(command=None):
    logging.debug(command)
    if command in ["forward", "fwd"]:
        gopigo.fwd()
    elif command == "left":
        gopigo.left()
    elif command == "left_rot":
        gopigo.left_rot()
    elif command == "right":
        gopigo.right()
    elif command == "right_rot":
        gopigo.right_rot()
    elif command == "stop":
        gopigo.stop()
    elif command == "leftled_on":
        gopigo.led_on(0)
    elif command == "leftled_off":
        gopigo.led_off(0)
    elif command == "rightled_on":
        gopigo.led_on(1)
    elif command == "rightled_off":
        gopigo.led_off(1)
    elif command in ["back", "bwd"]:
        gopigo.bwd()
    elif command == "speed":
        logging.debug("speed")
        speed = flask.request.args.get("speed")
        logging.debug("speed:" + str(speed))
        if speed:
            logging.debug("in if speed")
            gopigo.set_speed(int(speed))
        left_speed = flask.request.args.get("left_speed")
        logging.debug("left_speed:" + str(left_speed))
        if left_speed:
            logging.debug("in if left_speed")
            gopigo.set_left_speed(int(left_speed))
        right_speed = flask.request.args.get("right_speed")
        logging.debug("right_speed:" + str(right_speed))
        if right_speed:
            logging.debug("in if right_speed")
            gopigo.set_right_speed(int(right_speed))
        speed_result = gopigo.read_motor_speed()
        logging.debug(speed_result)
        return flask.json.jsonify({"speed": speed_result, "right": speed_result[0], "left": speed_result[1]})
    elif command == "get_data":
        speed_result = gopigo.read_motor_speed()
        enc_right = gopigo.enc_read(0)
        enc_left = gopigo.enc_read(1)
        volt = gopigo.volt()
        timeout = gopigo.read_timeout_status()
        return flask.json.jsonify(
            {
                "speed": speed_result,
                "speed_right": speed_result[0],
                "speed_left": speed_result[1],
                "enc_right": enc_right,
                "enc_left": enc_left,
                "volt": volt,
                "timeout": timeout,
                "fw_ver": gopigo.fw_ver(),
            }
        )
    elif command in ["enc_tgt", "step"]:
        tgt = flask.request.args.get("tgt")
        direction = flask.request.args.get("dir")
        if tgt:
            gopigo.gopigo.enc_tgt(1, 1, int(tgt))
            if dir:
                if dir == "bwd":
                    gopigo.bwd()
                else:
                    gopigo.fwd()
            else:
                gopigo.fwd()
    return ""
Пример #6
0
    def process_command(self, command):
        parts = command.split("/")

        if parts[1] == "poll":
            print "poll"
            self.us_dist = gopigo.us_dist(usdist_pin)
            self.enc_status = gopigo.read_status()[0]
            self.volt = gopigo.volt()
            self.fw_ver = gopigo.fw_ver()
            self.trim = gopigo.trim_read() - 100

            if self.enc_status == 0:
                self.waitingOn = None
        elif parts[1] == "stop":
            gopigo.stop()
        elif parts[1] == "trim_write":
            gopigo.trim_write(int(parts[2]))
            self.trim = gopigo.trim_read()
        elif parts[1] == "trim_read":
            self.trim = gopigo.trim_read() - 100
        elif parts[1] == "set_speed":
            if parts[2] == "left":
                self.left_speed = int(parts[3])
            elif parts[2] == "right":
                self.right_speed = int(parts[3])
            else:
                self.right_speed = int(parts[3])
                self.left_speed = int(parts[3])
            gopigo.set_left_speed(self.left_speed)
            gopigo.set_right_speed(self.right_speed)
        elif parts[1] == "leds":
            val = 0
            if parts[3] == "on":
                val = 1
            elif parts[3] == "off":
                val = 0
            elif parts[3] == "toggle":
                val = -1

            if parts[2] == "right" or parts[2] == "both":
                if val >= 0:
                    self.ledr = val
                else:
                    self.ledr = 1 - self.ledr

            if parts[2] == "left" or parts[2] == "both":
                if val >= 0:
                    self.ledl = val
                else:
                    self.ledl = 1 - self.ledl

            gopigo.digitalWrite(ledr_pin, self.ledr)
            gopigo.digitalWrite(ledl_pin, self.ledl)
        elif parts[1] == "servo":
            gopigo.servo(int(parts[2]))
        elif parts[1] == "turn":
            self.waitingOn = parts[2]
            direction = parts[3]
            amount = int(parts[4])
            encleft = 0 if direction == "left" else 1
            encright = 1 if direction == "left" else 0
            gopigo.enable_encoders()
            gopigo.enc_tgt(encleft, encright, int(amount / DPR))
            if direction == "left":
                gopigo.left()
            else:
                gopigo.right()
        elif parts[1] == "move":
            self.waitingOn = int(parts[2])
            direction = parts[3]
            amount = int(parts[4])
            gopigo.enable_encoders()
            gopigo.enc_tgt(1, 1, amount)
            if direction == "backward":
                gopigo.bwd()
            else:
                gopigo.fwd()
        elif parts[1] == "beep":
            gopigo.analogWrite(buzzer_pin, self.beep_volume)
            time.sleep(self.beep_time)
            gopigo.analogWrite(buzzer_pin, 0)
        elif parts[1] == "reset_all":
            self.ledl = 0
            self.ledr = 0

            gopigo.digitalWrite(ledl_pin, self.ledl)
            gopigo.digitalWrite(ledr_pin, self.ledr)
            gopigo.analogWrite(buzzer_pin, 0)
#           gopigo.servo(90)
            gopigo.stop()
Пример #7
0
#!/usr/bin/env python
##################################################
# GoPiGo IR remote control test
#
# This example is for controlling the GoPiGo with an IR remote similar to the one with AC and TV's 
# 
# History
# ------------------------------------------------
# Author	Date      		Comments
# Karan		1 June 15	  	Initial Authoring
#
# These files have been made available online through a Creative Commons Attribution-ShareAlike 3.0  license.
# (http://creativecommons.org/licenses/by-sa/3.0/)      
##################################################

import gopigo
import time

print gopigo.fw_ver()

gopigo.ir_recv_pin(15)
print "Press any button on the remote to see the data"
while True:
	ir_data_back=gopigo.ir_read_signal()
	if ir_data_back[0]==-1:		#IO Error
		pass
	elif ir_data_back[0]==0:	#Old signal
		pass
	else:
		print ir_data_back[1:]		#Current signal from IR remote
	time.sleep(.1)
Пример #8
0
#!/usr/bin/env python
##################################################
# GoPiGo IR remote control test
#
# This example is for controlling the GoPiGo with an IR remote similar to the one with AC and TV's
#
# History
# ------------------------------------------------
# Author	Date      		Comments
# Karan		1 June 15	  	Initial Authoring
#
# These files have been made available online through a Creative Commons Attribution-ShareAlike 3.0  license.
# (http://creativecommons.org/licenses/by-sa/3.0/)
##################################################

import gopigo
import time

print gopigo.fw_ver()

gopigo.ir_recv_pin(15)
print "Press any button on the remote to see the data"
while True:
    ir_data_back = gopigo.ir_read_signal()
    if ir_data_back[0] == -1:  #IO Error
        pass
    elif ir_data_back[0] == 0:  #Old signal
        pass
    else:
        print ir_data_back[1:]  #Current signal from IR remote
    time.sleep(.1)
Пример #9
0
def fw_ver(kargs):
    r = {'return_value': gopigo.fw_ver()}
    return r