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:
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  */
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 }
std::string device_port
The serial device port name [/dev/kobuki].
Definition: parameters.hpp:54
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/kobuki"].
Definition: parameters.hpp:55
void spin()
Worker thread loop; sends current velocity command at a fixed rate.
Definition: sigslots.cpp:32
Device driver core interface.
kobuki::Kobuki kobuki
void processStreamData()
Definition: sigslots.cpp:46
Parameter list and validator for the kobuki.
Definition: parameters.hpp:36
Keyboard remote control for our robot core (mobile base).
The core kobuki driver class.
Definition: kobuki.hpp:87
void connect(const std::string &topic)
int main()
Definition: sigslots.cpp:60
ecl::Slot slot_stream_data
Definition: sigslots.cpp:53


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Fri Sep 18 2020 03:22:02