예제 #1
0
 def settings_changed(self):
     new_values=self.settings.get_parameter_tree(True)
     if hasattr(self, 'setting_values'):
         #Check if LED status was changed
         for pn in [k for k in parse_firmware_config().keys() if 'LED' in k]:
             state=new_values[pn]
             if self.setting_values[pn]!=state:
                 self.cmd(pn[:-4].lower(),[int(state)])
     self.setting_values = new_values
예제 #2
0
 def settings_changed(self):
     new_values=self.settings.get_parameter_tree(True)
     if hasattr(self, 'setting_values'):
         #Check if LED status was changed
         for pn in [k for k in parse_firmware_config().keys() if 'LED' in k]:
             state=new_values[pn]
             if self.setting_values[pn]!=state and hasattr(self,'mc'):
                 self.mc.set_led(pn[:-4],state)
         #Check if PWM status was changed
         if self.setting_values['Motor Mode']=='pwm':
             for pn in [k for k in self.setting_values.keys() if 'PWM' in k]:
                 pwm=new_values[pn]
                 if self.setting_values[pn]!=pwm and hasattr(self,'mc'):
                     self.mc.set_pwm(int(pn[-1]),int(pwm*10))
     self.setting_values = new_values
예제 #3
0
 def connect_action(self):
     if self.setting_values['Connection'] == 'serial port':
         if hasattr(self,'s'):
             self.log('Already open')
             return
         import serial
         self.s=serial.Serial(self.setting_values['Serial port'], timeout=self.setting_values['Timeout'], baudrate=parse_firmware_config()['BAUD'])
         self.log('Connected')
예제 #4
0
 def _get_params_config(self):
     pc =  [
             {'name': 'Microcontroller', 'type': 'group', 'expanded' : True, 'children': [
                 {'name': 'Serial port', 'type': 'str', 'value': '/dev/ttyUSB0'},
                 {'name': 'Connection', 'type': 'list', 'values': ['serial port', 'tcp/ip'], 'value': 'serial port'},
                 {'name': 'Timeout', 'type': 'float', 'value': 0.5, 'suffix': 's'},
                 ]},
             {'name': 'Vehicle', 'type': 'group', 'expanded' : True, 'children': [
                 {'name': 'Default Motor Voltage', 'type': 'int', 'value': 30},
                 {'name': 'Movement Duration', 'type': 'float', 'value': 0.5},
                 ]},
             {'name': 'Camera', 'type': 'group', 'expanded' : True, 'children': [
                 {'name': 'N frames', 'type': 'int', 'value': 100},
                 {'name': 'Width', 'type': 'int', 'value': 320},
                 {'name': 'Height', 'type': 'int', 'value': 240},
                 {'name': 'ISO', 'type': 'int', 'value': 100},
                 {'name': 'Exposure', 'type': 'int', 'value': 10},
                 {'name': 'Delay', 'type': 'int', 'value': 50, 'suffix': 'ms'},
                 ]},
                 
                 ]
     pc[0]['children'].extend([{'name': '{0}'.format(l), 'type': 'bool', 'value': False} for l in [k for k in parse_firmware_config().keys() if 'LED' in k]])
     return pc
예제 #5
0
 def _get_params_config(self):
     pc =  [
             {'name': 'Motor Mode', 'type': 'list', 'values': ['voltage', 'pwm', 'wheels']},
             {'name': 'Microcontroller', 'type': 'group', 'expanded' : True, 'children': [
                 {'name': 'Serial port', 'type': 'str', 'value': '/dev/ttyUSB0'},
                 {'name': 'Connection', 'type': 'list', 'values': ['serial port', 'tcp/ip'], 'value': 'serial port'},
                 {'name': 'Timeout', 'type': 'float', 'value': 0.5, 'suffix': 's'},
                 ]},
             {'name': 'Vehicle Control', 'type': 'group', 'expanded' : True, 'children': [
                 {'name': 'Motor1 voltage', 'type': 'float', 'value': 0.0, 'suffix': '%'},
                 {'name': 'Motor2 voltage', 'type': 'float', 'value': 0.0, 'suffix': '%'},
                 {'name': 'Wheel voltage', 'type': 'float', 'value': 0.0, 'suffix': '%'},
                 {'name': 'Wheels voltage difference', 'type': 'float', 'value': 0.0, 'suffix': '%'},
                 {'name': 'Movement time', 'type': 'float', 'value': 0.0, 'suffix': 's'},
                 ]},
             {'name': 'Camera', 'type': 'group', 'expanded' : True, 'children': [
                 {'name': 'N frames', 'type': 'int', 'value': 100},
                 {'name': 'Width', 'type': 'int', 'value': 320},
                 {'name': 'Height', 'type': 'int', 'value': 240},
                 {'name': 'ISO', 'type': 'int', 'value': 100},
                 {'name': 'Exposure', 'type': 'int', 'value': 10},
                 {'name': 'Delay', 'type': 'int', 'value': 50, 'suffix': 'ms'},
                 ]},
                 
                 ]
     pc[1]['children'].extend([{'name': '{0}'.format(l), 'type': 'bool', 'value': False} for l in [k for k in parse_firmware_config().keys() if 'LED' in k]])
     pwm_channels = ['PWM {0}'.format(pwmc) for pwmc in ['PORTE0', 'PORTE1', 'PORTE2', 'PORTE3']]
     pc[1]['children'].extend([{'name': p, 'type': 'float', 'value': 0.0, 'suffix': '%'} for p in pwm_channels])
     return pc