inertia.hpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Preprocessor
00011 *****************************************************************************/
00012 
00013 #ifndef KOBUKI_INERTIA_DATA_HPP__
00014 #define KOBUKI_INERTIA_DATA_HPP__
00015 
00016 /*****************************************************************************
00017 ** Includes
00018 *****************************************************************************/
00019 
00020 #include "../packet_handler/payload_base.hpp"
00021 #include "../packet_handler/payload_headers.hpp"
00022 
00023 /*****************************************************************************
00024 ** Namespaces
00025 *****************************************************************************/
00026 
00027 namespace kobuki
00028 {
00029 
00030 /*****************************************************************************
00031 ** Interface
00032 *****************************************************************************/
00033 
00034 class Inertia : public packet_handler::payloadBase
00035 {
00036 public:
00037   Inertia() : packet_handler::payloadBase(false, 7) {};
00038   struct Data {
00039     int16_t angle;
00040     int16_t angle_rate;
00041     unsigned char acc[3];
00042   } data;
00043 
00044   virtual ~Inertia() {};
00045 
00046   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00047   {
00048     buildBytes(Header::Inertia, byteStream);
00049     buildBytes(length, byteStream);
00050     buildBytes(data.angle, byteStream);
00051     buildBytes(data.angle_rate, byteStream);
00052     buildBytes(data.acc[0], byteStream);
00053     buildBytes(data.acc[1], byteStream);
00054     buildBytes(data.acc[2], byteStream);
00055     return true;
00056   }
00057 
00058   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00059   {
00060     if (byteStream.size() < length+2)
00061     {
00062       //std::cout << "kobuki_node: kobuki_inertia: deserialise failed. not enough byte stream." << std::endl;
00063       return false;
00064     }
00065 
00066     unsigned char header_id, length_packed;
00067     buildVariable(header_id, byteStream);
00068     buildVariable(length_packed, byteStream);
00069     if( header_id != Header::Inertia ) return false;
00070     if( length_packed != length ) return false;
00071 
00072     buildVariable(data.angle, byteStream);
00073     buildVariable(data.angle_rate, byteStream);
00074     buildVariable(data.acc[0], byteStream);
00075     buildVariable(data.acc[1], byteStream);
00076     buildVariable(data.acc[2], byteStream);
00077 
00078     //showMe();
00079     return constrain();
00080   }
00081 
00082   bool constrain()
00083   {
00084     return true;
00085   }
00086 
00087   void showMe()
00088   {
00089   }
00090 };
00091 
00092 } // namespace kobuki
00093 
00094 #endif /* KOBUKI_INERTIA_DATA_HPP__ */
00095 


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Thu Jun 6 2019 20:24:37