command.hpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Preprocessor
00011 *****************************************************************************/
00012 
00013 #ifndef KOBUKI_COMMAND_DATA_HPP__
00014 #define KOBUKI_COMMAND_DATA_HPP__
00015 
00016 /*****************************************************************************
00017 ** Includes
00018 *****************************************************************************/
00019 
00020 #include <ecl/containers.hpp>
00021 #include "packet_handler/payload_base.hpp"
00022 #include "modules/led_array.hpp"
00023 #include "modules.hpp"
00024 #include "macros.hpp"
00025 
00026 /*****************************************************************************
00027 ** Namespace
00028 *****************************************************************************/
00029 
00030 
00031 namespace kobuki
00032 {
00033 
00034 class kobuki_PUBLIC Command : public packet_handler::payloadBase
00035 {
00036 public:
00037   typedef ecl::PushAndPop<unsigned char> Buffer;
00038   typedef ecl::Stencil< Buffer > BufferStencil;
00039 
00043   enum Name
00044   {
00045     BaseControl = 1, Sound = 3, SoundSequence = 4, RequestExtra = 9, ChangeFrame = 10, RequestEeprom = 11,
00046     SetDigitalOut = 12, SetController = 13, GetController = 14
00047   };
00048 
00049   enum VersionFlag
00050   {
00051     HardwareVersion = 0x01, FirmwareVersion = 0x02/*, Time = 0x04*/, UniqueDeviceID = 0x08
00052   };
00053 
00066   struct Data
00067   {
00068     Data()
00069       : command(BaseControl), speed(0), radius(0), request_flags(0), gp_out(0x00f0) // set all the power pins high, others low.
00070       , type(0), p_gain(1000), i_gain(1000), d_gain(1000)
00071     {
00072     }
00073 
00074     Name command;
00075 
00076     // BaseControl
00077     int16_t speed;
00078     int16_t radius;
00079 
00080     // Sound - not yet implemented
00081     uint16_t note;
00082     unsigned char duration;
00083 
00084     // SoundSequence
00085     // 0 - turning on, 1 - turn off, 2 - recharge start, 3 - press button,
00086     // 4 - error sound, 5 - start cleaning, 6 - cleaning end
00087     unsigned char segment_name;
00088 
00089     // RequestExtra (version flags)
00090     uint16_t request_flags;
00091 
00092     // ChangeFrame & RequestEeprom
00093     unsigned char frame_id;
00094 
00095     // SetDigitalOut
00096     // 0x000f - digital output pins 0-3 (0x0001, 0x0002, 0x0004, 0x0008)
00097     // 0x00f0 - external power breakers (3.3V, 5V, 12V 12V1A) (0x0010, 0x0020, 0x0040, 0x0080)
00098     // 0x0f00 - led array (red1, green1, red2, green2) ( 0x0100, 0x0200, 0x0400, 0x0800)
00099     uint16_t gp_out;
00100 
00101     // SetControllerGain
00102     unsigned char type;
00103     unsigned int p_gain;
00104     unsigned int i_gain;
00105     unsigned int d_gain;
00106 
00107     // SetControllerGain
00108     unsigned char reserved;
00109   };
00110 
00111   virtual ~Command() {}
00112 
00113   static Command SetLedArray(const enum LedNumber &number, const enum LedColour &colour, Command::Data &current_data);
00114   static Command SetDigitalOutput(const DigitalOutput &digital_output, Command::Data &current_data);
00115   static Command SetExternalPower(const DigitalOutput &digital_output, Command::Data &current_data);
00116   static Command PlaySoundSequence(const enum SoundSequences &number, Command::Data &current_data);
00117   static Command GetVersionInfo();
00118   static Command SetVelocityControl(DiffDrive& diff_drive);
00119   static Command SetVelocityControl(const int16_t &speed, const int16_t &radius);
00120   static Command SetControllerGain(const unsigned char &type,
00121                                    const unsigned int &p_gain,
00122                                    const unsigned int &i_gain,
00123                                    const unsigned int &d_gain);
00124   static Command GetControllerGain();
00125 
00126   Data data;
00127 
00128   void resetBuffer(Buffer &buffer);
00129   bool serialise(ecl::PushAndPop<unsigned char> & byteStream);
00130   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream) { return true; } 
00132 private:
00133   static const unsigned char header0;
00134   static const unsigned char header1;
00135 
00136 };
00137 
00138 } // namespace kobuki
00139 
00140 #endif /* KOBUKI_COMMAND_DATA_HPP__ */
00141 


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