Public Member Functions | Private Member Functions | Private Attributes | List of all members
kobuki::Kobuki Class Reference

The core kobuki driver class. More...

#include <kobuki.hpp>

Public Member Functions

Battery batteryStatus () const
 
bool disable ()
 
bool enable ()
 
void fixPayload (ecl::PushAndPop< unsigned char > &byteStream)
 
double getAngularVelocity () const
 
Cliff::Data getCliffData () const
 
bool getControllerGain ()
 
ControllerInfo::Data getControllerInfoData () const
 
CoreSensors::Data getCoreSensorData () const
 
Current::Data getCurrentData () const
 
DockIR::Data getDockIRData () const
 
GpInput::Data getGpInputData () const
 
ecl::Angle< double > getHeading () const
 
Inertia::Data getInertiaData () const
 
ThreeAxisGyro::Data getRawInertiaData () const
 
void getWheelJointStates (double &wheel_left_angle, double &wheel_left_angle_rate, double &wheel_right_angle, double &wheel_right_angle_rate)
 
void init (Parameters &parameters)
 
 Kobuki ()
 
void lockDataAccess ()
 
void playSoundSequence (const enum SoundSequences &number)
 
void printSigSlotConnections () const
 Print a list of all relevant sigslot connections. More...
 
void resetOdometry ()
 
void setBaseControl (const double &linear_velocity, const double &angular_velocity)
 
bool setControllerGain (const unsigned char &type, const unsigned int &p_gain, const unsigned int &i_gain, const unsigned int &d_gain)
 
void setDigitalOutput (const DigitalOutput &digital_output)
 
void setExternalPower (const DigitalOutput &digital_output)
 
void setLed (const enum LedNumber &number, const enum LedColour &colour)
 
void spin ()
 Performs a scan looking for incoming data packets. More...
 
void unlockDataAccess ()
 
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. More...
 
VersionInfo versionInfo () const
 
 ~Kobuki ()
 

Private Member Functions

std::vector< std::string > log (std::string level, std::string msg)
 
std::vector< std::string > log (std::string level, std::string name, std::string msg)
 
std::vector< std::string > log (std::string msg)
 
void sendBaseControlCommand ()
 
void sendCommand (Command command)
 Send the prepared command to the serial port. More...
 

Private Attributes

AccelerationLimiter acceleration_limiter
 
Cliff cliff
 
Command::Buffer command_buffer
 
ecl::Mutex command_mutex
 
ControllerInfo controller_info
 
int controller_info_reminder
 
CoreSensors core_sensors
 
Current current
 
PacketFinder::BufferType data_buffer
 
ecl::Mutex data_mutex
 
DiffDrive diff_drive
 
DockIR dock_ir
 
EventManager event_manager
 
Firmware firmware
 
GpInput gp_input
 
Hardware hardware
 
double heading_offset
 
Inertia inertia
 
bool is_alive
 
bool is_connected
 
bool is_enabled
 
Command kobuki_command
 
PacketFinder packet_finder
 
Parameters parameters
 
ecl::Serial serial
 
bool shutdown_requested
 
ecl::Signal sig_controller_info
 
ecl::Signal< const std::string & > sig_debug
 
ecl::Signal< const std::string & > sig_error
 
ecl::Signal< const std::string & > sig_info
 
ecl::Signal< const std::vector< std::string > & > sig_named
 
ecl::Signal< const std::vector< short > & > sig_raw_control_command
 
ecl::Signal< Command::Buffer & > sig_raw_data_command
 
ecl::Signal< PacketFinder::BufferType & > sig_raw_data_stream
 
ecl::Signal sig_stream_data
 
ecl::Signal< const VersionInfo & > sig_version_info
 
ecl::Signal< const std::string & > sig_warn
 
ecl::Thread thread
 
ThreeAxisGyro three_axis_gyro
 
UniqueDeviceID unique_device_id
 
std::vector< short > velocity_commands_debug
 
int version_info_reminder
 

Detailed Description

The core kobuki driver class.

This connects to the outside world via sigslots and get accessors.

Definition at line 95 of file kobuki.hpp.

Constructor & Destructor Documentation

◆ Kobuki()

kobuki::Kobuki::Kobuki ( )

Definition at line 55 of file kobuki.cpp.

◆ ~Kobuki()

kobuki::Kobuki::~Kobuki ( )

Shutdown the driver - make sure we wait for the thread to finish.

Definition at line 70 of file kobuki.cpp.

Member Function Documentation

◆ batteryStatus()

Battery kobuki::Kobuki::batteryStatus ( ) const
inline

Definition at line 134 of file kobuki.hpp.

◆ disable()

bool kobuki::Kobuki::disable ( )

Disable power to the motors.

Definition at line 606 of file kobuki.cpp.

◆ enable()

bool kobuki::Kobuki::enable ( )

Enable power to the motors.

Definition at line 600 of file kobuki.cpp.

◆ fixPayload()

void kobuki::Kobuki::fixPayload ( ecl::PushAndPop< unsigned char > &  byteStream)

Definition at line 391 of file kobuki.cpp.

◆ getAngularVelocity()

double kobuki::Kobuki::getAngularVelocity ( ) const

Definition at line 438 of file kobuki.cpp.

◆ getCliffData()

Cliff::Data kobuki::Kobuki::getCliffData ( ) const
inline

Definition at line 143 of file kobuki.hpp.

◆ getControllerGain()

bool kobuki::Kobuki::getControllerGain ( )

Definition at line 521 of file kobuki.cpp.

◆ getControllerInfoData()

ControllerInfo::Data kobuki::Kobuki::getControllerInfoData ( ) const
inline

Definition at line 148 of file kobuki.hpp.

◆ getCoreSensorData()

CoreSensors::Data kobuki::Kobuki::getCoreSensorData ( ) const
inline

Definition at line 141 of file kobuki.hpp.

◆ getCurrentData()

Current::Data kobuki::Kobuki::getCurrentData ( ) const
inline

Definition at line 144 of file kobuki.hpp.

◆ getDockIRData()

DockIR::Data kobuki::Kobuki::getDockIRData ( ) const
inline

Definition at line 142 of file kobuki.hpp.

◆ getGpInputData()

GpInput::Data kobuki::Kobuki::getGpInputData ( ) const
inline

Definition at line 146 of file kobuki.hpp.

◆ getHeading()

ecl::Angle< double > kobuki::Kobuki::getHeading ( ) const

Definition at line 430 of file kobuki.cpp.

◆ getInertiaData()

Inertia::Data kobuki::Kobuki::getInertiaData ( ) const
inline

Definition at line 145 of file kobuki.hpp.

◆ getRawInertiaData()

ThreeAxisGyro::Data kobuki::Kobuki::getRawInertiaData ( ) const
inline

Definition at line 147 of file kobuki.hpp.

◆ getWheelJointStates()

void kobuki::Kobuki::getWheelJointStates ( double &  wheel_left_angle,
double &  wheel_left_angle_rate,
double &  wheel_right_angle,
double &  wheel_right_angle_rate 
)

Definition at line 456 of file kobuki.cpp.

◆ init()

void kobuki::Kobuki::init ( Parameters parameters)

Definition at line 78 of file kobuki.cpp.

◆ lockDataAccess()

void kobuki::Kobuki::lockDataAccess ( )

Usually you should call the getXXX functions from within slot callbacks connected to this driver's signals. This ensures that data is not overwritten inbetween getXXX calls as it all happens in the serial device's reading thread (aye, convoluted - apologies for the multiple robot and multiple developer adhoc hacking over 4-5 years for hasty demos on pre-kobuki robots. This has generated such wonderful spaghetti ;).

If instead you just want to poll kobuki, then you should lock and unlock the data access around any getXXX calls.

Definition at line 160 of file kobuki.cpp.

◆ log() [1/3]

std::vector<std::string> kobuki::Kobuki::log ( std::string  level,
std::string  msg 
)
inlineprivate

Definition at line 255 of file kobuki.hpp.

◆ log() [2/3]

std::vector<std::string> kobuki::Kobuki::log ( std::string  level,
std::string  name,
std::string  msg 
)
inlineprivate

Definition at line 256 of file kobuki.hpp.

◆ log() [3/3]

std::vector<std::string> kobuki::Kobuki::log ( std::string  msg)
inlineprivate

Definition at line 254 of file kobuki.hpp.

◆ playSoundSequence()

void kobuki::Kobuki::playSoundSequence ( const enum SoundSequences number)

Definition at line 501 of file kobuki.cpp.

◆ printSigSlotConnections()

void kobuki::Kobuki::printSigSlotConnections ( ) const

Print a list of all relevant sigslot connections.

This includes both the kobuki driver signals as well as externally connected slots. Useful for when you need to check if any of your connections are dangling (often happens when you typo the name of the sigslots connection).

Definition at line 622 of file kobuki.cpp.

◆ resetOdometry()

void kobuki::Kobuki::resetOdometry ( )

Definition at line 448 of file kobuki.cpp.

◆ sendBaseControlCommand()

void kobuki::Kobuki::sendBaseControlCommand ( )
private

Definition at line 540 of file kobuki.cpp.

◆ sendCommand()

void kobuki::Kobuki::sendCommand ( Command  command)
private

Send the prepared command to the serial port.

Need to be a bit careful here, because we have no control over how the user is calling this - they may be calling from different threads (this is so for kobuki_node), so we mutex protect it here rather than relying on the user to do so above.

Parameters
command: prepared command template (see Command's static member functions).

Definition at line 570 of file kobuki.cpp.

◆ setBaseControl()

void kobuki::Kobuki::setBaseControl ( const double &  linear_velocity,
const double &  angular_velocity 
)

Definition at line 535 of file kobuki.cpp.

◆ setControllerGain()

bool kobuki::Kobuki::setControllerGain ( const unsigned char &  type,
const unsigned int &  p_gain,
const unsigned int &  i_gain,
const unsigned int &  d_gain 
)

Definition at line 506 of file kobuki.cpp.

◆ setDigitalOutput()

void kobuki::Kobuki::setDigitalOutput ( const DigitalOutput digital_output)

Definition at line 488 of file kobuki.cpp.

◆ setExternalPower()

void kobuki::Kobuki::setExternalPower ( const DigitalOutput digital_output)

Definition at line 492 of file kobuki.cpp.

◆ setLed()

void kobuki::Kobuki::setLed ( const enum LedNumber number,
const enum LedColour colour 
)

Definition at line 483 of file kobuki.cpp.

◆ spin()

void kobuki::Kobuki::spin ( )

Performs a scan looking for incoming data packets.

Sits on the device waiting for incoming and then parses it, and signals that an update has occured.

Or, if in simulation, just loopsback the motor devices.

Definition at line 181 of file kobuki.cpp.

◆ unlockDataAccess()

void kobuki::Kobuki::unlockDataAccess ( )

Unlock a previously locked data access privilege.

See also
lockDataAccess()

Definition at line 168 of file kobuki.cpp.

◆ updateOdometry()

void kobuki::Kobuki::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.

This fuses current sensor data with the last updated odometry state to produce the new odometry state. This will be usually done in the slot callback to the stream_data signal.

It is important that this is called every time a data packet is received from the robot.

Parameters
pose_update: return the pose updates in this variable.
pose_update_rates: return the pose update rates in this variable.

Definition at line 473 of file kobuki.cpp.

◆ versionInfo()

VersionInfo kobuki::Kobuki::versionInfo ( ) const
inline

Definition at line 133 of file kobuki.hpp.

Member Data Documentation

◆ acceleration_limiter

AccelerationLimiter kobuki::Kobuki::acceleration_limiter
private

Definition at line 207 of file kobuki.hpp.

◆ cliff

Cliff kobuki::Kobuki::cliff
private

Definition at line 215 of file kobuki.hpp.

◆ command_buffer

Command::Buffer kobuki::Kobuki::command_buffer
private

Definition at line 243 of file kobuki.hpp.

◆ command_mutex

ecl::Mutex kobuki::Kobuki::command_mutex
private

Definition at line 237 of file kobuki.hpp.

◆ controller_info

ControllerInfo kobuki::Kobuki::controller_info
private

Definition at line 222 of file kobuki.hpp.

◆ controller_info_reminder

int kobuki::Kobuki::controller_info_reminder
private

Definition at line 230 of file kobuki.hpp.

◆ core_sensors

CoreSensors kobuki::Kobuki::core_sensors
private

Definition at line 212 of file kobuki.hpp.

◆ current

Current kobuki::Kobuki::current
private

Definition at line 216 of file kobuki.hpp.

◆ data_buffer

PacketFinder::BufferType kobuki::Kobuki::data_buffer
private

Definition at line 226 of file kobuki.hpp.

◆ data_mutex

ecl::Mutex kobuki::Kobuki::data_mutex
private

Definition at line 241 of file kobuki.hpp.

◆ diff_drive

DiffDrive kobuki::Kobuki::diff_drive
private

Definition at line 190 of file kobuki.hpp.

◆ dock_ir

DockIR kobuki::Kobuki::dock_ir
private

Definition at line 214 of file kobuki.hpp.

◆ event_manager

EventManager kobuki::Kobuki::event_manager
private

Definition at line 249 of file kobuki.hpp.

◆ firmware

Firmware kobuki::Kobuki::firmware
private

Definition at line 219 of file kobuki.hpp.

◆ gp_input

GpInput kobuki::Kobuki::gp_input
private

Definition at line 217 of file kobuki.hpp.

◆ hardware

Hardware kobuki::Kobuki::hardware
private

Definition at line 218 of file kobuki.hpp.

◆ heading_offset

double kobuki::Kobuki::heading_offset
private

Definition at line 196 of file kobuki.hpp.

◆ inertia

Inertia kobuki::Kobuki::inertia
private

Definition at line 213 of file kobuki.hpp.

◆ is_alive

bool kobuki::Kobuki::is_alive
private

Definition at line 227 of file kobuki.hpp.

◆ is_connected

bool kobuki::Kobuki::is_connected
private

Definition at line 202 of file kobuki.hpp.

◆ is_enabled

bool kobuki::Kobuki::is_enabled
private

Definition at line 191 of file kobuki.hpp.

◆ kobuki_command

Command kobuki::Kobuki::kobuki_command
private

Definition at line 242 of file kobuki.hpp.

◆ packet_finder

PacketFinder kobuki::Kobuki::packet_finder
private

Definition at line 225 of file kobuki.hpp.

◆ parameters

Parameters kobuki::Kobuki::parameters
private

Definition at line 201 of file kobuki.hpp.

◆ serial

ecl::Serial kobuki::Kobuki::serial
private

Definition at line 224 of file kobuki.hpp.

◆ shutdown_requested

bool kobuki::Kobuki::shutdown_requested
private

Definition at line 185 of file kobuki.hpp.

◆ sig_controller_info

ecl::Signal kobuki::Kobuki::sig_controller_info
private

Definition at line 267 of file kobuki.hpp.

◆ sig_debug

ecl::Signal<const std::string&> kobuki::Kobuki::sig_debug
private

Definition at line 269 of file kobuki.hpp.

◆ sig_error

ecl::Signal<const std::string&> kobuki::Kobuki::sig_error
private

Definition at line 269 of file kobuki.hpp.

◆ sig_info

ecl::Signal<const std::string&> kobuki::Kobuki::sig_info
private

Definition at line 269 of file kobuki.hpp.

◆ sig_named

ecl::Signal<const std::vector<std::string>&> kobuki::Kobuki::sig_named
private

Definition at line 270 of file kobuki.hpp.

◆ sig_raw_control_command

ecl::Signal<const std::vector<short>&> kobuki::Kobuki::sig_raw_control_command
private

Definition at line 273 of file kobuki.hpp.

◆ sig_raw_data_command

ecl::Signal<Command::Buffer&> kobuki::Kobuki::sig_raw_data_command
private

Definition at line 271 of file kobuki.hpp.

◆ sig_raw_data_stream

ecl::Signal<PacketFinder::BufferType&> kobuki::Kobuki::sig_raw_data_stream
private

Definition at line 272 of file kobuki.hpp.

◆ sig_stream_data

ecl::Signal kobuki::Kobuki::sig_stream_data
private

Definition at line 267 of file kobuki.hpp.

◆ sig_version_info

ecl::Signal<const VersionInfo&> kobuki::Kobuki::sig_version_info
private

Definition at line 268 of file kobuki.hpp.

◆ sig_warn

ecl::Signal<const std::string&> kobuki::Kobuki::sig_warn
private

Definition at line 269 of file kobuki.hpp.

◆ thread

ecl::Thread kobuki::Kobuki::thread
private

Definition at line 184 of file kobuki.hpp.

◆ three_axis_gyro

ThreeAxisGyro kobuki::Kobuki::three_axis_gyro
private

Definition at line 221 of file kobuki.hpp.

◆ unique_device_id

UniqueDeviceID kobuki::Kobuki::unique_device_id
private

Definition at line 220 of file kobuki.hpp.

◆ velocity_commands_debug

std::vector<short> kobuki::Kobuki::velocity_commands_debug
private

Definition at line 244 of file kobuki.hpp.

◆ version_info_reminder

int kobuki::Kobuki::version_info_reminder
private

Definition at line 229 of file kobuki.hpp.


The documentation for this class was generated from the following files:


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Wed Mar 2 2022 00:26:14