sigslots.cpp
Go to the documentation of this file.
00001 
00006 /*****************************************************************************
00007 ** Includes
00008 *****************************************************************************/
00009 
00010 #include <ecl/time.hpp>
00011 #include <ecl/sigslots.hpp>
00012 #include <iostream>
00013 #include <kobuki_driver/kobuki.hpp>
00014 
00015 /*****************************************************************************
00016 ** Classes
00017 *****************************************************************************/
00018 
00019 class KobukiManager {
00020 public:
00021   KobukiManager() :
00022       slot_stream_data(&KobukiManager::processStreamData, *this) // establish the callback
00023   {
00024     kobuki::Parameters parameters;
00025     parameters.sigslots_namespace = "/mobile_base"; // configure the first part of the sigslot namespace
00026     parameters.device_port = "/dev/kobuki";         // the serial port to connect to (windows COM1..)
00027     // configure other parameters here
00028     kobuki.init(parameters);
00029     slot_stream_data.connect("/mobile_base/stream_data");
00030   }
00031 
00032   void spin() {
00033     ecl::Sleep sleep(1);
00034     while ( true ) {
00035       sleep();
00036     }
00037   }
00038 
00039   /*
00040    * Called whenever the kobuki receives a data packet. Up to you from here to process it.
00041    *
00042    * Note that special processing is done for the various events which discretely change
00043    * state (bumpers, cliffs etc) and updates for these are informed via the xxxEvent
00044    * signals provided by the kobuki driver.
00045    */
00046   void processStreamData() {
00047     kobuki::CoreSensors::Data data = kobuki.getCoreSensorData();
00048     std::cout << "Encoders [" <<  data.left_encoder << "," << data.right_encoder << "]" << std::endl;
00049   }
00050 
00051 private:
00052   kobuki::Kobuki kobuki;
00053   ecl::Slot<> slot_stream_data;
00054 };
00055 
00056 /*****************************************************************************
00057 ** Main
00058 *****************************************************************************/
00059 
00060 int main() {
00061   KobukiManager kobuki_manager;
00062   kobuki_manager.spin();
00063   return 0;
00064 }


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Oct 6 2014 01:31:10