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 <xbot_driver/xbot.hpp>
14 
15 /*****************************************************************************
16 ** Classes
17 *****************************************************************************/
18 
19 class XbotManager {
20 public:
22  slot_stream_data(&XbotManager::processStreamData, *this) // establish the callback
23  {
24  xbot::Parameters parameters;
25  parameters.sigslots_namespace = "/mobile_base"; // configure the first part of the sigslot namespace
26  parameters.base_port = "/dev/xbot"; // the serial port to connect to (windows COM1..)
27  // configure other parameters here
28  xbot.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 xbot 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 xbot driver.
45  */
47  xbot::CoreSensors::Data data = xbot.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  XbotManager xbot_manager;
62  xbot_manager.spin();
63  return 0;
64 }
std::string base_port
The serial device port name [/dev/xbot].
Definition: parameters.hpp:51
Parameter list and validator for the xbot.
Definition: parameters.hpp:35
void spin()
Worker thread loop; sends current velocity command at a fixed rate.
Definition: sigslots.cpp:32
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/xbot"].
Definition: parameters.hpp:53
xbot::Xbot xbot
EndOfLine endl
Device driver core interface.
Keyboard remote control for our robot core (mobile base).
ecl::Slot slot_stream_data
Definition: sigslots.cpp:53
void processStreamData()
Definition: sigslots.cpp:46
void connect(const std::string &topic)
int main()
Definition: sigslots.cpp:60
Definition: command.hpp:30
Function loading component of a callback system.
Definition: slot.hpp:48
The core xbot driver class.
Definition: xbot.hpp:86


xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:38