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   if (!(byteStream.size() > 0))
00030   {
00031     //ROS_WARN_STREAM("kobuki_node: kobuki_default: serialise failed. empty byte stream.");
00032     return false;
00033   }
00034   unsigned char length = 15;
00035   buildBytes(Header::CoreSensors, byteStream);
00036   buildBytes(length, byteStream);
00037   buildBytes(data.time_stamp, byteStream);      //2
00038   buildBytes(data.bumper, byteStream);          //1
00039   buildBytes(data.wheel_drop, byteStream);      //1
00040   buildBytes(data.cliff, byteStream);           //1
00041   buildBytes(data.left_encoder, byteStream);    //2
00042   buildBytes(data.right_encoder, byteStream);   //2
00043   buildBytes(data.left_pwm, byteStream);        //1
00044   buildBytes(data.right_pwm, byteStream);       //1
00045   buildBytes(data.buttons, byteStream);         //1
00046   buildBytes(data.charger, byteStream);         //1
00047   buildBytes(data.battery, byteStream);         //1
00048   buildBytes(data.over_current, byteStream);    //1
00049 
00050   return true;
00051 }
00052 bool CoreSensors::deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00053 {
00054   if (!(byteStream.size() > 0))
00055   {
00056     //ROS_WARN_STREAM("kobuki_node: kobuki_default: deserialise failed. empty byte stream.");
00057     return false;
00058   }
00059 
00060   unsigned char header_id, length;
00061   buildVariable(header_id, byteStream);
00062   buildVariable(length, byteStream);
00063   buildVariable(data.time_stamp, byteStream);
00064   buildVariable(data.bumper, byteStream);
00065   buildVariable(data.wheel_drop, byteStream);
00066   buildVariable(data.cliff, byteStream);
00067   buildVariable(data.left_encoder, byteStream);
00068   buildVariable(data.right_encoder, byteStream);
00069   buildVariable(data.left_pwm, byteStream);
00070   buildVariable(data.right_pwm, byteStream);
00071   buildVariable(data.buttons, byteStream);
00072   buildVariable(data.charger, byteStream);
00073   buildVariable(data.battery, byteStream);
00074   buildVariable(data.over_current, byteStream);
00075 
00076   return true;
00077 }
00078 
00079 
00080 
00081 } // namespace kobuki


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Oct 6 2014 01:31:09