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:
37  typedef ecl::PushAndPop<unsigned char> Buffer;
38  typedef ecl::Stencil< Buffer > BufferStencil;
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 
74  Name command;
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 
126  Data data;
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 
kobuki::LedNumber
LedNumber
Definition: led_array.hpp:39
kobuki::UniqueDeviceID
Definition: unique_device_id.hpp:40
kobuki
Definition: command.hpp:31
kobuki::DigitalOutput
Definition: digital_output.hpp:33
kobuki::LedColour
LedColour
Definition: led_array.hpp:44
payload_base.hpp
Base class for payloads.
led_array.hpp
Definitions for manipulating the led's.
modules.hpp
Convenience header for modules.
ecl::Stencil
packet_handler::payloadBase
Provides base class for payloads.
Definition: payload_base.hpp:44
macros.hpp
Macros for kobuki_driver.
radius
double radius
Definition: velocity_commands.cpp:18
kobuki::Command::VersionFlag
VersionFlag
Definition: command.hpp:61
speed
double speed
Definition: velocity_commands.cpp:18
kobuki_PUBLIC
#define kobuki_PUBLIC
Definition: macros.hpp:39
ecl::PushAndPop< unsigned char >
kobuki::Command
Definition: command.hpp:40
containers.hpp
kobuki::DiffDrive
Definition: diff_drive.hpp:44
kobuki::Command::Data
Data structure containing data for commands.
Definition: command.hpp:78
kobuki::SoundSequences
SoundSequences
Definition: sound.hpp:36


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Wed Mar 2 2022 00:26:14