core_sensors.cpp
Go to the documentation of this file.
00001 
00010 /*****************************************************************************
00011 ** Includes
00012 *****************************************************************************/
00013 
00014 #include "../../include/kobuki_driver/packets/core_sensors.hpp"
00015 #include "../../include/kobuki_driver/packet_handler/payload_headers.hpp"
00016 
00017 /*****************************************************************************
00018 ** Namespaces
00019 *****************************************************************************/
00020 
00021 namespace kobuki {
00022 
00023 /*****************************************************************************
00024 ** Implementation
00025 *****************************************************************************/
00026 
00027 bool CoreSensors::serialise(ecl::PushAndPop<unsigned char> & byteStream)
00028 {
00029   buildBytes(Header::CoreSensors, byteStream);
00030   buildBytes(length, byteStream);
00031   buildBytes(data.time_stamp, byteStream);      //2
00032   buildBytes(data.bumper, byteStream);          //1
00033   buildBytes(data.wheel_drop, byteStream);      //1
00034   buildBytes(data.cliff, byteStream);           //1
00035   buildBytes(data.left_encoder, byteStream);    //2
00036   buildBytes(data.right_encoder, byteStream);   //2
00037   buildBytes(data.left_pwm, byteStream);        //1
00038   buildBytes(data.right_pwm, byteStream);       //1
00039   buildBytes(data.buttons, byteStream);         //1
00040   buildBytes(data.charger, byteStream);         //1
00041   buildBytes(data.battery, byteStream);         //1
00042   buildBytes(data.over_current, byteStream);    //1
00043 
00044   return true;
00045 }
00046 bool CoreSensors::deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00047 {
00048   if (byteStream.size() < length+2)
00049   {
00050     //std::cout << "kobuki_node: kobuki_default: deserialise failed. not enough byte stream." << std::endl;
00051     return false;
00052   }
00053 
00054   unsigned char header_id, length_packed;
00055   buildVariable(header_id, byteStream);
00056   buildVariable(length_packed, byteStream);
00057   if( header_id != Header::CoreSensors ) return false;
00058   if( length_packed != length ) return false;
00059 
00060   buildVariable(data.time_stamp, byteStream);
00061   buildVariable(data.bumper, byteStream);
00062   buildVariable(data.wheel_drop, byteStream);
00063   buildVariable(data.cliff, byteStream);
00064   buildVariable(data.left_encoder, byteStream);
00065   buildVariable(data.right_encoder, byteStream);
00066   buildVariable(data.left_pwm, byteStream);
00067   buildVariable(data.right_pwm, byteStream);
00068   buildVariable(data.buttons, byteStream);
00069   buildVariable(data.charger, byteStream);
00070   buildVariable(data.battery, byteStream);
00071   buildVariable(data.over_current, byteStream);
00072 
00073   return true;
00074 }
00075 
00076 
00077 
00078 } // namespace kobuki


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Thu Aug 27 2015 13:43:57