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
00025
00026
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, UniqueDeviceID = 0x08
00051 };
00052
00065 struct Data
00066 {
00067 Data() :
00068 command(BaseControl), speed(0), radius(0), request_flags(0), gp_out(0x00f0)
00069 {
00070 }
00071
00072 Name command;
00073
00074
00075 int16_t speed;
00076 int16_t radius;
00077
00078
00079 uint16_t note;
00080 unsigned char duration;
00081
00082
00083
00084
00085 unsigned char segment_name;
00086
00087
00088 uint16_t request_flags;
00089
00090
00091 unsigned char frame_id;
00092
00093
00094
00095
00096
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 ¤t_data);
00103 static Command SetDigitalOutput(const DigitalOutput &digital_output, Command::Data ¤t_data);
00104 static Command SetExternalPower(const DigitalOutput &digital_output, Command::Data ¤t_data);
00105 static Command PlaySoundSequence(const enum SoundSequences &number, Command::Data ¤t_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 }
00123
00124 #endif
00125