20 #define BOOST_FILESYSTEM_VERSION 2 21 #include <boost/program_options.hpp> 30 #include "std_msgs/String.h" 46 namespace po = boost::program_options;
55 startGlove(
gloveID id, std::string serialPort, std::string gloveName, std::string calibFileName) {
58 if (glove->
init(serialPort)) {
59 printf(
"glove %s started\n", (
id ==
rightGlove) ?
"right" :
"left");
68 printf(
"Error while loading calibration. Bailing out!\n");
71 printf(
"Calibration loaded successfully.\n");
81 printf(
"Thread started, but was already running.\n");
82 printf(
"Thread running.\n");
87 int main(
int argc,
char **argv) {
90 std::string calibfileLeft;
91 std::string calibfileRight;
93 std::string pubNameLeft;
95 po::options_description desc(
"Usage : cyberGloveServer [options]", 120);
96 desc.add_options()(
"help,h",
"show help screen")(
"glove-right,r",
"use right glove")(
"glove-left,l",
97 "use left glove")(
"calibration-file-left",
99 "left glove calibration file")(
"calibration-file-right",
101 "right glove calibration file")(
"tty-right",
102 po::value<std::string>(&ttyright)->default_value(
DEFAULT_TTY_RIGHT),
"right glove tty (e.g. /dev/ttyS0")(
103 "tty-left", po::value<std::string>(&ttyleft)->default_value(
DEFAULT_TTY_LEFT),
104 "left glove tty (e.g. /dev/ttyS1")(
"register-as-right",
107 "left glove Name")(
"debug-level,d", po::value<unsigned int>(&
debugLevel)->default_value(0),
108 "the more, the higher ;)");
110 po::store(po::parse_command_line(argc, argv, desc),
vm);
113 if (
vm.count(
"help")) {
114 cout << desc << endl;
118 ros::init(argc, argv,
"gloveServer_node");
120 if (!
vm.count(
"glove-right") && !
vm.count(
"glove-left")) {
121 printf(
"No glove selected! Exit.\n");
126 if (
vm.count(
"glove-right")) {
127 printf(
"starting right glove on %s\n", ttyright.c_str());
131 if (
vm.count(
"glove-left")) {
132 printf(
"starting left glove on %s\n", ttyleft.c_str());
138 std::string calibFile;
144 if (
vm.count(
"glove-right")) {
149 if (
vm.count(
"glove-left")) {
154 ROS_INFO(
"%s",
"gloveServer exited normally. Gloves deleted.\n");
boost::thread * boostWorkerThread
Thread for delivering tracker data to nCenter.
static const char * DEFAULT_PUBLISH_NAME_RIGHT
bool loadCalibFile(const char *srcFileName)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
gloveServer_impl * gloveLeft
bool init(std::string serialPort)
void workerThread()
this method is called by static method s_workerthread
static const char * DEFAULT_TTY_RIGHT
bool threadRunning
flag switching on/off thread
int main(int argc, char **argv)
static const char * DEFAULT_CALIBRATION_RIGHT
gloveServer_impl * gloveRight
static const char * DEFAULT_CALIBRATION_LEFT
static const char * DEFAULT_TTY_LEFT
static const char * DEFAULT_PUBLISH_NAME_LEFT
gloveServer_impl * startGlove(gloveID id, std::string serialPort, std::string gloveName, std::string calibFileName)