sigslots.cpp
Go to the documentation of this file.
1 
6 /*****************************************************************************
7 ** Includes
8 *****************************************************************************/
9 
10 #include <ecl/time.hpp>
11 #include <ecl/sigslots.hpp>
12 #include <iostream>
13 #include <kobuki_driver/kobuki.hpp>
14 
15 /*****************************************************************************
16 ** Classes
17 *****************************************************************************/
18 
19 class KobukiManager {
20 public:
21  KobukiManager() :
22  slot_stream_data(&KobukiManager::processStreamData, *this) // establish the callback
23  {
24  kobuki::Parameters parameters;
25  parameters.sigslots_namespace = "/mobile_base"; // configure the first part of the sigslot namespace
26  parameters.device_port = "/dev/kobuki"; // the serial port to connect to (windows COM1..)
27  // configure other parameters here
28  kobuki.init(parameters);
29  slot_stream_data.connect("/mobile_base/stream_data");
30  }
31 
32  void spin() {
33  ecl::Sleep sleep(1);
34  while ( true ) {
35  sleep();
36  }
37  }
38 
39  /*
40  * Called whenever the kobuki receives a data packet. Up to you from here to process it.
41  *
42  * Note that special processing is done for the various events which discretely change
43  * state (bumpers, cliffs etc) and updates for these are informed via the xxxEvent
44  * signals provided by the kobuki driver.
45  */
46  void processStreamData() {
47  kobuki::CoreSensors::Data data = kobuki.getCoreSensorData();
48  std::cout << "Encoders [" << data.left_encoder << "," << data.right_encoder << "]" << std::endl;
49  }
50 
51 private:
54 };
55 
56 /*****************************************************************************
57 ** Main
58 *****************************************************************************/
59 
60 int main() {
61  KobukiManager kobuki_manager;
62  kobuki_manager.spin();
63  return 0;
64 }
kobuki::Parameters::sigslots_namespace
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/kobuki"].
Definition: parameters.hpp:69
ecl::Slot
kobuki::CoreSensors::Data
Definition: core_sensors.hpp:54
kobuki
Definition: command.hpp:31
sigslots.hpp
KobukiManager::spin
void spin()
Worker thread loop; sends current velocity command at a fixed rate.
Definition: sigslots.cpp:36
kobuki::CoreSensors::Data::left_encoder
uint16_t left_encoder
Definition: core_sensors.hpp:59
KobukiManager::kobuki
kobuki::Kobuki kobuki
Definition: initialisation.cpp:42
KobukiManager
Keyboard remote control for our robot core (mobile base).
Definition: initialisation.cpp:14
main
int main()
Definition: sigslots.cpp:60
ecl::Slot::connect
void connect(const std::string &topic)
kobuki::Parameters
Parameter list and validator for the kobuki.
Definition: parameters.hpp:42
kobuki.hpp
Device driver core interface.
KobukiManager::processStreamData
void processStreamData()
Definition: sigslots.cpp:50
kobuki::Kobuki
The core kobuki driver class.
Definition: kobuki.hpp:95
KobukiManager::KobukiManager
KobukiManager()
Default constructor, needs initialisation.
Definition: initialisation.cpp:18
kobuki::CoreSensors::Data::right_encoder
uint16_t right_encoder
Definition: core_sensors.hpp:60
time.hpp
KobukiManager::slot_stream_data
ecl::Slot slot_stream_data
Definition: sigslots.cpp:57
kobuki::Parameters::device_port
std::string device_port
The serial device port name [/dev/kobuki].
Definition: parameters.hpp:68


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