Go to the documentation of this file.
22 #include "../../include/kobuki_driver/kobuki.hpp"
23 #include "../../include/kobuki_driver/packet_handler/payload_headers.hpp"
40 for (
unsigned int i = 2; i < packet_size; i++)
44 return cs ? false :
true;
52 shutdown_requested(false)
54 , heading_offset(0.0/0.0)
57 , version_info_reminder(0)
58 , controller_info_reminder(0)
59 , velocity_commands_debug(4, 0)
108 sig_warn.
emit(
"device does not (yet) available, is the usb connected?.");
179 ecl::TimeStamp last_signal_time;
181 unsigned char buf[256];
203 sig_info.
emit(
"device does not (yet) available on this port, waiting...");
205 sig_info.
emit(
"device failed to open, waiting... [" + std::string(e.
what()) +
"]");
223 if (
is_alive && ((ecl::TimeStamp() - last_signal_time) > timeout))
228 sig_debug.
emit(
"Timed out while waiting for incoming bytes.");
235 std::ostringstream ostream;
236 ostream <<
"kobuki_node : serial_read(" << n <<
")"
300 if (version_match < 0) {
301 sig_error.
emit(
"This software is incompatible with Kobuki's firmware.");
302 sig_error.
emit(
"You need to upgrade your firmware. For more information,");
303 sig_error.
emit(
"refer to https://kobuki.readthedocs.io/en/devel/firmware.html.");
309 else if (version_match > 0) {
310 sig_error.
emit(
"This software is incompatible with Kobuki's firmware.");
311 sig_error.
emit(
"You need to upgrade your software. For more information,");
312 sig_error.
emit(
"refer to https://kobuki.readthedocs.io/en/devel/firmware.html.");
322 if (version_match < 0) {
323 sig_warn.
emit(
"The firmware does not match any of the recommended versions for this software.");
324 sig_warn.
emit(
"Consider replacing the firmware. For more information,");
325 sig_warn.
emit(
"refer to https://kobuki.readthedocs.io/en/devel/firmware.html.");
329 else if (version_match > 0) {
330 sig_warn.
emit(
"This software is significantly behind the latest firmware.");
331 sig_warn.
emit(
"Please upgrade your software. For more information,");
332 sig_warn.
emit(
"refer to https://kobuki.readthedocs.io/en/devel/firmware.html.");
338 catch (std::out_of_range& e)
341 sig_error.
emit(std::string(
"Invalid firmware version number: ").append(e.what()));
368 last_signal_time.stamp();
377 if (
is_alive && ((ecl::TimeStamp() - last_signal_time) > timeout))
389 if (byteStream.
size() < 3 ) {
393 std::stringstream ostream;
394 unsigned int header_id =
static_cast<unsigned int>(byteStream.
pop_front());
395 unsigned int length =
static_cast<unsigned int>(byteStream.
pop_front());
396 unsigned int remains = byteStream.
size();
399 ostream <<
"[" << header_id <<
"]";
400 ostream <<
"[" << length <<
"]";
403 ostream << std::setfill(
'0') << std::uppercase;
404 ostream << std::hex << std::setw(2) << header_id <<
" " << std::dec;
405 ostream << std::hex << std::setw(2) << length <<
" " << std::dec;
407 if (remains < length) to_pop = remains;
408 else to_pop = length;
410 for (
unsigned int i = 0; i < to_pop; i++ ) {
411 unsigned int byte =
static_cast<unsigned int>(byteStream.
pop_front());
412 ostream << std::hex << std::setw(2) <<
byte <<
" " << std::dec;
416 if (remains < length)
sig_named.
emit(
log(
"error",
"packet",
"malformed sub-payload detected. " + ostream.str()));
417 else sig_named.
emit(
log(
"debug",
"packet",
"unknown sub-payload detected. " + ostream.str()));
453 double &wheel_right_angle_rate)
472 pose_update, pose_update_rates);
503 const unsigned int &i_gain,
const unsigned int &d_gain)
506 sig_warn.
emit(
"Your robot firmware will need to be upgraded to get/set of PID gains." \
507 "Refer to https://kobuki.readthedocs.io/en/devel/firmware.html.");
509 +
". You will need at least 1.2.x");
520 sig_warn.
emit(
"Your robot firmware will need to be upgraded to get/set PID gains." \
521 "Refer to https://kobuki.readthedocs.io/en/devel/firmware.html.");
523 +
". You will need at least 1.2.x");
538 std::vector<double> velocity_commands_received;
584 unsigned char checksum = 0;
620 std::cout <<
"========== Void ==========" << std::endl;
622 std::cout <<
"========= String =========" << std::endl;
624 std::cout <<
"====== Button Event ======" << std::endl;
626 std::cout <<
"====== Bumper Event ======" << std::endl;
628 std::cout <<
"====== Cliff Event =======" << std::endl;
630 std::cout <<
"====== Wheel Event =======" << std::endl;
632 std::cout <<
"====== Power Event =======" << std::endl;
634 std::cout <<
"====== Input Event =======" << std::endl;
636 std::cout <<
"====== Robot Event =======" << std::endl;
638 std::cout <<
"====== VersionInfo =======" << std::endl;
640 std::cout <<
"===== Command Buffer =====" << std::endl;
ecl::Signal< const std::string & > sig_error
void connect(const std::string &topic)
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/kobuki"].
ecl::Signal< PacketFinder::BufferType & > sig_raw_data_stream
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
void setLed(const enum LedNumber &number, const enum LedColour &colour)
void getWheelJointStates(double &wheel_left_angle, double &wheel_left_angle_rate, double &wheel_right_angle, double &wheel_right_angle_rate)
ecl::Angle< double > getHeading() const
void update(const CoreSensors::Data &new_state, const std::vector< uint16_t > &cliff_data)
static void printStatistics()
ecl::PushAndPop< unsigned char > BufferType
void getPayload(BufferType &bufferRef)
static const std::vector< uint32_t > RECOMMENDED_VERSIONS
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
bool enable_acceleration_limiter
Enable or disable the acceleration limiter [true].
std::vector< uint16_t > bottom
AccelerationLimiter acceleration_limiter
struct kobuki::UniqueDeviceID::Data data
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
static Command SetDigitalOutput(const DigitalOutput &digital_output, Command::Data ¤t_data)
bool setControllerGain(const unsigned char &type, const unsigned int &p_gain, const unsigned int &i_gain, const unsigned int &d_gain)
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)
ecl::Signal< const std::string & > sig_debug
void fixPayload(ecl::PushAndPop< unsigned char > &byteStream)
void velocityCommands(const double &vx, const double &wz)
int version_info_reminder
static std::string toString(const uint32_t &version)
static Command GetVersionInfo()
void getWheelJointStates(double &wheel_left_angle, double &wheel_left_angle_rate, double &wheel_right_angle, double &wheel_right_angle_rate)
void printSigSlotConnections() const
Print a list of all relevant sigslot connections.
void init(Parameters ¶meters)
std::vector< short > velocity_commands_debug
const uint32_t & version() const
ecl::Signal sig_controller_info
void push_back(const Type &datum)
ecl_geometry_PUBLIC double wrap_angle(const double &angle)
struct kobuki::CoreSensors::Data data
void init(const std::string &sigslots_namespace)
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
static Command SetLedArray(const enum LedNumber &number, const enum LedColour &colour, Command::Data ¤t_data)
UniqueDeviceID unique_device_id
void setVelocityCommands(const double &vx, const double &wz)
PacketFinder::BufferType data_buffer
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.
Command::Buffer command_buffer
void setDigitalOutput(const DigitalOutput &digital_output)
ecl::Signal< const std::string & > sig_info
ecl::Signal< const VersionInfo & > sig_version_info
void setExternalPower(const DigitalOutput &digital_output)
int checkMajorVersion() const
static Command SetExternalPower(const DigitalOutput &digital_output, Command::Data ¤t_data)
virtual bool update(const unsigned char *incoming, unsigned int numberOfIncoming)
std::vector< double > pointVelocity() const
static Command PlaySoundSequence(const enum SoundSequences &number, Command::Data ¤t_data)
void spin()
Performs a scan looking for incoming data packets.
struct kobuki::Hardware::Data data
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Parameter list and validator for the kobuki.
ControllerInfo controller_info
ecl::Signal< const std::vector< short > & > sig_raw_control_command
void playSoundSequence(const enum SoundSequences &number)
bool validate()
A validator to ensure the user has supplied correct/sensible parameter values.
std::vector< double > limit(const std::vector< double > &command)
Limits the input velocity commands if gatekeeper is enabled.
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
int controller_info_reminder
ecl::Signal< const std::vector< std::string > & > sig_named
void configure(const std::string &sigslots_namespace, const BufferType &putStx, const BufferType &putEtx, unsigned int sizeLengthField, unsigned int sizeMaxPayload, unsigned int sizeChecksumField, bool variableSizePayload)
struct kobuki::Inertia::Data data
static Command SetVelocityControl(DiffDrive &diff_drive)
double getAngularVelocity() const
const char * what() const
void getBuffer(BufferType &bufferRef)
struct kobuki::Cliff::Data data
void resetBuffer(Buffer &buffer)
unsigned int numberOfDataToRead()
void setBaseControl(const double &linear_velocity, const double &angular_velocity)
static Command SetControllerGain(const unsigned char &type, const unsigned int &p_gain, const unsigned int &i_gain, const unsigned int &d_gain)
double battery_dangerous
Threshold for battery level in danger of depletion [13.2V].
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
PacketFinder packet_finder
ThreeAxisGyro three_axis_gyro
ecl::Signal sig_stream_data
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
double battery_low
Threshold for battery level warnings [14.0V].
int checkRecommendedVersion() const
EventManager event_manager
void sendCommand(Command command)
Send the prepared command to the serial port.
ecl::Signal< Command::Buffer & > sig_raw_data_command
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.
unsigned int size() const
std::string device_port
The serial device port name [/dev/kobuki].
ecl::Signal< const std::string & > sig_warn
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
static Command GetControllerGain()
double battery_capacity
Capacity voltage of the battery [16.5V].
std::vector< std::string > log(std::string msg)
void sendBaseControlCommand()
kobuki_driver
Author(s): Daniel Stonier
, Younghun Ju , Jorge Santos Simon
autogenerated on Wed Mar 2 2022 00:26:14