Changeset 2307
- Timestamp:
- 02/26/10 18:41:37 (5 months ago)
- Location:
- trunk/papywizard/plugins
- Files:
-
- 2 modified
-
panoduinoPlugins.py (modified) (9 diffs)
-
pololuServoPlugins.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/papywizard/plugins/panoduinoPlugins.py
r2306 r2307 74 74 NAME = "Panoduino" 75 75 76 DEFAULT_SPEED = 30 # deg/s76 DEFAULT_SPEED = 64 77 77 DEFAULT_DIRECTION = unicode(QtGui.QApplication.translate("panoduinoPlugins", 'forward')) 78 DEFAULT_ANGLE_1MS = 120. # angle for 1ms, which is 2 servo units (deg)79 78 DEFAULT_NEUTRAL_POSITION = 3000 # controller value for neutral position 80 79 DEFAULT_VALUE_OFF = 0 … … 92 91 unicode(QtGui.QApplication.translate("panoduinoPlugins", 'reverse')): 'reverse' 93 92 } 94 MANUAL_SPEED_TABLE = {'slow': .5, 93 SPEED_TABLE = {'yawAxis': 64, 94 'pitchAxis': 64 95 } 96 ANGLE_1MS_TABLE = {'yawAxis': 525., # angle (in °) for a 1ms pulse change 97 'pitchAxis': 315. 98 } 99 MANUAL_SPEED_TABLE = {'slow': .5, # angle (in °) for each key press 95 100 'normal': 2., 96 101 'fast': 5. … … 112 117 self._addConfigKey('_speed', 'SPEED', default=DEFAULT_SPEED) 113 118 self._addConfigKey('_direction', 'DIRECTION', default=DEFAULT_DIRECTION) 114 self._addConfigKey('_angle1ms', 'ANGLE_1MS', default=DEFAULT_ANGLE_1MS)115 119 self._addConfigKey('_neutralPos', 'NEUTRAL_POSITION', default=DEFAULT_NEUTRAL_POSITION) 116 120 … … 131 135 self._hardware.setAxis(AXIS_TABLE[self.capacity]), 132 136 AbstractHardwarePlugin.init(self) 133 #self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION'])134 137 self.configure() 138 self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION']) 135 139 self.__position = 0. 136 140 self.__endDrive = 0 … … 147 151 AbstractAxisPlugin.configure(self) 148 152 speed = self.__computeServoSpeed(self._config['SPEED']) 149 Logger().debug("PanoduinoAxis.configure(): speed=%d" % speed)150 153 direction = DIRECTION_TABLE[self._config['DIRECTION']] 151 154 self._hardware.configure(speed, direction) 152 self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION'])155 #self._hardware.setNeutral(self._config['NEUTRAL_POSITION']) 153 156 154 157 def read(self): … … 164 167 @rtype: int 165 168 """ 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) 167 172 if servoSpeed < 1: 168 173 servoSpeed = 1 … … 182 187 direction = DIRECTION_TABLE[self._config['DIRECTION']] 183 188 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) 185 190 return servoPosition 186 191 … … 194 199 value = self.__computeServoPosition(position) 195 200 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'] 197 202 if wait: 198 203 self.waitEndOfDrive() 199 204 self.__position = position 205 206 # TODO: use a setpoint, and compute position in read according to timing/speed/... 207 # This avoid using a thread 200 208 201 209 def waitEndOfDrive(self): … … 240 248 HardwarePluginController._defineGui(self) 241 249 self._addWidget('Main', QtGui.QApplication.translate("panoduinoPlugins", "Speed"), 242 SpinBoxField, ( 1, 99, "", u" °/s"), 'SPEED')250 SpinBoxField, (0, 127), 'SPEED') 243 251 self._addTab('Servo', QtGui.QApplication.translate("panoduinoPlugins", 'Servo')) 244 252 directions = [DIRECTION_TABLE['forward'], DIRECTION_TABLE['reverse']] 245 253 self._addWidget('Servo', QtGui.QApplication.translate("panoduinoPlugins", "Direction"), 246 254 ComboBoxField, (directions,), 'DIRECTION') 247 self._addWidget('Servo', QtGui.QApplication.translate("panoduinoPlugins", "Angle for 1ms"),248 DoubleSpinBoxField, (1., 999., 1, 0.1, "", u" °"), 'ANGLE_1MS')249 255 self._addWidget('Servo', QtGui.QApplication.translate("panoduinoPlugins", "Neutral position"), 250 256 SpinBoxField, (500, 5500), 'NEUTRAL_POSITION') -
trunk/papywizard/plugins/pololuServoPlugins.py
r2305 r2307 133 133 AbstractHardwarePlugin.init(self) 134 134 self.configure() 135 self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION']) 135 136 self.__position = 0. 136 137 self.__endDrive = 0 … … 146 147 Logger().trace("PololuServoAxis.configure()") 147 148 AbstractAxisPlugin.configure(self) 148 self._hardware.setPositionAbsolute(self._config['NEUTRAL_POSITION'])149 149 speed = self.__computeServoSpeed(self._config['SPEED']) 150 150 direction = DIRECTION_TABLE[self._config['DIRECTION']]
