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 
40  ~KobukiManager() {}
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 }
kobuki::Parameters::sigslots_namespace
std::string sigslots_namespace
The first part of a sigslot connection namespace ["/kobuki"].
Definition: parameters.hpp:69
KobukiManager::relayWarnings
void relayWarnings(const std::string &message)
Definition: simple_keyop.cpp:228
ecl::Slot< const std::string & >
KobukiManager::getSoftwareVersion
std::string & getSoftwareVersion()
Definition: version_info.cpp:66
KobukiManager::processVersionInfo
void processVersionInfo(const kobuki::VersionInfo &version_info)
Definition: version_info.cpp:46
kobuki
Definition: command.hpp:31
command_line.hpp
KobukiManager::hardware
std::string hardware
Definition: version_info.cpp:72
KobukiManager::udid
std::string udid
Definition: version_info.cpp:72
ecl::CmdLine
KobukiManager::slot_version_info
ecl::Slot< const kobuki::VersionInfo & > slot_version_info
Definition: version_info.cpp:74
sigslots.hpp
KobukiManager::slot_debug_warning
ecl::Slot< const std::string & > slot_debug_warning
Definition: simple_keyop.cpp:96
kobuki::VersionInfo::toString
static std::string toString(const uint32_t &version)
Definition: version_info.hpp:82
kobuki::VersionInfo::udid2
const uint32_t udid2
Definition: version_info.hpp:68
KobukiManager::acquired
volatile bool acquired
Definition: version_info.cpp:70
ecl::ValueArg::getValue
T & getValue()
kobuki::VersionInfo::hardware
const uint32_t hardware
Definition: version_info.hpp:64
KobukiManager::getHardwareVersion
std::string & getHardwareVersion()
Definition: version_info.cpp:64
ecl::CmdLine::add
void add(Arg &a)
console.hpp
KobukiManager::slot_debug_error
ecl::Slot< const std::string & > slot_debug_error
Definition: simple_keyop.cpp:96
main
int main(int argc, char **argv)
Definition: version_info.cpp:77
KobukiManager::kobuki
kobuki::Kobuki kobuki
Definition: initialisation.cpp:42
KobukiManager
Keyboard remote control for our robot core (mobile base).
Definition: initialisation.cpp:14
KobukiManager::getFirmwareVersion
std::string & getFirmwareVersion()
Definition: version_info.cpp:65
ecl::Slot::connect
void connect(const std::string &topic)
KobukiManager::isAcquired
bool isAcquired()
Definition: version_info.cpp:63
kobuki::VersionInfo::getSoftwareVersion
static std::string getSoftwareVersion()
kobuki::Parameters
Parameter list and validator for the kobuki.
Definition: parameters.hpp:42
kobuki.hpp
Device driver core interface.
KobukiManager::~KobukiManager
~KobukiManager()
Definition: simple_loop.cpp:43
kobuki::Kobuki
The core kobuki driver class.
Definition: kobuki.hpp:95
KobukiManager::software
std::string software
Definition: version_info.cpp:72
KobukiManager::KobukiManager
KobukiManager()
Default constructor, needs initialisation.
Definition: initialisation.cpp:18
time.hpp
ecl::UnlabeledValueArg
ecl::CmdLine::parse
void parse(int argc, char **argv)
KobukiManager::firmware
std::string firmware
Definition: version_info.cpp:72
kobuki::VersionInfo::udid0
const uint32_t udid0
Definition: version_info.hpp:66
kobuki::VersionInfo::firmware
const uint32_t firmware
Definition: version_info.hpp:63
KobukiManager::relayErrors
void relayErrors(const std::string &message)
Definition: simple_keyop.cpp:232
kobuki::VersionInfo::udid1
const uint32_t udid1
Definition: version_info.hpp:67
kobuki::Parameters::device_port
std::string device_port
The serial device port name [/dev/kobuki].
Definition: parameters.hpp:68
KobukiManager::getUDID
std::string & getUDID()
Definition: version_info.cpp:67
kobuki::VersionInfo
Definition: version_info.hpp:45


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