def __init__(self, parent): self._parent = parent self._status = True self.robot = pybot_client.robot() self.pollthread = None self.actualizable = True self._auto_refresh = False self.modulos_conectados = [] self._list_connected_device_module = []
def __init__(self, parent): Plugin.__init__(self) self.tw = parent self.init_gconf() power_manager_off(True) self.butia = pybot_client.robot(auto_connect=False) self.actualSpeed = [600, 600] self.active_butia = 0 self.butia_count = 0 self.pollthread = None self.pollrun = True self.bobot = None self._auto_refresh = False self.use_cc = False self.modsen_a_f = 'x' self.modsen_b_f = 'x' self.modsen_c_f = 'x' self.getCastButia() self.m_d = {} self.match_dict = {} self.battery_value = ERROR self.battery_color = COLOR_NOTPRESENT[:] self.old_battery_color = COLOR_NOTPRESENT[:] self.statics_color = COLOR_NOTPRESENT[:] self.extras_color = COLOR_NOTPRESENT[:] self.old_extras_color = COLOR_NOTPRESENT[:] self.match_list = [] self.modules_changed = [] self.list_connected_device_module = [] self.pollthread = threading.Timer(0, self.pybot_launch) self.pollthread.start() self.can_refresh = True self.regex = re.compile(r"""^ #Start of the string (\D*?) # name, an string without digits, the ? mark says that it's not greedy, to avoid to consume also the "Butia" part, in case it's present (\d*) # index, a group comprised only of digits, posibly absent (?:Butia)? # an ocurrence of the "Butia" string, the first ? mark says that the group hasn't to be returned, the second that the group might or not be present $ # end of the string, this regex must match all of the input """, re.X) # Verbose definition, to include comments global d d['led'] = self.setLed d['light'] = self.getLight d['gray'] = self.getGray d['button'] = self.getButton d['distance'] = self.getDistance d['resistanceB'] = self.getResistance d['voltageB'] = self.getVoltage d['temperature'] = self.getTemperature d['modSenA'] = self.getSenA d['modSenB'] = self.getSenB d['modSenC'] = self.getSenC d['modActA'] = self.setActA d['modActB'] = self.setActB d['modActC'] = self.setActC
def pybot_launch(self): output = commands.getoutput('ps -ax | grep python') if 'pybot_server.py' in output: print 'Pybot is alive!' else: try: print 'creating Pybot server' self.bobot = subprocess.Popen(['python', 'pybot_server.py'], cwd='./pybot') except: print 'ERROR creating Pybot server' # Sure that bobot is running time.sleep(2) self.butia = pybot_client.robot() time.sleep(1)
def butia_ros_server_topics(topic, vel, cmd, a): pub = rospy.Publisher(topic, String) rospy.init_node('butia_ros_server_topics', anonymous=True) r = rospy.Rate(vel) # 10 = 10hz while not rospy.is_shutdown(): robot = pybot_client.robot() if cmd == "get_gray": value = robot.getGray(a) elif cmd == "get_distance": value = robot.getDistance(a) elif cmd == "get_button": value = robot.getButton(a) else: print "Invalid Command: %s" % cmd sys.exit(1) print "Publishing [%s(%s):%s]" % (cmd, a, value) pub.publish("%s" % value) r.sleep()
def butia_ros_server_topics(topic,vel,cmd,a): pub = rospy.Publisher(topic, String) rospy.init_node('butia_ros_server_topics', anonymous=True) r = rospy.Rate(vel) # 10 = 10hz while not rospy.is_shutdown(): robot = pybot_client.robot() if cmd == "get_gray": value = robot.getGray(a) elif cmd == "get_distance": value = robot.getDistance(a) elif cmd == "get_button": value = robot.getButton(a) else: print "Invalid Command: %s"%cmd sys.exit(1) print "Publishing [%s(%s):%s]"%(cmd, a, value) pub.publish("%s"%value) r.sleep()
def prim_change_ipButia(self, ip): ip = ip.strip() if self._validate_ip(ip): self.butia = pybot_client.robot(host=ip) else: raise logoerror(_("ERROR: Invalid IP '%s'") % ip)
def __init__(self, parent): Plugin.__init__(self) self.tw = parent self.butia = pybot_client.robot(auto_connect=True) self.pause = 0
#! /usr/bin/env python # -*- coding: utf-8 -*- from pybot import pybot_client from library import patternsAPI butia = pybot_client.robot() negro = 39000 blanco = 22000 idIzq = "1" idDer = "3" distMinMark = 200 def main(): det = patternsAPI.detection() salida = det.arMultiGetIdsMarker() print salida modulos = butia.getModulesList() print modulos while True: butia.set2MotorSpeed("0", "600", "0", "600") print "pase" print str(idIzq) + " " + str(butia.getGray(idIzq)) print str(idDer) + " " + str(butia.getGray(idDer)) # chequeo a la izquierda if butia.getGray(idIzq) < negro and butia.getGray(idDer) > negro: busco_camino_izquierda()
def __init__(self,parent): Plugin.__init__(self) self.tw = parent self.butia = pybot_client.robot()
def __init__(self, activity, channels): #Se utiliza para contralar que no se ejecute dos veces self._butia_context_id = None gtk.Toolbar.__init__(self) self.activity = activity self._channels = channels self.mode = 'butia' # Set up Sensores Button self.time = RadioToolButton(group=None) # Mantiene la lista de botones (de sensores) # agregados a la ButiaToolbar self.lista_sensores_button = [] self.we_are_logging = False self._log_this_sample = False self._logging_timer = None self._logging_counter = 0 self._image_counter = 0 self._logging_interval = 0 self._channels_logged = [] self._busy = False self._take_screenshot = True # BUTIA Se detectan sensores log.debug('se agrega el boton refrescar') self.refrescar_button = RadioToolButton(group=None) self.refrescar_button.set_named_icon('recargar') self.refrescar_button.connect('clicked', self.update_buttons) self.insert(self.refrescar_button, -1) separator = gtk.SeparatorToolItem() separator.props.draw = True self.insert(separator, -1) self.robot = pybot_client.robot() self.detect_sensors() self.load_buttons() separator = gtk.SeparatorToolItem() separator.props.draw = True self.insert(separator, -1) self._log_value = LOG_TIMER_VALUES[1] self.log_label = gtk.Label(self._log_to_string(self._log_value)) toolitem = gtk.ToolItem() toolitem.add(self.log_label) self.insert(toolitem, -1) self._log_button = ToolButton('timer-10') self._log_button.set_tooltip(_('Select logging interval')) self._log_button.connect('clicked', self._log_selection_cb) self.insert(self._log_button, -1) self._setup_log_palette() # Set up Logging/Stop Logging Button self._record = ToolButton('media-record') self.insert(self._record, -1) self._record.set_tooltip(_('Start Recording')) self._record.connect('clicked', self.record_control_cb) log.debug('***showing all*****') self.show_all() gobject.timeout_add(1000, self.update_buttons)
def handle_get_gray(req): robot = pybot_client.robot() value = robot.getGray(req.a) print "Returning [robot.getGray(%s):%s]" % (req.a, value) return ButiaGetGrayResponse(value)
def handle_set_2_motor_speed(req): robot = pybot_client.robot() robot.set2MotorSpeed(req.a, req.b, req.c, req.d) print "Setting Motor Speed to: %s, %s, %s, %s " % (req.a, req.b, req.c, req.d) return ButiaSet2MotorSpeedResponse()
def handle_get_distance(req): robot = pybot_client.robot() value = robot.getDistance(req.a) print "Returning [robot.getDistance(%s):%s]" % (req.a, value) return ButiaGetDistanceResponse(value)