Go to the documentation of this file.00001
00008
00009
00010
00011
00012 #include <string>
00013 #include <ecl/time.hpp>
00014 #include <ecl/sigslots.hpp>
00015 #include <ecl/command_line.hpp>
00016 #include "kobuki_driver/kobuki.hpp"
00017
00018
00019
00020
00021
00022 class KobukiManager {
00023 public:
00024 KobukiManager(const std::string &device_port) :
00025 acquired(false),
00026 slot_version_info(&KobukiManager::processVersionInfo, *this)
00027 {
00028 kobuki::Parameters parameters;
00029 parameters.sigslots_namespace = "/kobuki";
00030 parameters.device_port = device_port;
00031 kobuki.init(parameters);
00032 kobuki.enable();
00033 slot_version_info.connect("/kobuki/version_info");
00034 }
00035
00036 ~KobukiManager() {
00037 kobuki.disable();
00038 }
00039
00040 void processVersionInfo(const kobuki::VersionInfo &version_info) {
00041 hardware = kobuki::VersionInfo::toString(version_info.hardware);
00042 firmware = kobuki::VersionInfo::toString(version_info.firmware);
00043
00044 software = kobuki::VersionInfo::getSoftwareVersion();
00045 udid = kobuki::VersionInfo::toString(version_info.udid0, version_info.udid1, version_info.udid2);
00046 acquired = true;
00047 }
00048
00049 bool isAcquired() { return acquired; }
00050 std::string& getHardwareVersion() { return hardware; }
00051 std::string& getFirmwareVersion() { return firmware; }
00052 std::string& getSoftwareVersion() { return software; }
00053 std::string& getUDID() { return udid; }
00054
00055 private:
00056 volatile bool acquired;
00057 kobuki::Kobuki kobuki;
00058 std::string hardware, firmware, software, udid;
00059 ecl::Slot<const kobuki::VersionInfo&> slot_version_info;
00060 };
00061
00062
00063
00064
00065
00066 int main(int argc, char** argv)
00067 {
00068 ecl::CmdLine cmd_line("version_info program", ' ', "0.2");
00069 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");
00070 cmd_line.add(device_port);
00071 cmd_line.parse(argc, argv);
00072
00073
00074 std::cout << "Version Info:" << std::endl;
00075 KobukiManager kobuki_manager(device_port.getValue());
00076
00077 while (!kobuki_manager.isAcquired());
00078 std::cout << " * Hardware Version: " << kobuki_manager.getHardwareVersion() << std::endl;
00079 std::cout << " * Firmware Version: " << kobuki_manager.getFirmwareVersion() << std::endl;
00080 std::cout << " * Software Version: " << kobuki_manager.getSoftwareVersion() << std::endl;
00081 std::cout << " * Unique Device ID: " << kobuki_manager.getUDID() << std::endl;
00082
00083 return 0;
00084 }