xbot.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10  ** Includes
11  *****************************************************************************/
12 
13 #include "../../include/xbot_driver/xbot.hpp"
14 #include <cmath>
15 #include <ecl/converters.hpp>
16 #include <ecl/geometry/angle.hpp>
17 #include <ecl/geometry/angle.hpp>
18 #include <ecl/math.hpp>
19 #include <ecl/sigslots.hpp>
20 #include <ecl/time/sleep.hpp>
21 #include <ecl/time/timestamp.hpp>
22 #include <fstream>
23 #include <stdexcept>
24 #include "../../include/xbot_driver/packet_handler/payload_headers.hpp"
25 
26 /*****************************************************************************
27  ** Namespaces
28  *****************************************************************************/
29 
30 namespace xbot {
31 
32 /*****************************************************************************
33  ** Implementation [PacketFinder]
34  *****************************************************************************/
35 
37  unsigned int packet_size(buffer.size());
38  unsigned char cs(0);
39  for (unsigned int i = 0; i < packet_size; i++) {
40  cs ^= buffer[i];
41  }
42  return cs ? false : true;
43 }
44 
45 /*****************************************************************************
46  ** Implementation [Initialisation]
47  *****************************************************************************/
48 
50  : shutdown_requested(false),
51  is_enabled(false),
52  base_is_connected(false),
53  sensor_is_connected(false),
54  base_is_alive(false),
55  sensor_is_alive(false),
56  heading_offset(0.0 / 0.0),
57  Power(1)
58 
59 {}
60 
65  for (int i = 0; i < 10; ++i) {
66  setSoundEnableControl(false);
67  setPowerControl(false);
68  }
69  disable();
70  shutdown_requested = true; // thread's spin() will catch this and terminate
71  base_thread.join();
72  sensor_thread.join();
74  sig_debug.emit("Device: xbot driver terminated.");
75 }
76 
78  if (!parameters.validate()) {
80  "Xbot's parameter settings did not validate.");
81  }
82  this->parameters = parameters;
83  std::string sigslots_namespace = parameters.sigslots_namespace;
84 
85  // connect signals
86  base_sig_stream_data.connect(sigslots_namespace +
87  std::string("/base_stream_data"));
88  base_sig_raw_data_command.connect(sigslots_namespace +
89  std::string("/base_raw_data_command"));
90  base_sig_raw_data_stream.connect(sigslots_namespace +
91  std::string("/base_raw_data_stream"));
92  // sig_serial_timeout.connect(sigslots_namespace+std::string("/serial_timeout"));
93 
94  sensor_sig_stream_data.connect(sigslots_namespace +
95  std::string("/sensor_stream_data"));
96  sensor_sig_raw_data_command.connect(sigslots_namespace +
97  std::string("/sensor_raw_data_command"));
98  sensor_sig_raw_data_stream.connect(sigslots_namespace +
99  std::string("/sensor_raw_data_stream"));
100 
101  sig_debug.connect(sigslots_namespace + std::string("/ros_debug"));
102  sig_info.connect(sigslots_namespace + std::string("/ros_info"));
103  sig_warn.connect(sigslots_namespace + std::string("/ros_warn"));
104  sig_error.connect(sigslots_namespace + std::string("/ros_error"));
105 
106  try {
109  ecl::NoParity); // this will throw exceptions -
110  // NotFoundError, OpenError
111  base_is_connected = true;
112  base_serial.block(4000); // blocks by default, but just to be clear!
113  } catch (const ecl::StandardException &e) {
114  if (e.flag() == ecl::NotFoundError) {
115  sig_warn.emit(
116  "base device does not (yet) available, is the usb connected?."); // not a failure mode.
117  } else {
118  throw ecl::StandardException(LOC, e);
119  }
120  }
121 
122  try {
125  sensor_is_connected = true;
126  sensor_serial.block(4000);
127  } catch (const ecl::StandardException &e) {
128  if (e.flag() == ecl::NotFoundError) {
129  sig_warn.emit(
130  "sensor device does not (yet) available, is the usb connected?");
131  } else {
132  throw ecl::StandardException(LOC, e);
133  }
134  }
135 
136  ecl::PushAndPop<unsigned char> base_stx(2, 0);
137  ecl::PushAndPop<unsigned char> base_etx(1);
138  base_stx.push_back(0xaa);
139  base_stx.push_back(0x55);
140  base_packet_finder.configure(sigslots_namespace, base_stx, base_etx, 1, 256,
141  1, true);
143  base_thread.start(&Xbot::base_spin, *this);
144 
145  ecl::PushAndPop<unsigned char> sensor_stx(2, 0);
146  ecl::PushAndPop<unsigned char> sensor_etx(1);
147  sensor_stx.push_back(0xaa);
148  sensor_stx.push_back(0x55);
149  sensor_packet_finder.configure(sigslots_namespace, sensor_stx, sensor_etx, 1,
150  256, 1, true);
151  sensor_thread.start(&Xbot::sensor_spin, *this);
152 }
153 
154 /*****************************************************************************
155  ** Implementation [Runtime]
156  *****************************************************************************/
170 
176 
178 
180 
191  ecl::TimeStamp last_signal_time;
192  ecl::Duration timeout(0.1);
193  unsigned char buf[256];
194 
195  // int buf_size=0;
196 
197  /*********************
198  ** Simulation Params
199  **********************/
200 
201  while (!shutdown_requested) {
202  /*********************
203  ** Checking Connection
204  **********************/
205  if (!base_serial.open()) {
206  try {
207  // this will throw exceptions - NotFoundError is the important one,
208  // handle it
211  sig_info.emit("base device is connected.");
212  base_is_connected = true;
213  base_serial.block(4000); // blocks by default, but just to be clear!
214  } catch (const ecl::StandardException &e) {
215  // windows throws OpenError if not connected
216  if (e.flag() == ecl::NotFoundError) {
217  sig_info.emit(
218  "base device does not (yet) available on this port, waiting...");
219  } else if (e.flag() == ecl::OpenError) {
220  sig_info.emit("base device failed to open, waiting... [" +
221  std::string(e.what()) + "]");
222  } else {
223  // This is bad - some unknown error we're not handling! But at least
224  // throw and show what error we came across.
225  throw ecl::StandardException(LOC, e);
226  }
227  ecl::Sleep(5)(); // five seconds
228  base_is_connected = false;
229  base_is_alive = false;
230  continue;
231  }
232  }
233 
234  /*********************
235  ** Read Incoming
236  **********************/
237  int n = base_serial.read((char *)buf, 1);
238  // std::cout<<"n: "<<n<<std::endl;
239 
240  if (n == 0) {
241  if (base_is_alive && ((ecl::TimeStamp() - last_signal_time) > timeout)) {
242  base_is_alive = false;
243  sig_debug.emit("Timed out while waiting for incoming bytes.");
244  }
245  continue;
246  } else {
247  std::ostringstream ostream;
248  ostream << "xbot_node : serial_read(" << n << ")"
249  << ", packet_finder.numberOfDataToRead("
251  // sig_debug.emit(ostream.str());
252  // might be useful to send this to a topic if there is subscribers
253  }
254  // buf_size+=n;
255 
256  bool find_packet = base_packet_finder.update(buf, n);
257 
258  if (find_packet) // this clears packet finder's buffer and transfers
259  // important bytes into it
260  {
261  PacketFinder::BufferType local_buffer;
263  local_buffer); // get a reference to packet finder's buffer.
264  base_sig_raw_data_stream.emit(local_buffer);
265 
267  base_data_buffer); // get a reference to packet finder's buffer.
268 
270  std::cout << "data_buffer.size:" << base_data_buffer.size() << std::endl;
271 
272  while (base_data_buffer.size() > 0) {
273  // std::cout << "header_id: " << (unsigned int)data_buffer[0] <<
274  // " | "<<std::endl;
275  // std::cout << "length: " << (unsigned int)data_buffer[1] << " |
276  // ";
277  // std::cout << "remains: " << data_buffer.size() << " | ";
278  // std::cout << "local_buffer: " << local_buffer.size() << " | ";
279  // std::cout << std::endl;
281  std::cout << "fixed" << std::endl;
283  break;
284  }
285 
286  }
287  // std::cout << "---" << std::endl;
290 
291  base_is_alive = true;
292  last_signal_time.stamp();
293  // sig_stream_data.emit();
294  sendBaseControlCommand(); // send the command packet to mainboard;
295  } else {
296  // watchdog
297  if (base_is_alive && ((ecl::TimeStamp() - last_signal_time) > timeout)) {
298  base_is_alive = false;
299  // do not call here the event manager update, as it generates a spurious
300  // offline state
301  }
302  }
303  }
304  sig_error.emit("Driver worker thread shutdown!");
305 }
306 
308  if (byteStream.size() <
309  3) { /* minimum size of sub-payload is 3; header_id, length, data */
310  byteStream.clear();
311  } else {
312  std::stringstream ostream;
313  unsigned int header_id = static_cast<unsigned int>(byteStream.pop_front());
314  unsigned int length = static_cast<unsigned int>(byteStream.pop_front());
315  unsigned int remains = byteStream.size();
316  unsigned int to_pop;
317 
318  ostream << "[" << header_id << "]";
319  ostream << "[" << length << "]";
320 
321  ostream << "[";
322  ostream << std::setfill('0') << std::uppercase;
323  ostream << std::hex << std::setw(2) << header_id << " " << std::dec;
324  ostream << std::hex << std::setw(2) << length << " " << std::dec;
325 
326  if (remains < length)
327  to_pop = remains;
328  else
329  to_pop = length;
330 
331  for (unsigned int i = 0; i < to_pop; i++) {
332  unsigned int byte = static_cast<unsigned int>(byteStream.pop_front());
333  ostream << std::hex << std::setw(2) << byte << " " << std::dec;
334  }
335  ostream << "]";
336  }
337 }
338 
340  ecl::TimeStamp last_signal_time;
341  ecl::Duration timeout(0.1);
342  unsigned char buf[256];
343 
344  // int buf_size=0;
345 
346  /*********************
347  ** Simulation Params
348  **********************/
349 
350  while (!shutdown_requested) {
351  /*********************
352  ** Checking Connection
353  **********************/
354  if (!sensor_serial.open()) {
355  try {
356  // this will throw exceptions - NotFoundError is the important one,
357  // handle it
360  sig_info.emit("sensor device is connected.");
361  sensor_is_connected = true;
362  sensor_serial.block(4000); // blocks by default, but just to be clear!
363  } catch (const ecl::StandardException &e) {
364  // windows throws OpenError if not connected
365  if (e.flag() == ecl::NotFoundError) {
366  sig_info.emit(
367  "sensor device does not (yet) available on this port, "
368  "waiting...");
369  } else if (e.flag() == ecl::OpenError) {
370  sig_info.emit("sensor device failed to open, waiting... [" +
371  std::string(e.what()) + "]");
372  } else {
373  // This is bad - some unknown error we're not handling! But at least
374  // throw and show what error we came across.
375  throw ecl::StandardException(LOC, e);
376  }
377  ecl::Sleep(5)(); // five seconds
378  sensor_is_connected = false;
379  sensor_is_alive = false;
380  continue;
381  }
382  }
383 
384  /*********************
385  ** Read Incoming
386  **********************/
387  int n = sensor_serial.read((char *)buf, 1);
388  // std::cout<<"n: "<<n<<std::endl;
389 
390  if (n == 0) {
391  if (sensor_is_alive &&
392  ((ecl::TimeStamp() - last_signal_time) > timeout)) {
393  sensor_is_alive = false;
394  sig_debug.emit("Timed out while waiting for incoming bytes.");
395  }
396  continue;
397  } else {
398  std::ostringstream ostream;
399  ostream << "xbot_node : serial_read(" << n << ")"
400  << ", packet_finder.numberOfDataToRead("
402  // sig_debug.emit(ostream.str());
403  // might be useful to send this to a topic if there is subscribers
404  }
405  // buf_size+=n;
406 
407  bool find_packet = sensor_packet_finder.update(buf, n);
408 
409  if (find_packet) // this clears packet finder's buffer and transfers
410  // important bytes into it
411  {
412  PacketFinder::BufferType local_buffer;
414  local_buffer); // get a reference to packet finder's buffer.
415  sensor_sig_raw_data_stream.emit(local_buffer);
416 
418  sensor_data_buffer); // get a reference to packet finder's buffer.
419 
421  std::cout << "data_buffer.size:" << sensor_data_buffer.size()
422  << std::endl;
423 
424  while (sensor_data_buffer.size() > 0) {
426  std::cout << "fixed" << std::endl;
428  break;
429  }
430 
431  if (std::isnan(heading_offset) == true) {
433  static_cast<double>(sensors.data.yaw) * ecl::pi / 180.0;
434  }
435 
436  }
437  // std::cout << "---" << std::endl;
440 
441  sensor_is_alive = true;
442  last_signal_time.stamp();
443  } else {
444  // watchdog
445  if (sensor_is_alive &&
446  ((ecl::TimeStamp() - last_signal_time) > timeout)) {
447  sensor_is_alive = false;
448  // do not call here the event manager update, as it generates a spurious
449  // offline state
450  }
451  }
452  }
453  sig_error.emit("Driver worker thread shutdown!");
454 }
455 
457  if (byteStream.size() <
458  3) { /* minimum size of sub-payload is 3; header_id, length, data */
459  byteStream.clear();
460  } else {
461  std::stringstream ostream;
462  unsigned int header_id = static_cast<unsigned int>(byteStream.pop_front());
463  unsigned int length = static_cast<unsigned int>(byteStream.pop_front());
464  unsigned int remains = byteStream.size();
465  unsigned int to_pop;
466 
467  ostream << "[" << header_id << "]";
468  ostream << "[" << length << "]";
469 
470  ostream << "[";
471  ostream << std::setfill('0') << std::uppercase;
472  ostream << std::hex << std::setw(2) << header_id << " " << std::dec;
473  ostream << std::hex << std::setw(2) << length << " " << std::dec;
474 
475  if (remains < length)
476  to_pop = remains;
477  else
478  to_pop = length;
479 
480  for (unsigned int i = 0; i < to_pop; i++) {
481  unsigned int byte = static_cast<unsigned int>(byteStream.pop_front());
482  ostream << std::hex << std::setw(2) << byte << " " << std::dec;
483  }
484  ostream << "]";
485  }
486 }
487 /*****************************************************************************
488  ** Implementation [Human Friendly Accessors]
489  *****************************************************************************/
490 
491 double Xbot::getHeading() const {
492  ecl::Angle<double> heading;
493  // double heading;
494  // raw data angles are in tens of a degree, convert to radians.
495  heading = (static_cast<double>(sensors.data.yaw)) * ecl::pi / 180.0;
496  // std::cout<<"heading:"<<heading<<" |
497  // heading_offset:"<<heading_offset<<std::endl;
498 
499  return ecl::wrap_angle(heading - heading_offset);
500 }
501 
503  return (static_cast<int>(core_sensors.data.left_encoder));
504 }
505 double Xbot::getAngularVelocity() const {
506  // raw data angles are in hundredths of a degree, convert to radians.
507  return static_cast<double>(sensors.data.gyro_z);
508 }
509 
511  setLiftControl(0);
512  setPowerControl(1);
515 }
516 
517 /*****************************************************************************
518  ** Implementation [Raw Data Accessors]
519  *****************************************************************************/
520 
522  diff_drive.reset();
523 
524  // Issue #274: use current imu reading as zero heading to emulate reseting
525  // gyro
526  heading_offset = (static_cast<float>(sensors.data.yaw)) * ecl::pi / 180.0;
527 }
528 
529 void Xbot::getWheelJointStates(float &wheel_left_angle,
530  float &wheel_left_angle_rate,
531  float &wheel_right_angle,
532  float &wheel_right_angle_rate) {
533  diff_drive.getWheelJointStates(wheel_left_angle, wheel_left_angle_rate,
534  wheel_right_angle, wheel_right_angle_rate);
535 }
536 
553  ecl::linear_algebra::Vector3d &pose_update_rates) {
555  core_sensors.data.right_encoder, pose_update,
556  pose_update_rates);
557 }
558 
559 /*****************************************************************************
560  ** Commands
561  *****************************************************************************/
562 
563 void Xbot::setBaseControl(const float &linear_velocity,
564  const float &angular_velocity) {
565  diff_drive.setVelocityCommands(linear_velocity, angular_velocity);
566 }
567 
568 void Xbot::setPowerControl(const bool &power) {
570  Power = power;
571 }
572 
573 void Xbot::setLiftControl(const unsigned char &height_percent) {
574  sendCommand(Command::SetLiftControl(height_percent));
575  HeightPercent = height_percent;
576 }
577 
578 void Xbot::setYawPlatformControl(const int &yaw_degree) {
580 }
581 
582 void Xbot::setPitchPlatformControl(const int &pitch_degree) {
584 }
585 
586 void Xbot::setSoundEnableControl(const bool &sound) {
588 }
589 
590 void Xbot::setLedControl(const char &led) {
592 }
594  setBaseControl(0, 0);
595  setLiftControl(0);
596  setPowerControl(1);
599 }
600 
602  std::vector<float> velocity_commands_received;
604  velocity_commands_received =
606  } else {
607  velocity_commands_received = diff_drive.pointVelocity();
608  }
609  diff_drive.velocityCommands(velocity_commands_received);
610  std::vector<float> velocity_commands = diff_drive.velocityCommands();
611  std::cout << "linear_velocity: " << velocity_commands[0]
612  << ", angular_velocity: " << velocity_commands[1] << std::endl;
613  if ((velocity_commands[0] != 0) || (velocity_commands[1] != 0)) {
614  sendCommand(Command::SetVelocityControl(velocity_commands[0],
615  velocity_commands[1]));
616  }
617 
618  // //experimental; send raw control command and received command velocity
619  // velocity_commands_debug=velocity_commands;
620  // velocity_commands_debug.push_back((short)(velocity_commands_received[0]*1000.0));
621  // velocity_commands_debug.push_back((short)(velocity_commands_received[1]*1000.0));
622  // sig_raw_control_command.emit(velocity_commands_debug);
623 }
624 
636 void Xbot::sendCommand(Command command) {
637  if (command.data.command < 3) {
638  if (!base_is_alive) {
639  // need to do something
640  sig_debug.emit("Base Device state is not ready yet.");
641  sig_debug.emit(" - Base Device is not alive.");
642  return;
643  }
644 
645  if (!base_is_connected) {
646  sig_debug.emit(" - Base Device is not connected.");
647  return;
648  }
649  base_command_mutex.lock();
651 
652  if (!command.serialise(command_buffer)) {
653  sig_error.emit("command serialise failed.");
654  }
656  unsigned char checksum = 0;
657  for (unsigned int i = 0; i < command_buffer.size(); i++)
658  checksum ^= (command_buffer[i]);
659 
660  command_buffer.push_back(checksum);
661  // check_device();
662  // for (int i = 0;i < command_buffer.size();i++)
663  // {
664  // // std::cout <<std::hex<<command_buffer[i]<<std::endl;
665  // printf("%02x ",command_buffer[i]);
666 
667  // }
668 
669  base_serial.write((const char *)&command_buffer[0], command_buffer.size());
670 
672  base_command_mutex.unlock();
673 
674  } else {
675  if (!sensor_is_alive) {
676  // need to do something
677  sig_debug.emit("Sensor Device state is not ready yet.");
678  sig_debug.emit(" - Sensor Device is not alive.");
679  return;
680  }
681  if (!sensor_is_connected) {
682  sig_debug.emit(" - Sensor Device is not connected.");
683  return;
684  }
685  sensor_command_mutex.lock();
687 
688  if (!command.serialise(command_buffer)) {
689  sig_error.emit("command serialise failed.");
690  }
692  unsigned char checksum = 0;
693  for (unsigned int i = 0; i < command_buffer.size(); i++)
694  checksum ^= (command_buffer[i]);
695 
696  command_buffer.push_back(checksum);
697  // check_device();
698  // for (int i = 0;i < command_buffer.size();i++)
699  // {
700  // // std::cout <<std::hex<<command_buffer[i]<<std::endl;
701  // printf("%02x ",command_buffer[i]);
702 
703  // }
704 
705  sensor_serial.write((const char *)&command_buffer[0],
706  command_buffer.size());
707 
709  sensor_command_mutex.unlock();
710  }
711 }
712 
713 bool Xbot::enable() {
714  setPowerControl(true);
715  is_enabled = true;
716  return true;
717 }
718 
720  setBaseControl(0.0f, 0.0f);
722  setPowerControl(false);
723  is_enabled = false;
724  return true;
725 }
726 
736 } // namespace xbot
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: command.cpp:126
bool sensor_is_alive
Definition: xbot.hpp:273
int getDebugSensors() const
Definition: xbot.cpp:502
void sensor_lockDataAccess()
Definition: xbot.cpp:177
void velocityCommands(const float &vx, const float &wz)
Definition: diff_drive.cpp:143
DiffDrive diff_drive
Definition: xbot.hpp:235
std::string base_port
The serial device port name [/dev/xbot].
Definition: parameters.hpp:51
ecl::Serial sensor_serial
Definition: xbot.hpp:269
static Command SetPowerControl(const bool &power_state)
Definition: command.cpp:104
const char * what() const
void sensor_fixPayload(ecl::PushAndPop< unsigned char > &byteStream)
Definition: xbot.cpp:456
ecl::Signal< PacketFinder::BufferType & > base_sig_raw_data_stream
Definition: xbot.hpp:305
std::string sensor_port
Definition: parameters.hpp:52
bool base_is_connected
Definition: xbot.hpp:249
unsigned int size() const
void resetBuffer(Buffer &buffer)
Definition: command.cpp:118
void update(const unsigned int &time_stamp, const uint16_t &left_encoder, const uint16_t &right_encoder, ecl::Pose2D< double > &pose_update, ecl::linear_algebra::Vector3d &pose_update_rates)
Updates the odometry from firmware stamps and encoders.
Definition: diff_drive.cpp:54
bool Power
Definition: xbot.hpp:230
Parameter list and validator for the xbot.
Definition: parameters.hpp:35
double getAngularVelocity() const
Definition: xbot.cpp:505
static Command SetYawPlatformControl(const int &yaw_platform_degree)
Definition: command.cpp:67
std::vector< float > pointVelocity() const
Definition: diff_drive.cpp:153
static Command SetLedControl(const unsigned char &led)
Definition: command.cpp:94
#define LOC
Stringify the line of code you are at.
ecl::Thread base_thread
Definition: xbot.hpp:221
StopBits_1
bool base_is_alive
Definition: xbot.hpp:272
bool is_enabled
Definition: xbot.hpp:236
bool validate()
A validator to ensure the user has supplied correct/sensible parameter values.
Definition: parameters.hpp:69
AccelerationLimiter acceleration_limiter
Definition: xbot.hpp:256
double heading_offset
Definition: xbot.hpp:242
double const pi
void getWheelJointStates(float &wheel_left_angle, float &wheel_left_angle_rate, float &wheel_right_angle, float &wheel_right_angle_rate)
Definition: diff_drive.cpp:122
void getWheelJointStates(float &wheel_left_angle, float &wheel_left_angle_rate, float &wheel_right_angle, float &wheel_right_angle_rate)
Definition: xbot.cpp:529
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/xbot"].
Definition: parameters.hpp:53
void resetOdometry()
Definition: xbot.cpp:521
void sensor_unlockDataAccess()
Definition: xbot.cpp:179
std::vector< float > limit(const std::vector< float > &command)
Limits the input velocity commands if gatekeeper is enabled.
Sensors sensors
Definition: xbot.hpp:262
void setPitchPlatformControl(const int &pitch_degree)
Definition: xbot.cpp:582
void base_unlockDataAccess()
Definition: xbot.cpp:175
bool shutdown_requested
Definition: xbot.hpp:224
void sensor_spin()
Definition: xbot.cpp:339
Command xbot_command
Definition: xbot.hpp:288
ecl::Mutex sensor_command_mutex
Definition: xbot.hpp:284
ConfigurationError
static Command SetSoundControl(const bool &sound_state)
Definition: command.cpp:85
void setLedControl(const char &led)
Definition: xbot.cpp:590
void setBaseControl(const float &linear_velocity, const float &angular_velocity)
Definition: xbot.cpp:563
EndOfLine endl
void push_back(const Type &datum)
void configure(const std::string &sigslots_namespace, const BufferType &putStx, const BufferType &putEtx, unsigned int sizeLengthField, unsigned int sizeMaxPayload, unsigned int sizeChecksumField, bool variableSizePayload)
bool enable()
Definition: xbot.cpp:713
Standard exception type, provides code location and error string.
static Command SetPitchPlatformControl(const int &pitch_platform_degree)
Definition: command.cpp:76
NotFoundError
void setVelocityCommands(const float &vx, const float &wz)
Definition: diff_drive.cpp:134
DataBits_8
Xbot()
Definition: xbot.cpp:49
unsigned char HeightPercent
Definition: xbot.hpp:229
ecl::Signal< PacketFinder::BufferType & > sensor_sig_raw_data_stream
Definition: xbot.hpp:308
ecl::Signal sensor_sig_stream_data
Definition: xbot.hpp:295
ecl::PushAndPop< unsigned char > BufferType
struct xbot::CoreSensors::Data data
void setLiftControl(const unsigned char &height_percent)
Definition: xbot.cpp:573
void base_fixPayload(ecl::PushAndPop< unsigned char > &byteStream)
Definition: xbot.cpp:307
Command::Buffer command_buffer
Definition: xbot.hpp:289
bool checkSum()
Definition: xbot.cpp:36
virtual bool update(const unsigned char *incoming, unsigned int numberOfIncoming)
PacketFinder::BufferType base_data_buffer
Definition: xbot.hpp:266
ecl::Thread sensor_thread
Definition: xbot.hpp:223
~Xbot()
Definition: xbot.cpp:64
ecl::Signal< const std::string & > sig_warn
Definition: xbot.hpp:296
PacketFinder::BufferType sensor_data_buffer
Definition: xbot.hpp:271
Parameters parameters
Definition: xbot.hpp:247
void setYawPlatformControl(const int &yaw_degree)
Definition: xbot.cpp:578
ecl_geometry_PUBLIC const float & wrap_angle(float &angle)
Wrap the angle on -pi,pi (float types).
ecl::Mutex sensor_data_mutex
Definition: xbot.hpp:285
void setPowerControl(const bool &power)
Definition: xbot.cpp:568
ecl::Signal base_sig_stream_data
Definition: xbot.hpp:294
struct xbot::Sensors::Data data
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Parent template definition for angles.
Definition: angle.hpp:113
ecl::Signal< const std::string & > sig_error
Definition: xbot.hpp:296
ecl::Mutex base_data_mutex
Definition: xbot.hpp:282
CoreSensors core_sensors
Definition: xbot.hpp:261
void sendCommand(Command command)
Send the prepared command to the serial port.
Definition: xbot.cpp:636
void getBuffer(BufferType &bufferRef)
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: sensors.cpp:45
ecl::Signal< Command::Buffer & > sensor_sig_raw_data_command
Definition: xbot.hpp:303
double getHeading() const
Definition: xbot.cpp:491
BaudRate_115200
ecl::Signal< const std::string & > sig_debug
Definition: xbot.hpp:296
void updateOdometry(ecl::Pose2D< double > &pose_update, ecl::linear_algebra::Vector3d &pose_update_rates)
Use the current sensor data (encoders and gyro) to calculate an update for the odometry.
Definition: xbot.cpp:552
TimeStamp Duration
ecl::Signal< const std::string & > sig_info
Definition: xbot.hpp:296
ecl::Serial base_serial
Definition: xbot.hpp:264
void f(int i) ecl_debug_throw_decl(StandardException)
void resetXbotState()
Definition: xbot.cpp:510
ecl::Mutex base_command_mutex
Definition: xbot.hpp:280
void connect(const std::string &topic)
void base_spin()
Performs a scan looking for incoming data packets.
Definition: xbot.cpp:190
PacketFinder base_packet_finder
Definition: xbot.hpp:265
Definition: command.hpp:30
static Command SetVelocityControl(DiffDrive &diff_drive)
Definition: command.cpp:38
bool sensor_is_connected
Definition: xbot.hpp:251
void base_lockDataAccess()
Definition: xbot.cpp:169
void emit(Data data)
bool enable_acceleration_limiter
Enable or disable the acceleration limiter [true].
Definition: parameters.hpp:55
void init(Parameters &parameters)
Definition: xbot.cpp:77
void resetXbot()
Definition: xbot.cpp:593
void init(bool enable_acceleration_limiter, float linear_acceleration_max_=0.5, float angular_acceleration_max_=3.5, float linear_deceleration_max_=-0.5 *1.2, float angular_deceleration_max_=-3.5 *1.2)
bool disable()
Definition: xbot.cpp:719
void setSoundEnableControl(const bool &sound)
Definition: xbot.cpp:586
void getPayload(BufferType &bufferRef)
unsigned int numberOfDataToRead()
PacketFinder sensor_packet_finder
Definition: xbot.hpp:270
ecl::Signal< Command::Buffer & > base_sig_raw_data_command
Definition: xbot.hpp:297
static Command SetLiftControl(const unsigned char &lift_height)
Definition: command.cpp:57
const ErrorFlag & flag() const
void sendBaseControlCommand()
Definition: xbot.cpp:601


xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:38