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 
00025 /*****************************************************************************
00026 ** Namespace
00027 *****************************************************************************/
00028 
00029 
00030 namespace kobuki
00031 {
00032 
00033 class Command : public packet_handler::payloadBase
00034 {
00035 public:
00036   typedef ecl::PushAndPop<unsigned char> Buffer;
00037   typedef ecl::Stencil< Buffer > BufferStencil;
00038 
00042   enum Name
00043   {
00044     BaseControl = 1, Sound = 3, SoundSequence = 4, RequestExtra = 9, ChangeFrame = 10, RequestEeprom = 11,
00045     SetDigitalOut = 12
00046   };
00047 
00048   enum VersionFlag
00049   {
00050     HardwareVersion = 0x01, FirmwareVersion = 0x02/*, Time = 0x04*/, UniqueDeviceID = 0x08
00051   };
00052 
00065   struct Data
00066   {
00067     Data() :
00068         command(BaseControl), speed(0), radius(0), request_flags(0), gp_out(0x00f0) // set all the power pins high, others low.
00069     {
00070     }
00071 
00072     Name command;
00073 
00074     // BaseControl
00075     int16_t speed;
00076     int16_t radius;
00077 
00078     // Sound - not yet implemented
00079     uint16_t note;
00080     unsigned char duration;
00081 
00082     // SoundSequence
00083     // 0 - turning on, 1 - turn off, 2 - recharge start, 3 - press button,
00084     // 4 - error sound, 5 - start cleaning, 6 - cleaning end
00085     unsigned char segment_name;
00086 
00087     // RequestExtra (version flags)
00088     uint16_t request_flags;
00089 
00090     // ChangeFrame & RequestEeprom
00091     unsigned char frame_id;
00092 
00093     // SetDigitalOut
00094     // 0x000f - digital output pins 0-3 (0x0001, 0x0002, 0x0004, 0x0008)
00095     // 0x00f0 - external power breakers (3.3V, 5V, 12V 12V1A) (0x0010, 0x0020, 0x0040, 0x0080)
00096     // 0x0f00 - led array (red1, green1, red2, green2) ( 0x0100, 0x0200, 0x0400, 0x0800)
00097     uint16_t gp_out;
00098   };
00099 
00100   virtual ~Command() {}
00101 
00102   static Command SetLedArray(const enum LedNumber &number, const enum LedColour &colour, Command::Data &current_data);
00103   static Command SetDigitalOutput(const DigitalOutput &digital_output, Command::Data &current_data);
00104   static Command SetExternalPower(const DigitalOutput &digital_output, Command::Data &current_data);
00105   static Command PlaySoundSequence(const enum SoundSequences &number, Command::Data &current_data);
00106   static Command GetVersionInfo();
00107   static Command SetVelocityControl(DiffDrive& diff_drive);
00108   static Command SetVelocityControl(const int16_t &speed, const int16_t &radius);
00109 
00110   Data data;
00111 
00112   void resetBuffer(Buffer &buffer);
00113   bool serialise(ecl::PushAndPop<unsigned char> & byteStream);
00114   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream) { return true; } 
00116 private:
00117   static const unsigned char header0;
00118   static const unsigned char header1;
00119 
00120 };
00121 
00122 } // namespace kobuki
00123 
00124 #endif /* KOBUKI_COMMAND_DATA_HPP__ */
00125 


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