Go to the documentation of this file.00001
00009
00010
00011
00012
00013 #ifndef KOBUKI_COMMAND_DATA_HPP__
00014 #define KOBUKI_COMMAND_DATA_HPP__
00015
00016
00017
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
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, UniqueDeviceID = 0x08
00052 };
00053
00066 struct Data
00067 {
00068 Data()
00069 : command(BaseControl), speed(0), radius(0), request_flags(0), gp_out(0x00f0)
00070 , type(0), p_gain(1000), i_gain(1000), d_gain(1000)
00071 {
00072 }
00073
00074 Name command;
00075
00076
00077 int16_t speed;
00078 int16_t radius;
00079
00080
00081 uint16_t note;
00082 unsigned char duration;
00083
00084
00085
00086
00087 unsigned char segment_name;
00088
00089
00090 uint16_t request_flags;
00091
00092
00093 unsigned char frame_id;
00094
00095
00096
00097
00098
00099 uint16_t gp_out;
00100
00101
00102 unsigned char type;
00103 unsigned int p_gain;
00104 unsigned int i_gain;
00105 unsigned int d_gain;
00106
00107
00108 unsigned char reserved;
00109 };
00110
00111 virtual ~Command() {}
00112
00113 static Command SetLedArray(const enum LedNumber &number, const enum LedColour &colour, Command::Data ¤t_data);
00114 static Command SetDigitalOutput(const DigitalOutput &digital_output, Command::Data ¤t_data);
00115 static Command SetExternalPower(const DigitalOutput &digital_output, Command::Data ¤t_data);
00116 static Command PlaySoundSequence(const enum SoundSequences &number, Command::Data ¤t_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 }
00139
00140 #endif
00141