RokubiminiSerialCommunication.hpp
Go to the documentation of this file.
1 
2 #pragma once
3 #include <regex>
8 
9 namespace rokubimini
10 {
11 namespace serial
12 {
14 {
15 public:
17 
18  virtual ~RokubiminiSerialResponseRegex() = default;
19 
20  virtual bool matchInString(const std::string& str) = 0;
21 };
22 
24 {
25 public:
26  RokubiminiSerialCommand() = default;
27  virtual ~RokubiminiSerialCommand() = default;
28  virtual bool formatCommand(std::string& formattedString) = 0;
29 };
30 
32 {
33 public:
36  const uint8_t& dataFormat, const uint8_t& baudRate);
37 
38  bool formatCommand(std::string& formattedString) override;
39 
40 private:
41  const std::string formatString_ = "c,%u,%u,%u,%u";
43  uint8_t dataFormat_;
44  uint8_t baudRate_;
45 };
46 
48 {
49 public:
52 
53  bool formatCommand(std::string& formattedString) override;
54 
55 private:
56  const std::string formatString_ = "f,%u,%u,%u,%u";
58 };
59 
61 {
62 public:
64  RokubiminiSerialCommandOffset(const Eigen::Matrix<double, 6, 1>& forceTorqueOffset);
65 
66  bool formatCommand(std::string& formattedString) override;
67 
68 private:
69  const std::string formatString_ = "b,%6.3f,%6.3f,%6.3f,%6.3f,%6.3f,%6.3f";
70  const Eigen::Matrix<double, 6, 1> forceTorqueOffset_;
71 };
72 
74 {
75 public:
77  RokubiminiSerialCommandSensorCalibrationRow(const double& sensorCalibration1, const double& sensorCalibration2,
78  const double& sensorCalibration3, const double& sensorCalibration4,
79  const double& sensorCalibration5, const double& sensorCalibration6,
80  const uint32_t& row);
81 
82  bool formatCommand(std::string& formattedString) override;
83 
84 private:
85  const std::string formatString_ = "m%u,%9.6f,%9.6f,%9.6f,%9.6f,%9.6f,%9.6f";
92  uint32_t row_;
93 };
94 
96 {
97 public:
99 
100  bool formatCommand(std::string& formattedString) override;
101 
102 private:
103  const std::string formatString_ = "#";
104 };
105 
107 {
108 public:
110  ;
111 
112  bool formatCommand(std::string& formattedString) override;
113 
114 private:
115  const std::string formatString_ = "I";
116 };
117 
119 {
120 public:
121  RokubiminiSerialCommandConfig() = default;
122  ;
123 
124  bool formatCommand(std::string& formattedString) override;
125 
126 private:
127  const std::string formatString_ = "C";
128 };
129 
131 {
132 public:
133  RokubiminiSerialCommandRun() = default;
134  ;
135 
136  bool formatCommand(std::string& formattedString) override;
137 
138 private:
139  const std::string formatString_ = "R";
140 };
141 
143 {
144 public:
145  RokubiminiSerialCommandSave() = default;
146  ;
147 
148  bool formatCommand(std::string& formattedString) override;
149 
150 private:
151  const std::string formatString_ = "s";
152 };
153 
155 {
156 public:
157  RokubiminiSerialCommandLoad() = default;
158  ;
159 
160  bool formatCommand(std::string& formattedString) override;
161 
162 private:
163  const std::string formatString_ = "l";
164 };
165 
167 {
168 public:
169  RokubiminiSerialCommandPrint() = default;
170  ;
171 
172  bool formatCommand(std::string& formattedString) override;
173 
174 private:
175  const std::string formatString_ = "w";
176 };
177 
179 {
180 public:
181  bool matchInString(const std::string& str) override;
182 
183  inline const uint8_t& getTempComp()
184  {
185  return tempComp_;
186  }
187  inline const uint8_t& getDataFormat()
188  {
189  return dataFormat_;
190  }
191  inline const uint8_t& getBaudRate()
192  {
193  return baudRate_;
194  }
195  inline const uint8_t& getCalibration()
196  {
197  return calibration_;
198  }
199  inline void setBaudRate(uint8_t& baudRate)
200  {
201  baudRate_ = baudRate;
202  }
203 
204 private:
205  const std::regex stringRegex_ = std::regex("\\bc(,\\d){4}\\b");
206  const std::string format_ = "c,%c,%c,%c,%c";
207  uint8_t tempComp_;
208  uint8_t dataFormat_;
209  uint8_t baudRate_;
210  uint8_t calibration_;
211 };
212 
214 {
215 public:
216  bool matchInString(const std::string& str) override;
217 
218  inline const std::string& getFirstWord()
219  {
220  return firstWord_;
221  }
222  inline const std::string& getSecondWord()
223  {
224  return secondWord_;
225  }
226  inline const std::string& getThirdWord()
227  {
228  return thirdWord_;
229  }
230  inline const std::string& getFourthWord()
231  {
232  return fourthWord_;
233  }
234 
235 private:
236  const std::regex stringRegex_ = std::regex("name: BFF-\\w{3}(-\\w{2}){3}");
237  const std::string format_ = "name: BFF-%s-%s-%s";
238  std::string firstWord_;
239  std::string secondWord_;
240  std::string thirdWord_;
241  std::string fourthWord_;
242 };
243 
245 {
246 public:
247  bool matchInString(const std::string& str) override;
248 
249  inline const uint8_t& getFirstNumber()
250  {
251  return firstNumber_;
252  }
253  inline const std::string& getCommand()
254  {
255  return command_;
256  }
257  inline const uint8_t& getReturnCode()
258  {
259  return returnCode_;
260  }
261 
262 private:
263  const std::regex stringRegex_ = std::regex("\\br,\\d,\\w,\\d\\b");
264  const std::string format_ = "r,%c,%c,%c";
265  uint8_t firstNumber_;
266  std::string command_;
267  std::uint8_t returnCode_;
268 };
269 } // namespace serial
270 } // namespace rokubimini
virtual bool matchInString(const std::string &str)=0
System dependencies.


rokubimini_serial
Author(s):
autogenerated on Wed Mar 3 2021 03:09:18