Changeset 67d9807 in orbit for iOS


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

Legend:

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

    r876e42b r67d9807  
    1313#import <CoreMotion/CoreMotion.h> 
    1414 
    15 double defaultControlYaw = 0.5; 
    16 double defaultControlPitch = 0.5; 
    17 double defaultControlThrottle = 0.5; 
     15//double defaultControlThrottle = 0.5; 
     16//double defaultControlYaw = 0.5; 
     17//double defaultControlPitch = 0.5; 
     18 
     19double defaultControlThrottle = 0.8; 
     20double defaultControlYaw = 0.78; 
     21double defaultControlPitch = 0.31; 
     22 
    1823double referenceTiltX = 0; 
    1924double referenceTiltY = 0; 
     25double titleSensorMinimumThreshold = 0.01; 
    2026 
    2127@interface AdvancedViewController : UIViewController 
  • 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       
  • iOS/Orbit/Orbit/en.lproj/MainStoryboard.storyboard

    r7f21a20 r67d9807  
    8181                                        <nil key="highlightedColor"/> 
    8282                                    </label> 
    83                                     <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" id="mKS-gr-qpn" userLabel="Throttle"> 
     83                                    <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.80000000000000004" minValue="0.25" maxValue="1.25" id="mKS-gr-qpn" userLabel="Throttle"> 
    8484                                        <rect key="frame" x="20" y="16" width="280" height="30"/> 
    8585                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/> 
     
    114114                                        <nil key="highlightedColor"/> 
    115115                                    </label> 
    116                                     <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" id="8k8-7Y-hWH" userLabel="Yaw"> 
    117                                         <rect key="frame" x="20" y="16" width="280" height="30"/> 
     116                                    <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.78000000000000003" minValue="0.25" maxValue="1.25" id="8k8-7Y-hWH" userLabel="Yaw"> 
     117                                        <rect key="frame" x="20" y="20" width="280" height="30"/> 
    118118                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/> 
    119119                                        <connections> 
     
    147147                                        <nil key="highlightedColor"/> 
    148148                                    </label> 
    149                                     <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" id="pE4-wd-89x" userLabel="Throttle"> 
     149                                    <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.31" minValue="0.0" maxValue="0.63" id="pE4-wd-89x" userLabel="Throttle"> 
    150150                                        <rect key="frame" x="20" y="16" width="280" height="30"/> 
    151151                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/> 
Note: See TracChangeset for help on using the changeset viewer.