kobuki.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10  ** Includes
11  *****************************************************************************/
12 
13 #include <cmath>
14 #include <ecl/math.hpp>
15 #include <ecl/geometry/angle.hpp>
16 #include <ecl/time/sleep.hpp>
17 #include <ecl/converters.hpp>
18 #include <ecl/sigslots.hpp>
19 #include <ecl/geometry/angle.hpp>
20 #include <ecl/time/timestamp.hpp>
21 #include <stdexcept>
22 #include "../../include/kobuki_driver/kobuki.hpp"
23 #include "../../include/kobuki_driver/packet_handler/payload_headers.hpp"
24 
25 /*****************************************************************************
26  ** Namespaces
27  *****************************************************************************/
28 
29 namespace kobuki
30 {
31 
32 /*****************************************************************************
33  ** Implementation [PacketFinder]
34  *****************************************************************************/
35 
37 {
38  unsigned int packet_size(buffer.size());
39  unsigned char cs(0);
40  for (unsigned int i = 2; i < packet_size; i++)
41  {
42  cs ^= buffer[i];
43  }
44  return cs ? false : true;
45 }
46 
47 /*****************************************************************************
48  ** Implementation [Initialisation]
49  *****************************************************************************/
50 
52  shutdown_requested(false)
53  , is_enabled(false)
54  , is_connected(false)
55  , is_alive(false)
56  , version_info_reminder(0)
57  , controller_info_reminder(0)
58  , heading_offset(0.0/0.0)
59  , velocity_commands_debug(4, 0)
60 {
61 }
62 
67 {
68  disable();
69  shutdown_requested = true; // thread's spin() will catch this and terminate
70  thread.join();
71  sig_debug.emit("Device: kobuki driver terminated.");
72 }
73 
74 void Kobuki::init(Parameters &parameters) throw (ecl::StandardException)
75 {
76 
77  if (!parameters.validate())
78  {
79  throw ecl::StandardException(LOC, ecl::ConfigurationError, "Kobuki's parameter settings did not validate.");
80  }
81  this->parameters = parameters;
82  std::string sigslots_namespace = parameters.sigslots_namespace;
83  event_manager.init(sigslots_namespace);
84 
85  // connect signals
86  sig_version_info.connect(sigslots_namespace + std::string("/version_info"));
87  sig_controller_info.connect(sigslots_namespace + std::string("/controller_info"));
88  sig_stream_data.connect(sigslots_namespace + std::string("/stream_data"));
89  sig_raw_data_command.connect(sigslots_namespace + std::string("/raw_data_command"));
90  sig_raw_data_stream.connect(sigslots_namespace + std::string("/raw_data_stream"));
91  sig_raw_control_command.connect(sigslots_namespace + std::string("/raw_control_command"));
92  //sig_serial_timeout.connect(sigslots_namespace+std::string("/serial_timeout"));
93 
94  sig_debug.connect(sigslots_namespace + std::string("/ros_debug"));
95  sig_info.connect(sigslots_namespace + std::string("/ros_info"));
96  sig_warn.connect(sigslots_namespace + std::string("/ros_warn"));
97  sig_error.connect(sigslots_namespace + std::string("/ros_error"));
98  sig_named.connect(sigslots_namespace + std::string("/ros_named"));
99 
100  try {
101  serial.open(parameters.device_port, ecl::BaudRate_115200, ecl::DataBits_8, ecl::StopBits_1, ecl::NoParity); // this will throw exceptions - NotFoundError, OpenError
102  is_connected = true;
103  serial.block(4000); // blocks by default, but just to be clear!
104  }
105  catch (const ecl::StandardException &e)
106  {
107  if (e.flag() == ecl::NotFoundError) {
108  sig_warn.emit("device does not (yet) available, is the usb connected?."); // not a failure mode.
109  } else {
110  throw ecl::StandardException(LOC, e);
111  }
112  }
113 
114  ecl::PushAndPop<unsigned char> stx(2, 0);
115  ecl::PushAndPop<unsigned char> etx(1);
116  stx.push_back(0xaa);
117  stx.push_back(0x55);
118  packet_finder.configure(sigslots_namespace, stx, etx, 1, 256, 1, true);
120 
121  // in case the user changed these from the defaults
125 
126  /******************************************
127  ** Get Version Info Commands
128  *******************************************/
131 
132  /******************************************
133  ** Get Controller Info Commands
134  *******************************************/
137  //sig_controller_info.emit(); //emit default gain
138 
139  thread.start(&Kobuki::spin, *this);
140 }
141 
142 /*****************************************************************************
143  ** Implementation [Runtime]
144  *****************************************************************************/
157  data_mutex.lock();
158 }
159 
165  data_mutex.unlock();
166 }
167 
178 {
179  ecl::TimeStamp last_signal_time;
180  ecl::Duration timeout(0.1);
181  unsigned char buf[256];
182 
183  /*********************
184  ** Simulation Params
185  **********************/
186 
187  while (!shutdown_requested)
188  {
189  /*********************
190  ** Checking Connection
191  **********************/
192  if ( !serial.open() ) {
193  try {
194  // this will throw exceptions - NotFoundError is the important one, handle it
195  serial.open(parameters.device_port, ecl::BaudRate_115200, ecl::DataBits_8, ecl::StopBits_1, ecl::NoParity);
196  sig_info.emit("device is connected.");
197  is_connected = true;
198  serial.block(4000); // blocks by default, but just to be clear!
202  }
203  catch (const ecl::StandardException &e)
204  {
205  // windows throws OpenError if not connected
206  if (e.flag() == ecl::NotFoundError) {
207  sig_info.emit("device does not (yet) available on this port, waiting...");
208  } else if (e.flag() == ecl::OpenError) {
209  sig_info.emit("device failed to open, waiting... [" + std::string(e.what()) + "]");
210  } else {
211  // This is bad - some unknown error we're not handling! But at least throw and show what error we came across.
212  throw ecl::StandardException(LOC, e);
213  }
214  ecl::Sleep(5)(); // five seconds
215  is_connected = false;
216  is_alive = false;
217  continue;
218  }
219  }
220 
221  /*********************
222  ** Read Incoming
223  **********************/
224  int n = serial.read((char*)buf, packet_finder.numberOfDataToRead());
225  if (n == 0)
226  {
227  if (is_alive && ((ecl::TimeStamp() - last_signal_time) > timeout))
228  {
229  is_alive = false;
232  sig_debug.emit("Timed out while waiting for incoming bytes.");
233  }
235  continue;
236  }
237  else
238  {
239  std::ostringstream ostream;
240  ostream << "kobuki_node : serial_read(" << n << ")"
241  << ", packet_finder.numberOfDataToRead(" << packet_finder.numberOfDataToRead() << ")";
242  //sig_debug.emit(ostream.str());
243  sig_named.emit(log("debug", "serial", ostream.str()));
244  // might be useful to send this to a topic if there is subscribers
245  }
246 
247  if (packet_finder.update(buf, n)) // this clears packet finder's buffer and transfers important bytes into it
248  {
249  PacketFinder::BufferType local_buffer;
250  packet_finder.getBuffer(local_buffer); // get a reference to packet finder's buffer.
251  sig_raw_data_stream.emit(local_buffer);
252 
253  packet_finder.getPayload(data_buffer);// get a reference to packet finder's buffer.
254 
255  lockDataAccess();
256  while (data_buffer.size() > 0)
257  {
258  //std::cout << "header_id: " << (unsigned int)data_buffer[0] << " | ";
259  //std::cout << "length: " << (unsigned int)data_buffer[1] << " | ";
260  //std::cout << "remains: " << data_buffer.size() << " | ";
261  //std::cout << "local_buffer: " << local_buffer.size() << " | ";
262  //std::cout << std::endl;
263  switch (data_buffer[0])
264  {
265  // these come with the streamed feedback
266  case Header::CoreSensors:
269  break;
272  break;
273  case Header::Inertia:
275 
276  // Issue #274: use first imu reading as zero heading; update when reseting odometry
277  if (std::isnan(heading_offset) == true)
278  heading_offset = (static_cast<double>(inertia.data.angle) / 100.0) * ecl::pi / 180.0;
279  break;
280  case Header::Cliff:
281  if( !cliff.deserialise(data_buffer) ) { fixPayload(data_buffer); break; }
282  break;
283  case Header::Current:
285  break;
286  case Header::GpInput:
289  break;
292  break;
293  // the rest are only included on request
294  case Header::Hardware:
296  //sig_version_info.emit(VersionInfo(firmware.data.version, hardware.data.version));
297  break;
298  case Header::Firmware:
300  try
301  {
302  // Check firmware/driver compatibility; major version must be the same
303  int version_match = firmware.check_major_version();
304  if (version_match < 0) {
305  sig_error.emit("Robot firmware is outdated and needs to be upgraded. Consult how-to on: " \
306  "http://kobuki.yujinrobot.com/home-en/documentation/howtos/upgrading-firmware");
307  sig_error.emit("Robot firmware version is " + VersionInfo::toString(firmware.data.version)
308  + "; latest version is " + firmware.current_version());
309  shutdown_requested = true;
310  }
311  else if (version_match > 0) {
312  sig_error.emit("Driver version isn't not compatible with robot firmware. Please upgrade driver");
313  shutdown_requested = true;
314  }
315  else
316  {
317  // And minor version don't need to, but just make a suggestion
318  version_match = firmware.check_minor_version();
319  if (version_match < 0) {
320  sig_warn.emit("Robot firmware is outdated; we suggest you to upgrade it " \
321  "to benefit from the latest features. Consult how-to on: " \
322  "http://kobuki.yujinrobot.com/home-en/documentation/howtos/upgrading-firmware");
323  sig_warn.emit("Robot firmware version is " + VersionInfo::toString(firmware.data.version)
324  + "; latest version is " + firmware.current_version());
325  }
326  else if (version_match > 0) {
327  // Driver version is outdated; maybe we should also suggest to upgrade it, but this is not a typical case
328  }
329  }
330  }
331  catch (std::out_of_range& e)
332  {
333  // Wrong version hardcoded on firmware; lowest value is 10000
334  sig_error.emit(std::string("Invalid firmware version number: ").append(e.what()));
335  shutdown_requested = true;
336  }
337  break;
342  sig_info.emit("Version info - Hardware: " + VersionInfo::toString(hardware.data.version)
343  + ". Firmware: " + VersionInfo::toString(firmware.data.version));
345  break;
348  sig_controller_info.emit();
350  break;
351  default: // in the case of unknown or mal-formed sub-payload
353  break;
354  }
355  }
356  //std::cout << "---" << std::endl;
358 
359  is_alive = true;
361  last_signal_time.stamp();
362  sig_stream_data.emit();
363  sendBaseControlCommand(); // send the command packet to mainboard;
366  }
367  else
368  {
369  // watchdog
370  if (is_alive && ((ecl::TimeStamp() - last_signal_time) > timeout))
371  {
372  is_alive = false;
373  // do not call here the event manager update, as it generates a spurious offline state
374  }
375  }
376  }
377  sig_error.emit("Driver worker thread shutdown!");
378 }
379 
380 void Kobuki::fixPayload(ecl::PushAndPop<unsigned char> & byteStream)
381 {
382  if (byteStream.size() < 3 ) { /* minimum size of sub-payload is 3; header_id, length, data */
383  sig_named.emit(log("error", "packet", "too small sub-payload detected."));
384  byteStream.clear();
385  } else {
386  std::stringstream ostream;
387  unsigned int header_id = static_cast<unsigned int>(byteStream.pop_front());
388  unsigned int length = static_cast<unsigned int>(byteStream.pop_front());
389  unsigned int remains = byteStream.size();
390  unsigned int to_pop;
391 
392  ostream << "[" << header_id << "]";
393  ostream << "[" << length << "]";
394 
395  ostream << "[";
396  ostream << std::setfill('0') << std::uppercase;
397  ostream << std::hex << std::setw(2) << header_id << " " << std::dec;
398  ostream << std::hex << std::setw(2) << length << " " << std::dec;
399 
400  if (remains < length) to_pop = remains;
401  else to_pop = length;
402 
403  for (unsigned int i = 0; i < to_pop; i++ ) {
404  unsigned int byte = static_cast<unsigned int>(byteStream.pop_front());
405  ostream << std::hex << std::setw(2) << byte << " " << std::dec;
406  }
407  ostream << "]";
408 
409  if (remains < length) sig_named.emit(log("error", "packet", "malformed sub-payload detected. " + ostream.str()));
410  else sig_named.emit(log("debug", "packet", "unknown sub-payload detected. " + ostream.str()));
411  }
412 }
413 
414 
415 /*****************************************************************************
416  ** Implementation [Human Friendly Accessors]
417  *****************************************************************************/
418 
419 ecl::Angle<double> Kobuki::getHeading() const
420 {
421  ecl::Angle<double> heading;
422  // raw data angles are in hundredths of a degree, convert to radians.
423  heading = (static_cast<double>(inertia.data.angle) / 100.0) * ecl::pi / 180.0;
424  return ecl::wrap_angle(heading - heading_offset);
425 }
426 
428 {
429  // raw data angles are in hundredths of a degree, convert to radians.
430  return (static_cast<double>(inertia.data.angle_rate) / 100.0) * ecl::pi / 180.0;
431 }
432 
433 /*****************************************************************************
434  ** Implementation [Raw Data Accessors]
435  *****************************************************************************/
436 
438 {
439  diff_drive.reset();
440 
441  // Issue #274: use current imu reading as zero heading to emulate reseting gyro
442  heading_offset = (static_cast<double>(inertia.data.angle) / 100.0) * ecl::pi / 180.0;
443 }
444 
445 void Kobuki::getWheelJointStates(double &wheel_left_angle, double &wheel_left_angle_rate, double &wheel_right_angle,
446  double &wheel_right_angle_rate)
447 {
448  diff_drive.getWheelJointStates(wheel_left_angle, wheel_left_angle_rate, wheel_right_angle, wheel_right_angle_rate);
449 }
450 
462 void Kobuki::updateOdometry(ecl::LegacyPose2D<double> &pose_update, ecl::linear_algebra::Vector3d &pose_update_rates)
463 {
465  pose_update, pose_update_rates);
466 }
467 
468 /*****************************************************************************
469  ** Commands
470  *****************************************************************************/
471 
472 void Kobuki::setLed(const enum LedNumber &number, const enum LedColour &colour)
473 {
475 }
476 
477 void Kobuki::setDigitalOutput(const DigitalOutput &digital_output) {
479 }
480 
481 void Kobuki::setExternalPower(const DigitalOutput &digital_output) {
483 }
484 
485 //void Kobuki::playSound(const enum Sounds &number)
486 //{
487 // sendCommand(Command::PlaySound(number, kobuki_command.data));
488 //}
489 
491 {
493 }
494 
495 bool Kobuki::setControllerGain(const unsigned char &type, const unsigned int &p_gain,
496  const unsigned int &i_gain, const unsigned int &d_gain)
497 {
499  sig_warn.emit("Robot firmware doesn't support this function, so you must upgrade it. " \
500  "Consult how-to on: http://kobuki.yujinrobot.com/home-en/documentation/howtos/upgrading-firmware");
501  sig_warn.emit("Robot firmware version is " + VersionInfo::toString(firmware.data.version)
502  + "; latest version is " + firmware.current_version());
503  return false;
504  }
505 
506  sendCommand(Command::SetControllerGain(type, p_gain, i_gain, d_gain));
507  return true;
508 }
509 
511 {
513  sig_warn.emit("Robot firmware doesn't support this function, so you must upgrade it. " \
514  "Consult how-to on: http://kobuki.yujinrobot.com/home-en/documentation/howtos/upgrading-firmware");
515  sig_warn.emit("Robot firmware version is " + VersionInfo::toString(firmware.data.version)
516  + "; latest version is " + firmware.current_version());
517  return false;
518  }
519 
521  return true;
522 }
523 
524 void Kobuki::setBaseControl(const double &linear_velocity, const double &angular_velocity)
525 {
526  diff_drive.setVelocityCommands(linear_velocity, angular_velocity);
527 }
528 
530 {
531  std::vector<double> velocity_commands_received;
533  velocity_commands_received=acceleration_limiter.limit(diff_drive.pointVelocity());
534  } else {
535  velocity_commands_received=diff_drive.pointVelocity();
536  }
537  diff_drive.velocityCommands(velocity_commands_received);
538  std::vector<short> velocity_commands = diff_drive.velocityCommands();
539  //std::cout << "speed: " << velocity_commands[0] << ", radius: " << velocity_commands[1] << std::endl;
540  sendCommand(Command::SetVelocityControl(velocity_commands[0], velocity_commands[1]));
541 
542  //experimental; send raw control command and received command velocity
543  velocity_commands_debug=velocity_commands;
544  velocity_commands_debug.push_back((short)(velocity_commands_received[0]*1000.0));
545  velocity_commands_debug.push_back((short)(velocity_commands_received[1]*1000.0));
547 }
548 
560 {
561  if( !is_alive || !is_connected ) {
562  //need to do something
563  sig_debug.emit("Device state is not ready yet.");
564  if( !is_alive ) sig_debug.emit(" - Device is not alive.");
565  if( !is_connected ) sig_debug.emit(" - Device is not connected.");
566  //std::cout << is_enabled << ", " << is_alive << ", " << is_connected << std::endl;
567  return;
568  }
569  command_mutex.lock();
571 
572  if (!command.serialise(command_buffer))
573  {
574  sig_error.emit("command serialise failed.");
575  }
576  command_buffer[2] = command_buffer.size() - 3;
577  unsigned char checksum = 0;
578  for (unsigned int i = 2; i < command_buffer.size(); i++)
579  checksum ^= (command_buffer[i]);
580 
581  command_buffer.push_back(checksum);
582  //check_device();
583  serial.write((const char*)&command_buffer[0], command_buffer.size());
584 
586  command_mutex.unlock();
587 }
588 
590 {
591  is_enabled = true;
592  return true;
593 }
594 
596 {
597  setBaseControl(0.0f, 0.0f);
599  is_enabled = false;
600  return true;
601 }
602 
612 
613  std::cout << "========== Void ==========" << std::endl;
614  ecl::SigSlotsManager<>::printStatistics();
615  std::cout << "========= String =========" << std::endl;
616  ecl::SigSlotsManager<const std::string&>::printStatistics();
617  std::cout << "====== Button Event ======" << std::endl;
618  ecl::SigSlotsManager<const ButtonEvent&>::printStatistics();
619  std::cout << "====== Bumper Event ======" << std::endl;
620  ecl::SigSlotsManager<const BumperEvent&>::printStatistics();
621  std::cout << "====== Cliff Event =======" << std::endl;
622  ecl::SigSlotsManager<const CliffEvent&>::printStatistics();
623  std::cout << "====== Wheel Event =======" << std::endl;
624  ecl::SigSlotsManager<const WheelEvent&>::printStatistics();
625  std::cout << "====== Power Event =======" << std::endl;
626  ecl::SigSlotsManager<const PowerEvent&>::printStatistics();
627  std::cout << "====== Input Event =======" << std::endl;
628  ecl::SigSlotsManager<const InputEvent&>::printStatistics();
629  std::cout << "====== Robot Event =======" << std::endl;
630  ecl::SigSlotsManager<const RobotEvent&>::printStatistics();
631  std::cout << "====== VersionInfo =======" << std::endl;
632  ecl::SigSlotsManager<const VersionInfo&>::printStatistics();
633  std::cout << "===== Command Buffer =====" << std::endl;
634  ecl::SigSlotsManager<const Command::Buffer&>::printStatistics();
635 }
636 
637 } // namespace kobuki
std::vector< std::string > log(std::string msg)
Definition: kobuki.hpp:244
ecl::Signal< PacketFinder::BufferType & > sig_raw_data_stream
Definition: kobuki.hpp:262
SoundSequences
Definition: sound.hpp:30
struct kobuki::Cliff::Data data
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: hardware.hpp:52
ControllerInfo controller_info
Definition: kobuki.hpp:212
AccelerationLimiter acceleration_limiter
Definition: kobuki.hpp:197
void configure(const std::string &sigslots_namespace, const BufferType &putStx, const BufferType &putEtx, unsigned int sizeLengthField, unsigned int sizeMaxPayload, unsigned int sizeChecksumField, bool variableSizePayload)
void sendCommand(Command command)
Send the prepared command to the serial port.
Definition: kobuki.cpp:559
EventManager event_manager
Definition: kobuki.hpp:239
static Command SetControllerGain(const unsigned char &type, const unsigned int &p_gain, const unsigned int &i_gain, const unsigned int &d_gain)
Definition: command.cpp:176
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: gp_input.hpp:66
void unlockDataAccess()
Definition: kobuki.cpp:164
static double low
Definition: battery.hpp:65
void fixPayload(ecl::PushAndPop< unsigned char > &byteStream)
Definition: kobuki.cpp:380
Current current
Definition: kobuki.hpp:206
double battery_low
Threshold for battery level warnings [14.0V].
Definition: parameters.hpp:59
Command::Buffer command_buffer
Definition: kobuki.hpp:233
ecl::Thread thread
Definition: kobuki.hpp:174
bool setControllerGain(const unsigned char &type, const unsigned int &p_gain, const unsigned int &i_gain, const unsigned int &d_gain)
Definition: kobuki.cpp:495
DiffDrive diff_drive
Definition: kobuki.hpp:180
ecl::Signal< const std::string & > sig_info
Definition: kobuki.hpp:259
bool enable()
Definition: kobuki.cpp:589
bool is_enabled
Definition: kobuki.hpp:181
int controller_info_reminder
Definition: kobuki.hpp:220
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Firmware firmware
Definition: kobuki.hpp:209
ecl::Serial serial
Definition: kobuki.hpp:214
bool validate()
A validator to ensure the user has supplied correct/sensible parameter values.
Definition: parameters.hpp:74
struct kobuki::CoreSensors::Data data
std::string current_version()
Definition: firmware.hpp:106
ecl::Signal< const std::vector< short > & > sig_raw_control_command
Definition: kobuki.hpp:263
ecl::PushAndPop< unsigned char > BufferType
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Command kobuki_command
Definition: kobuki.hpp:232
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: dock_ir.hpp:53
ecl::Signal< const VersionInfo & > sig_version_info
Definition: kobuki.hpp:258
std::string device_port
The serial device port name [/dev/kobuki].
Definition: parameters.hpp:54
void getWheelJointStates(double &wheel_left_angle, double &wheel_left_angle_rate, double &wheel_right_angle, double &wheel_right_angle_rate)
Definition: kobuki.cpp:445
struct kobuki::UniqueDeviceID::Data data
std::vector< uint16_t > bottom
Definition: cliff.hpp:42
ecl::Signal< const std::string & > sig_error
Definition: kobuki.hpp:259
double battery_dangerous
Threshold for battery level in danger of depletion [13.2V].
Definition: parameters.hpp:60
bool shutdown_requested
Definition: kobuki.hpp:175
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: cliff.hpp:55
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/kobuki"].
Definition: parameters.hpp:55
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
void update(const CoreSensors::Data &new_state, const std::vector< uint16_t > &cliff_data)
struct kobuki::Inertia::Data data
Inertia inertia
Definition: kobuki.hpp:203
ecl::Signal< const std::string & > sig_debug
Definition: kobuki.hpp:259
void resetOdometry()
Definition: kobuki.cpp:437
void sendBaseControlCommand()
Definition: kobuki.cpp:529
int check_major_version()
Definition: firmware.hpp:128
static Command SetLedArray(const enum LedNumber &number, const enum LedColour &colour, Command::Data &current_data)
Definition: command.cpp:53
void getBuffer(BufferType &bufferRef)
void setLed(const enum LedNumber &number, const enum LedColour &colour)
Definition: kobuki.cpp:472
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: inertia.hpp:58
int check_minor_version()
Definition: firmware.hpp:136
static std::string toString(const uint32_t &version)
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: current.hpp:57
UniqueDeviceID unique_device_id
Definition: kobuki.hpp:210
struct kobuki::Firmware::Data data
void setExternalPower(const DigitalOutput &digital_output)
Definition: kobuki.cpp:481
ecl::Angle< double > getHeading() const
Definition: kobuki.cpp:419
int flashed_major_version()
Definition: firmware.hpp:125
ecl::Signal< Command::Buffer & > sig_raw_data_command
Definition: kobuki.hpp:261
void playSoundSequence(const enum SoundSequences &number)
Definition: kobuki.cpp:490
Parameter list and validator for the kobuki.
Definition: parameters.hpp:36
void init(Parameters &parameters)
Definition: kobuki.cpp:74
bool getControllerGain()
Definition: kobuki.cpp:510
double heading_offset
Definition: kobuki.hpp:186
double getAngularVelocity() const
Definition: kobuki.cpp:427
std::vector< double > limit(const std::vector< double > &command)
Limits the input velocity commands if gatekeeper is enabled.
void setDigitalOutput(const DigitalOutput &digital_output)
Definition: kobuki.cpp:477
void getWheelJointStates(double &wheel_left_angle, double &wheel_left_angle_rate, double &wheel_right_angle, double &wheel_right_angle_rate)
Definition: diff_drive.cpp:114
static Command SetDigitalOutput(const DigitalOutput &digital_output, Command::Data &current_data)
Definition: command.cpp:84
int version_info_reminder
Definition: kobuki.hpp:219
void velocityCommands(const double &vx, const double &wz)
Definition: diff_drive.cpp:133
int flashed_minor_version()
Definition: firmware.hpp:126
DockIR dock_ir
Definition: kobuki.hpp:204
static Command SetVelocityControl(DiffDrive &diff_drive)
Definition: command.cpp:157
ecl::Mutex data_mutex
Definition: kobuki.hpp:231
Parameters parameters
Definition: kobuki.hpp:191
void updateOdometry(ecl::LegacyPose2D< 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: kobuki.cpp:462
ThreeAxisGyro three_axis_gyro
Definition: kobuki.hpp:211
Hardware hardware
Definition: kobuki.hpp:208
void setBaseControl(const double &linear_velocity, const double &angular_velocity)
Definition: kobuki.cpp:524
CoreSensors core_sensors
Definition: kobuki.hpp:202
ecl::Mutex command_mutex
Definition: kobuki.hpp:227
bool disable()
Definition: kobuki.cpp:595
std::vector< double > pointVelocity() const
Definition: diff_drive.cpp:183
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: firmware.hpp:60
void resetBuffer(Buffer &buffer)
Definition: command.cpp:202
unsigned int numberOfDataToRead()
GpInput gp_input
Definition: kobuki.hpp:207
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
ecl::Signal sig_controller_info
Definition: kobuki.hpp:257
static double capacity
Definition: battery.hpp:64
ecl::Signal< const std::string & > sig_warn
Definition: kobuki.hpp:259
void update(const uint16_t &time_stamp, const uint16_t &left_encoder, const uint16_t &right_encoder, ecl::LegacyPose2D< double > &pose_update, ecl::linear_algebra::Vector3d &pose_update_rates)
Updates the odometry from firmware stamps and encoders.
Definition: diff_drive.cpp:52
static double dangerous
Definition: battery.hpp:66
void getPayload(BufferType &bufferRef)
double battery_capacity
Capacity voltage of the battery [16.5V].
Definition: parameters.hpp:58
void printSigSlotConnections() const
Print a list of all relevant sigslot connections.
Definition: kobuki.cpp:611
static Command GetVersionInfo()
Definition: command.cpp:146
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: command.cpp:210
uint16_t digital_input
Definition: gp_input.hpp:41
virtual bool update(const unsigned char *incoming, unsigned int numberOfIncoming)
ecl::Signal< const std::vector< std::string > & > sig_named
Definition: kobuki.hpp:260
PacketFinder packet_finder
Definition: kobuki.hpp:215
static Command PlaySoundSequence(const enum SoundSequences &number, Command::Data &current_data)
Definition: command.cpp:135
void init(const std::string &sigslots_namespace)
static Command GetControllerGain()
Definition: command.cpp:188
bool is_connected
Definition: kobuki.hpp:192
struct kobuki::Hardware::Data data
void spin()
Performs a scan looking for incoming data packets.
Definition: kobuki.cpp:177
struct kobuki::GpInput::Data data
bool enable_acceleration_limiter
Enable or disable the acceleration limiter [true].
Definition: parameters.hpp:57
void lockDataAccess()
Definition: kobuki.cpp:156
void init(bool enable_acceleration_limiter, double linear_acceleration_max_=0.5, double angular_acceleration_max_=3.5, double linear_deceleration_max_=-0.5 *1.2, double angular_deceleration_max_=-3.5 *1.2)
std::vector< short > velocity_commands_debug
Definition: kobuki.hpp:234
static Command SetExternalPower(const DigitalOutput &digital_output, Command::Data &current_data)
Definition: command.cpp:115
void setVelocityCommands(const double &vx, const double &wz)
Definition: diff_drive.cpp:124
ecl::Signal sig_stream_data
Definition: kobuki.hpp:257
PacketFinder::BufferType data_buffer
Definition: kobuki.hpp:216


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Mar 27 2017 01:02:59