Clara Keng / Mbed 2 deprecated FreeFlyerROS_clarakhl

Dependencies:   mbed ros_lib_kinetic

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers utilities.cpp Source File

utilities.cpp

00001 
00002 #include "utilities.h"
00003 #include "mbed.h"
00004 
00005 namespace utils {
00006     
00007     float smooth(float data, float filterVal, float smoothedVal) {
00008     
00009         if (filterVal > 1) {      // check to make sure param's are within range
00010             filterVal = .99;
00011         }  else if (filterVal <= 0) {
00012             filterVal = 0;
00013         }
00014         
00015         smoothedVal = (data * (1 - filterVal)) + (smoothedVal  *  filterVal);
00016         
00017         return (float)smoothedVal;
00018     }
00019     
00020     float min(float a, float b) {
00021         if (a < b)
00022             return a;
00023         else
00024             return b;
00025     }
00026     
00027     void printBits(char myByte, Serial &pc) {
00028         for (char mask = 0x80; mask; mask >>= 1) {
00029             if(mask  & myByte)
00030                 pc.putc('1');
00031             else
00032                 pc.putc('0');
00033         }
00034     }
00035 
00036 } // end utils namespace