Advertisement
uas_arduino

G Sensor Processor

Oct 25th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.80 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4.  
  5. my $filename = shift || die("Usage: $0 <input file>");
  6.  
  7. open(IN, "<", $filename) or die ($!);
  8. my @samples = <IN>;
  9. close(IN);
  10. shift @samples;
  11.  
  12. my $last = 0.0;
  13. my $currentSample = 0;
  14. foreach (@samples){
  15.         chomp;
  16.         /^.*?([\d\.]+)[\s\t]+([\d\.]+)/;
  17.         my $g = $1;
  18.         my $t = ".$2";
  19.         my $ms = (($g - 1) * 9.8);
  20.         my $tdelta = $t - $last;
  21.         print "Current Sample: ".($currentSample++)." ";
  22.         print "";
  23.         print "\n\tG: $g";
  24.         print "\n\tT: $t";
  25.         print "\n\tM/s/s: $ms";
  26.         print "\n\tDelta: $tdelta";
  27.         print "\n\tLast: $last";
  28.         printf("\n\tDistance (meters): %0.4f", 0.5 * $ms * $tdelta);
  29.         print "\n";
  30.         $last = $t;
  31. }
  32.  
  33. #print 0.5 * ($g - 1) * $t * 10;
  34. #print "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement