version_info.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9  * Includes
10  ****************************************************************************/
11 
12 #include <string>
13 #include <ecl/console.hpp>
14 #include <ecl/time.hpp>
15 #include <ecl/sigslots.hpp>
16 #include <ecl/command_line.hpp>
17 #include "kobuki_driver/kobuki.hpp"
18 
19 /*****************************************************************************
20 ** Classes
21 *****************************************************************************/
22 
23 class KobukiManager {
24 public:
25  KobukiManager(const std::string &device_port) :
26  acquired(false),
30  {
31  kobuki::Parameters parameters;
32  parameters.sigslots_namespace = "/kobuki"; // configure the first part of the sigslot namespace
33  parameters.device_port = device_port; // the serial port to connect to (windows COM1..)
34  kobuki.init(parameters);
35  slot_debug_warning.connect("/kobuki/ros_warn");
36  slot_debug_error.connect("/kobuki/ros_error");
37  slot_version_info.connect("/kobuki/version_info");
38  }
39 
41 
42  void processVersionInfo(const kobuki::VersionInfo &version_info) {
45  //software = kobuki::VersionInfo::toString(version_info.software);
47  udid = kobuki::VersionInfo::toString(version_info.udid0, version_info.udid1, version_info.udid2);
48  acquired = true;
49  }
50 
51  void relayWarnings(const std::string& message) {
52  std::cout << ecl::yellow << "[WARNING] " << message << ecl::reset << std::endl;
53  }
54 
55  void relayErrors(const std::string& message) {
56  std::cout << ecl::red << "[ERROR] " << message << ecl::reset << std::endl;
57  }
58 
59  bool isAcquired() { return acquired; }
60  std::string& getHardwareVersion() { return hardware; }
61  std::string& getFirmwareVersion() { return firmware; }
62  std::string& getSoftwareVersion() { return software; }
63  std::string& getUDID() { return udid; }
64 
65 private:
66  volatile bool acquired;
68  std::string hardware, firmware, software, udid;
71 };
72 
73 /*****************************************************************************
74 ** Main
75 *****************************************************************************/
76 
77 int main(int argc, char** argv)
78 {
79  ecl::CmdLine cmd_line("version_info program", ' ', "0.2");
80  ecl::UnlabeledValueArg<std::string> device_port("device_port", "Path to device file of serial port to open, connected to the kobuki", false, "/dev/kobuki", "string");
81  cmd_line.add(device_port);
82  cmd_line.parse(argc, argv);
83  //std::cout << "device_port: " << device_port.getValue() << std::endl;
84 
85  std::cout << "Version Info:" << std::endl;
86  KobukiManager kobuki_manager(device_port.getValue());
87 
88  ecl::MilliSleep sleep_one_hundred_ms(100);
89  while (!kobuki_manager.isAcquired()) { sleep_one_hundred_ms(); }
90  std::cout << " * Hardware Version: " << kobuki_manager.getHardwareVersion() << std::endl;
91  std::cout << " * Firmware Version: " << kobuki_manager.getFirmwareVersion() << std::endl;
92  std::cout << " * Software Version: " << kobuki_manager.getSoftwareVersion() << std::endl;
93  std::cout << " * Unique Device ID: " << kobuki_manager.getUDID() << std::endl;
94 
95  return 0;
96 }
const uint32_t udid0
const uint32_t udid2
KobukiManager(const std::string &device_port)
void processVersionInfo(const kobuki::VersionInfo &version_info)
ecl::Slot< const kobuki::VersionInfo & > slot_version_info
std::string & getFirmwareVersion()
const uint32_t hardware
const uint32_t firmware
std::string & getSoftwareVersion()
std::string device_port
The serial device port name [/dev/kobuki].
Definition: parameters.hpp:54
static std::string getSoftwareVersion()
std::string & getHardwareVersion()
void add(Arg &a)
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/kobuki"].
Definition: parameters.hpp:55
volatile bool acquired
Device driver core interface.
std::string software
kobuki::Kobuki kobuki
const uint32_t udid1
std::string udid
std::string hardware
static std::string toString(const uint32_t &version)
Parameter list and validator for the kobuki.
Definition: parameters.hpp:36
Keyboard remote control for our robot core (mobile base).
void relayErrors(const std::string &message)
ecl::Slot< const std::string & > slot_debug_error
int main(int argc, char **argv)
The core kobuki driver class.
Definition: kobuki.hpp:87
void connect(const std::string &topic)
void relayWarnings(const std::string &message)
std::string & getUDID()
void parse(int argc, char **argv)
ecl::Slot< const std::string & > slot_debug_warning
std::string firmware


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