Kobuki 1.0.0
C++ API for the Kobuki research robot
All Classes Files Functions Variables Enumerations Pages
command.hpp
Go to the documentation of this file.
1
9/*****************************************************************************
10** Preprocessor
11*****************************************************************************/
12
13#ifndef KOBUKI_CORE_COMMAND_DATA_HPP__
14#define KOBUKI_CORE_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
31namespace kobuki
32{
33
34class kobuki_PUBLIC Command : public packet_handler::payloadBase
35{
36public:
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
49 enum VersionFlag
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);
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; }
132private:
133 static const unsigned char header0;
134 static const unsigned char header1;
135
136};
137
138} // namespace kobuki
139
140#endif /* KOBUKI_CORE_COMMAND_DATA_HPP__ */
141
Definition command.hpp:35
bool deserialise(ecl::PushAndPop< unsigned char > &)
Definition command.hpp:130
Name
Definition command.hpp:44
Definition diff_drive.hpp:52
Definition unique_device_id.hpp:35
Provides base class for payloads.
Definition payload_base.hpp:39
Macros for kobuki_core.
Convenience header for modules.
Base class for payloads.
Data structure containing data for commands.
Definition command.hpp:67
Definition digital_output.hpp:29