Ignore:
Timestamp:
12/31/13 02:09:58 (8 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, Servo
Children:
b094d6c
Parents:
395ea1a
Message:
  • Tilt Sensor fine tuning include fllter for sudden changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit/controllers/AdvancedViewController.m

    r395ea1a r67d9807  
    3434    
    3535   self.motionManager = [[CMMotionManager alloc] init]; 
    36    //   self.motionManager.accelerometerUpdateInterval = .2; 
    37    //   self.motionManager.gyroUpdateInterval = .2; 
    38    self.motionManager.accelerometerUpdateInterval = .1; 
    39    self.motionManager.gyroUpdateInterval = .1; 
     36   self.motionManager.accelerometerUpdateInterval = .2; 
     37   self.motionManager.gyroUpdateInterval = .2; 
     38   //   self.motionManager.accelerometerUpdateInterval = .1; 
     39   //   self.motionManager.gyroUpdateInterval = .1; 
    4040    
    4141   [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue] 
     
    9191- (void) adjustValues 
    9292{ 
     93   NSLog(@"DEBUG: yaw:%f pitch:%f", yaw.value, pitch.value); 
    9394   [signalConverter setYaw:[self yawValue]throttle:[self throttleValue] pitch:[self pitchValue]]; 
    9495} 
     
    115116 
    116117- (IBAction) forwardButtonPressed:(id)sender { 
    117    pitch.value = 0.8; 
    118    yaw.value = 0.5; 
    119    throttle.value = 0.5; 
     118   throttle.value = defaultControlThrottle; 
     119   pitch.value = defaultControlPitch + 0.2; 
     120   yaw.value = defaultControlYaw; 
    120121   [self adjustValues]; 
    121122    
     
    123124 
    124125- (IBAction) leftButtonPressed:(id)sender { 
    125    pitch.value = 0.5; 
    126    yaw.value = 0.1; 
    127    throttle.value = 0.5; 
     126   throttle.value = defaultControlThrottle; 
     127   pitch.value = defaultControlPitch; 
     128   yaw.value = defaultControlYaw - 0.3; 
    128129   [self adjustValues]; 
    129130    
     
    131132 
    132133- (IBAction) rightButtonPressed:(id)sender { 
    133    pitch.value = 0.5; 
    134    yaw.value = 0.9; 
    135    throttle.value = 0.5; 
     134   throttle.value = defaultControlThrottle; 
     135   pitch.value = defaultControlPitch; 
     136   yaw.value = defaultControlYaw + 0.3; 
    136137   [self adjustValues]; 
    137138    
     
    160161   if([sender isOn]){ 
    161162      NSLog(@"DEBUG: Throttle Tilt Sensor Enabled"); 
     163      referenceTiltY = 0; 
    162164   } else{ 
    163165      NSLog(@"DEBUG: Throttle Tilt Sensor Disabled"); 
     
    202204         //   NSLog(@"DEBUG: newYaw:%f newPitch:%f", newYaw, newPitch); 
    203205          
    204          yaw.value = newYaw; 
    205          pitch.value = newPitch; 
     206         // Filter changes below titleSensorMinimumThreshold 
     207         if (((newYaw > yaw.value) && (newYaw - yaw.value > titleSensorMinimumThreshold)) || 
     208             ((newYaw < yaw.value) && (yaw.value - newYaw > titleSensorMinimumThreshold))) { 
     209            yaw.value = newYaw; 
     210         } 
     211          
     212         if (((newPitch > pitch.value) && (newPitch - pitch.value > titleSensorMinimumThreshold)) || 
     213             ((newPitch < pitch.value) && (pitch.value - newPitch > titleSensorMinimumThreshold))) { 
     214            pitch.value = newPitch; 
     215         } 
    206216          
    207217      } // Pitch/Yaw Tilt Control 
     
    211221         // Throttle Tilt Control 
    212222          
    213          double tiltY = acceleration.y * -1;  // invert the Y axis so that negative values equal forward 
     223         double tiltY = acceleration.y * 1;  // invert the Y axis so that negative values equal forward 
    214224          
    215225         if (referenceTiltY == 0) { 
     
    217227         } 
    218228          
    219          throttle.value = defaultControlThrottle - (tiltY - referenceTiltY); 
     229         double newThrottle = defaultControlThrottle - (tiltY - referenceTiltY); 
     230          
     231         if (((newThrottle > throttle.value) && (newThrottle - throttle.value > titleSensorMinimumThreshold)) || 
     232             ((newThrottle < throttle.value) && (throttle.value - newThrottle > titleSensorMinimumThreshold))) { 
     233            throttle.value = newThrottle; 
     234         } 
    220235          
    221236      } // Throttle Tilt Control 
    222237       
    223  
     238       
    224239      [self adjustValues]; 
    225240       
Note: See TracChangeset for help on using the changeset viewer.