Revision 0c8d22a5 src/client/client.cpp
src/client/client.cpp | ||
---|---|---|
25 | 25 |
* Excellence Initiative. |
26 | 26 |
*/ |
27 | 27 |
|
28 |
#include "client/client.h" |
|
29 |
#include "client/middleware_ros.h" |
|
30 | 28 |
#include <boost/algorithm/string.hpp> |
29 |
#include <string> |
|
31 | 30 |
|
32 |
using namespace std; |
|
33 |
using namespace boost; |
|
34 |
using namespace humotion; |
|
35 |
using namespace humotion::client; |
|
31 |
#include "humotion/client/client.h" |
|
32 |
#include "humotion/client/middleware_ros.h" |
|
33 |
|
|
34 |
// using namespace std; |
|
35 |
// using namespace boost; |
|
36 |
// using namespace humotion; |
|
37 |
using humotion::client::Client; |
|
36 | 38 |
|
37 | 39 |
//! constructor |
38 | 40 |
//! open a new client instance. |
39 |
Client::Client(string scope, string mw){
|
|
40 |
//convert mw to uppercase:
|
|
41 |
to_upper(mw); |
|
41 |
Client::Client(std::string scope, std::string mw) {
|
|
42 |
// convert mw to uppercase
|
|
43 |
boost::to_upper(mw);
|
|
42 | 44 |
|
43 |
printf("> initializing humotion client (on %s, middleware=%s)\n",scope.c_str(),mw.c_str());
|
|
45 |
printf("> initializing humotion client (on %s, middleware=%s)\n", scope.c_str(), mw.c_str());
|
|
44 | 46 |
|
45 |
//start middleware: |
|
46 |
if (mw == "ROS"){ |
|
47 |
middleware = new MiddlewareROS(scope); |
|
48 |
}else{ |
|
49 |
printf("> ERROR: invalid mw '%s' given. RSB support was droppd. please use ROS\n\n",mw.c_str()); |
|
47 |
// start middleware |
|
48 |
if (mw == "ROS") { |
|
49 |
middleware = new humotion::client::MiddlewareROS(scope); |
|
50 |
} else { |
|
51 |
printf("> ERROR: invalid mw '%s' given. RSB support was droppd. please use ROS\n\n", |
|
52 |
mw.c_str()); |
|
50 | 53 |
exit(EXIT_FAILURE); |
51 | 54 |
} |
52 | 55 |
} |
53 | 56 |
|
54 | 57 |
//! destructor |
55 |
Client::~Client(){ |
|
58 |
Client::~Client() {
|
|
56 | 59 |
} |
57 | 60 |
|
58 | 61 |
//! check if connection is ok |
59 | 62 |
//! \return true if conn is alive |
60 |
bool Client::ok(){ |
|
63 |
bool Client::ok() {
|
|
61 | 64 |
return middleware->ok(); |
62 | 65 |
} |
63 | 66 |
|
64 | 67 |
//! do a single middleware tick: |
65 |
void Client::tick(){ |
|
68 |
void Client::tick() {
|
|
66 | 69 |
middleware->tick(); |
67 | 70 |
} |
68 | 71 |
|
69 | 72 |
//! set mouth position |
70 | 73 |
//! \param MouthState m to set |
71 | 74 |
//! \param send data to server (optional, use manual call to send_*() to trigger update on server) |
72 |
void Client::update_mouth_target(MouthState m, bool send){ |
|
75 |
void Client::update_mouth_target(MouthState m, bool send) {
|
|
73 | 76 |
middleware->update_mouth_target(m, send); |
74 | 77 |
} |
75 | 78 |
|
76 | 79 |
//! set gaze direction |
77 | 80 |
//! \param GazeState m to set |
78 | 81 |
//! \param send data to server (optional, use manual call to send_*() to trigger update on server) |
79 |
void Client::update_gaze_target(GazeState s, bool send){ |
|
82 |
void Client::update_gaze_target(GazeState s, bool send) {
|
|
80 | 83 |
middleware->update_gaze_target(s, send); |
81 | 84 |
} |
82 | 85 |
|
83 | 86 |
|
84 | 87 |
//! send all targets to server |
85 |
void Client::send_all(){ |
|
88 |
void Client::send_all() {
|
|
86 | 89 |
middleware->send_all(); |
87 | 90 |
} |
88 | 91 |
|
Also available in: Unified diff