command.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_COMMAND_DATA_HPP__
14 #define KOBUKI_COMMAND_DATA_HPP__
15 
16 /*****************************************************************************
17 ** Includes
18 *****************************************************************************/
19 
20 #include <ecl/containers.hpp>
22 #include "modules/led_array.hpp"
23 #include "modules.hpp"
24 #include "macros.hpp"
25 
26 /*****************************************************************************
27 ** Namespace
28 *****************************************************************************/
29 
30 
31 namespace kobuki
32 {
33 
35 {
36 public:
39 
43  enum Name
44  {
45  BaseControl = 1, Sound = 3, SoundSequence = 4, RequestExtra = 9, ChangeFrame = 10, RequestEeprom = 11,
46  SetDigitalOut = 12, SetController = 13, GetController = 14
47  };
48 
50  {
51  HardwareVersion = 0x01, FirmwareVersion = 0x02/*, Time = 0x04*/, UniqueDeviceID = 0x08
52  };
53 
66  struct Data
67  {
68  Data()
69  : command(BaseControl), speed(0), radius(0), request_flags(0), gp_out(0x00f0) // set all the power pins high, others low.
70  , type(0), p_gain(1000), i_gain(1000), d_gain(1000)
71  {
72  }
73 
75 
76  // BaseControl
77  int16_t speed;
78  int16_t radius;
79 
80  // Sound - not yet implemented
81  uint16_t note;
82  unsigned char duration;
83 
84  // SoundSequence
85  // 0 - turning on, 1 - turn off, 2 - recharge start, 3 - press button,
86  // 4 - error sound, 5 - start cleaning, 6 - cleaning end
87  unsigned char segment_name;
88 
89  // RequestExtra (version flags)
90  uint16_t request_flags;
91 
92  // ChangeFrame & RequestEeprom
93  unsigned char frame_id;
94 
95  // SetDigitalOut
96  // 0x000f - digital output pins 0-3 (0x0001, 0x0002, 0x0004, 0x0008)
97  // 0x00f0 - external power breakers (3.3V, 5V, 12V 12V1A) (0x0010, 0x0020, 0x0040, 0x0080)
98  // 0x0f00 - led array (red1, green1, red2, green2) ( 0x0100, 0x0200, 0x0400, 0x0800)
99  uint16_t gp_out;
100 
101  // SetControllerGain
102  unsigned char type;
103  unsigned int p_gain;
104  unsigned int i_gain;
105  unsigned int d_gain;
106 
107  // SetControllerGain
108  unsigned char reserved;
109  };
110 
111  virtual ~Command() {}
112 
113  static Command SetLedArray(const enum LedNumber &number, const enum LedColour &colour, Command::Data &current_data);
114  static Command SetDigitalOutput(const DigitalOutput &digital_output, Command::Data &current_data);
115  static Command SetExternalPower(const DigitalOutput &digital_output, Command::Data &current_data);
116  static Command PlaySoundSequence(const enum SoundSequences &number, Command::Data &current_data);
117  static Command GetVersionInfo();
118  static Command SetVelocityControl(DiffDrive& diff_drive);
119  static Command SetVelocityControl(const int16_t &speed, const int16_t &radius);
120  static Command SetControllerGain(const unsigned char &type,
121  const unsigned int &p_gain,
122  const unsigned int &i_gain,
123  const unsigned int &d_gain);
124  static Command GetControllerGain();
125 
127 
128  void resetBuffer(Buffer &buffer);
129  bool serialise(ecl::PushAndPop<unsigned char> & byteStream);
130  bool deserialise(ecl::PushAndPop<unsigned char> & byteStream) { return true; }
132 private:
133  static const unsigned char header0;
134  static const unsigned char header1;
135 
136 };
137 
138 } // namespace kobuki
139 
140 #endif /* KOBUKI_COMMAND_DATA_HPP__ */
141 
Definitions for manipulating the led&#39;s.
SoundSequences
Definition: sound.hpp:30
unsigned int p_gain
Definition: command.hpp:103
static const unsigned char header1
Definition: command.hpp:134
double radius
virtual ~Command()
Definition: command.hpp:111
unsigned char segment_name
Definition: command.hpp:87
uint16_t request_flags
Definition: command.hpp:90
unsigned int i_gain
Definition: command.hpp:104
unsigned char frame_id
Definition: command.hpp:93
unsigned int d_gain
Definition: command.hpp:105
Provides base class for payloads.
Base class for payloads.
#define kobuki_PUBLIC
Definition: macros.hpp:39
double speed
Convenience header for modules.
unsigned char duration
Definition: command.hpp:82
unsigned char reserved
Definition: command.hpp:108
Macros for kobuki_driver.
ecl::Stencil< Buffer > BufferStencil
Definition: command.hpp:38
unsigned char type
Definition: command.hpp:102
Data structure containing data for commands.
Definition: command.hpp:66
static const unsigned char header0
Definition: command.hpp:133
ecl::PushAndPop< unsigned char > Buffer
Definition: command.hpp:37
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: command.hpp:130


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Fri Sep 18 2020 03:22:01