KITProstheticHandDriverExampleNoArmarX.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <thread>
3
4#include <QCoreApplication>
5
7
8[[maybe_unused]] static constexpr auto old = "DF:70:E8:81:DB:D6";
9[[maybe_unused]] static constexpr auto dlr = "DF:A2:F5:48:E7:50";
10[[maybe_unused]] static constexpr auto arches = "XX:XX:XX:XX:XX:XX";
11
12int
13main(int argc, char* argv[])
14{
15 for (int i = 0; i < argc; ++i)
16 {
17 if (std::string(argv[i]) == "-h" ||
18 std::string(argv[i]) == "--print-options") // needed for ArmarX Doc generation
19 {
20 // TODO: print help
21 return 0;
22 }
23 }
24 QCoreApplication a(argc, argv);
25 {
26 BLEProthesisInterface iface{dlr};
27 iface.verboseReceive(false);
28 iface.verboseSend(true);
29 std::size_t dcCounter = 0;
30 while (iface.getState() != BLEProthesisInterface::State::Running)
31 {
32 std::cout << "Waiting for Running State: " << to_string(iface.getState()) << std::endl;
33
34 if (iface.getState() == BLEProthesisInterface::State::Disconnected)
35 {
36 ++dcCounter;
37 }
38
39 if (dcCounter > 50)
40 {
41 return 1;
42 }
43
44 std::this_thread::sleep_for(std::chrono::milliseconds{100});
45 }
46
47 auto printAndSleep = [&](std::size_t n = 25)
48 {
49 for (std::size_t i2 = 0; i2 < n; ++i2)
50 {
51 std::cout << iface.getThumbPos() << "\t" << iface.getThumbPWM() << "\t"
52 << iface.getFingerPos() << "\t" << iface.getFingerPWM() << std::endl;
53 std::this_thread::sleep_for(std::chrono::milliseconds{100});
54 }
55 };
56
57 for (std::size_t i = 0; i < 4; ++i)
58 {
59 iface.sendGrasp(i % 2);
60 printAndSleep();
61 }
62 iface.sendThumbPWM(200, 2999, 0);
63 printAndSleep(1);
64 iface.sendFingerPWM(200, 2999, 0);
65 printAndSleep();
66 }
67 return 0;
68}
std::string to_string(BLEProthesisInterface::State s)