Changeset 2307

Show
Ignore:
Timestamp:
02/26/10 18:41:37 (5 months ago)
Author:
fma
Message:

Misc

Location:
trunk/papywizard/plugins
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/papywizard/plugins/panoduinoPlugins.py

    r2306 r2307  
    7474NAME = "Panoduino" 
    7575 
    76 DEFAULT_SPEED = 30 # deg/s 
     76DEFAULT_SPEED = 64 
    7777DEFAULT_DIRECTION = unicode(QtGui.QApplication.translate("panoduinoPlugins", 'forward')) 
    78 DEFAULT_ANGLE_1MS = 120. # angle for 1ms, which is 2 servo units (deg) 
    7978DEFAULT_NEUTRAL_POSITION = 3000 # controller value for neutral position 
    8079DEFAULT_VALUE_OFF = 0 
     
    9291                   unicode(QtGui.QApplication.translate("panoduinoPlugins", 'reverse')): 'reverse' 
    9392                   } 
    94 MANUAL_SPEED_TABLE = {'slow': .5, 
     93SPEED_TABLE = {'yawAxis': 64, 
     94               'pitchAxis': 64 
     95               } 
     96ANGLE_1MS_TABLE = {'yawAxis': 525.,  # angle (in °) for a 1ms pulse change 
     97                   'pitchAxis': 315. 
     98                   } 
     99MANUAL_SPEED_TABLE = {'slow': .5,  # angle (in °) for each key press 
    95100                      'normal': 2., 
    96101                      'fast': 5. 
     
    112117        self._addConfigKey('_speed', 'SPEED', default=DEFAULT_SPEED) 
    113118        self._addConfigKey('_direction', 'DIRECTION', default=DEFAULT_DIRECTION) 
    114         self._addConfigKey('_angle1ms', 'ANGLE_1MS', default=DEFAULT_ANGLE_1MS) 
    115119        self._addConfigKey('_neutralPos', 'NEUTRAL_POSITION', default=DEFAULT_NEUTRAL_POSITION) 
    116120 
     
    131135        self._hardware.setAxis(AXIS_TABLE[self.capacity]), 
    132136        AbstractHardwarePlugin.init(self) 
    133         #self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION']) 
    134137        self.configure() 
     138        self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION']) 
    135139        self.__position = 0. 
    136140        self.__endDrive = 0 
     
    147151        AbstractAxisPlugin.configure(self) 
    148152        speed = self.__computeServoSpeed(self._config['SPEED']) 
    149         Logger().debug("PanoduinoAxis.configure(): speed=%d" % speed) 
    150153        direction = DIRECTION_TABLE[self._config['DIRECTION']] 
    151154        self._hardware.configure(speed, direction) 
    152         self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION']) 
     155        #self._hardware.setNeutral(self._config['NEUTRAL_POSITION']) 
    153156 
    154157    def read(self): 
     
    164167        @rtype: int 
    165168        """ 
    166         servoSpeed = int(speed * 1000 / self._config['ANGLE_1MS'] / 50) 
     169        return speed 
     170 
     171        servoSpeed = int(speed * 1000 / ANGLE_1MS_TABLE[self.capacity] / 50) 
    167172        if servoSpeed < 1: 
    168173            servoSpeed = 1 
     
    182187        direction = DIRECTION_TABLE[self._config['DIRECTION']] 
    183188        dir_ = DIRECTION_INDEX[direction] 
    184         servoPosition = int(self._config['NEUTRAL_POSITION'] + dir_ * position / self._config['ANGLE_1MS'] * 2000) 
     189        servoPosition = int(self._config['NEUTRAL_POSITION'] + dir_ * position / ANGLE_1MS_TABLE[self.capacity] * 2000) 
    185190        return servoPosition 
    186191 
     
    194199        value = self.__computeServoPosition(position) 
    195200        self._hardware.setPositionAbsolute(value) 
    196         self._endDrive = time.time() + 2 * abs(position - self.__position) / self._config['SPEED'] 
     201        self._endDrive = time.time() + abs(position - self.__position) / self._config['SPEED'] 
    197202        if wait: 
    198203            self.waitEndOfDrive() 
    199204        self.__position = position 
     205 
     206        # TODO: use a setpoint, and compute position in read according to timing/speed/... 
     207        # This avoid using a thread 
    200208 
    201209    def waitEndOfDrive(self): 
     
    240248        HardwarePluginController._defineGui(self) 
    241249        self._addWidget('Main', QtGui.QApplication.translate("panoduinoPlugins", "Speed"), 
    242                         SpinBoxField, (1, 99, "", u" °/s"), 'SPEED') 
     250                        SpinBoxField, (0, 127), 'SPEED') 
    243251        self._addTab('Servo', QtGui.QApplication.translate("panoduinoPlugins", 'Servo')) 
    244252        directions = [DIRECTION_TABLE['forward'], DIRECTION_TABLE['reverse']] 
    245253        self._addWidget('Servo', QtGui.QApplication.translate("panoduinoPlugins", "Direction"), 
    246254                        ComboBoxField, (directions,), 'DIRECTION') 
    247         self._addWidget('Servo', QtGui.QApplication.translate("panoduinoPlugins", "Angle for 1ms"), 
    248                         DoubleSpinBoxField, (1., 999., 1, 0.1, "", u" °"), 'ANGLE_1MS') 
    249255        self._addWidget('Servo', QtGui.QApplication.translate("panoduinoPlugins", "Neutral position"), 
    250256                        SpinBoxField, (500, 5500), 'NEUTRAL_POSITION') 
  • trunk/papywizard/plugins/pololuServoPlugins.py

    r2305 r2307  
    133133        AbstractHardwarePlugin.init(self) 
    134134        self.configure() 
     135        self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION']) 
    135136        self.__position = 0. 
    136137        self.__endDrive = 0 
     
    146147        Logger().trace("PololuServoAxis.configure()") 
    147148        AbstractAxisPlugin.configure(self) 
    148         self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION']) 
    149149        speed = self.__computeServoSpeed(self._config['SPEED']) 
    150150        direction = DIRECTION_TABLE[self._config['DIRECTION']]