Project: engagement_recognition License: BSD Dependencies:
Used by:
None |
engagement_recognition/src/recognition/lib/engagement_params.cppGo to the documentation of this file.00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Worcester Polytechnic Institute 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Worcester Polytechnic Institute. nor the names 00018 * of its contributors may be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 // @author Brett Ponsler (bponsler (at) wpi (dot) edu) 00035 #include "engagement_params.h" 00036 #include "engagement_declarations.h" 00037 #include <stdio.h> 00038 00039 // Set the instance of the EngagementParams class to NULL 00040 EngagementParams *EngagementParams::param_ = new EngagementParams(); 00041 00042 void EngagementParams::destroy() 00043 { 00044 // Grab the instance of the params 00045 EngagementParams *params = EngagementParams::getParams(); 00046 00047 // Make sure it exists 00048 if (params) 00049 { 00050 // Destroy all the node handles 00051 EngagementParams::destroyNodeHandles(); 00052 00053 // Now destroy the EngagementParams object 00054 delete EngagementParams::param_; 00055 EngagementParams::param_ = NULL; 00056 } 00057 } 00058 00059 EngagementParams::EngagementParams() 00060 { 00061 this->retrieved_parameters_ = false; 00062 this->degraded_ = false; 00063 this->base_handle_ = NULL; 00064 this->vision_handle_ = NULL; 00065 this->collab_handle_ = NULL; 00066 this->performing_handle_ = NULL; 00067 this->recog_handle_ = NULL; 00068 this->recog_human_handle_ = NULL; 00069 this->recog_robot_handle_ = NULL; 00070 this->conf_handle_ = NULL; 00071 this->conf_dir_gaze_handle_ = NULL; 00072 this->conf_mf_gaze_handle_ = NULL; 00073 this->conf_adjacency_pair_handle_ = NULL; 00074 this->conf_backchannel_handle_ = NULL; 00075 this->log_directory_ = ""; 00076 this->log_file_ = ""; 00077 } 00078 00079 EngagementParams *EngagementParams::getParams() 00080 { 00081 // If the object doesn't exist, create it 00082 if (EngagementParams::param_ == NULL) 00083 EngagementParams::param_ = new EngagementParams(); 00084 00085 // Return the EngagementParams object 00086 return EngagementParams::param_; 00087 } 00088 00089 void EngagementParams::retrieveParameters(bool force) 00090 { 00091 EngagementParams *params = EngagementParams::getParams(); 00092 00093 // Make sure the conf node handle exists 00094 if (params->conf_handle_ == NULL) 00095 EngagementParams::createNodeHandles(); 00096 00097 // If the parameters have not yet been retrieved, or the 00098 // retrieval is being forced 00099 if (params && params->conf_handle_ && 00100 (!params->retrieved_parameters_ || force)) 00101 { 00102 // Grab the verbosity and degraded params from the param server 00103 params->conf_handle_->param(engagement::VERBOSITY_PARAM, 00104 params->verbosity_, int(0)); 00105 params->conf_handle_->param(engagement::DEGRADED_PARAM, 00106 params->degraded_, false); 00107 00108 // Grab the color codes from the param server 00109 params->conf_handle_->param(engagement::RECOG_FG_COLOR_PARAM, 00110 params->recog_fg_color_, int(31)); 00111 params->conf_adjacency_pair_handle_->param( 00112 engagement::ADJACENCY_PAIR_FG_COLOR_PARAM, 00113 params->ap_fg_color_, int(32)); 00114 params->conf_backchannel_handle_->param( 00115 engagement::BACKCHANNEL_FG_COLOR_PARAM, 00116 params->bc_fg_color_, int(33)); 00117 params->conf_dir_gaze_handle_->param( 00118 engagement::DIRECTED_GAZE_FG_COLOR_PARAM, 00119 params->dg_fg_color_, int(34)); 00120 params->conf_mf_gaze_handle_->param( 00121 engagement::MUTUAL_FACIAL_GAZE_FG_COLOR_PARAM, 00122 params->mfg_fg_color_, int(35)); 00123 params->conf_handle_->param(engagement::ACTOR_FG_COLOR_PARAM, 00124 params->actor_fg_color_, int(36)); 00125 params->conf_handle_->param(engagement::STATE_FG_COLOR_PARAM, 00126 params->state_fg_color_, int(36)); 00127 params->conf_handle_->param(engagement::SEMAPHORE_FG_COLOR_PARAM, 00128 params->sema_fg_color_, int(36)); 00129 00130 // Grab the background colors, default to black 00131 params->conf_handle_->param(engagement::RECOG_BG_COLOR_PARAM, 00132 params->recog_bg_color_, int(40)); 00133 params->conf_adjacency_pair_handle_->param( 00134 engagement::ADJACENCY_PAIR_BG_COLOR_PARAM, 00135 params->ap_bg_color_, int(40)); 00136 params->conf_backchannel_handle_->param( 00137 engagement::BACKCHANNEL_BG_COLOR_PARAM, 00138 params->bc_bg_color_, int(40)); 00139 params->conf_dir_gaze_handle_->param( 00140 engagement::DIRECTED_GAZE_BG_COLOR_PARAM, 00141 params->dg_bg_color_, int(40)); 00142 params->conf_mf_gaze_handle_->param( 00143 engagement::MUTUAL_FACIAL_GAZE_BG_COLOR_PARAM, 00144 params->mfg_bg_color_, int(40)); 00145 params->conf_handle_->param(engagement::ACTOR_BG_COLOR_PARAM, 00146 params->actor_bg_color_, int(40)); 00147 params->conf_handle_->param(engagement::STATE_BG_COLOR_PARAM, 00148 params->state_bg_color_, int(40)); 00149 params->conf_handle_->param(engagement::SEMAPHORE_BG_COLOR_PARAM, 00150 params->sema_bg_color_, int(40)); 00151 00152 params->conf_handle_->param(engagement::LOG_STATS_PARAM, 00153 params->log_file_, 00154 (std::string)"engagement_stats.csv"); 00155 params->conf_handle_->param(engagement::LOG_DIRECTORY_STATS_PARAM, 00156 params->log_directory_, (std::string)"~"); 00157 00158 params->retrieved_parameters_ = true; 00159 } 00160 } 00161 00162 bool EngagementParams::isDegraded() 00163 { 00164 // Grab the instance of the params class 00165 EngagementParams *params = EngagementParams::getParams(); 00166 00167 // Make sure it exists, and return true if it's degraded 00168 if (params) 00169 { 00170 // If the parameters have not been retrieved, retrieve them 00171 if (!params->retrieved_parameters_) 00172 EngagementParams::retrieveParameters(); 00173 00174 return params->degraded_; 00175 } 00176 else 00177 return false; 00178 } 00179 00180 int EngagementParams::getVerbosity() 00181 { 00182 // Grab the instance of the params class 00183 EngagementParams *params = EngagementParams::getParams(); 00184 00185 // Make sure it exists, and return the verbosity 00186 if (params) 00187 { 00188 // If the parameters have not been retrieved, retrieve them 00189 if (!params->retrieved_parameters_) 00190 EngagementParams::retrieveParameters(); 00191 00192 return params->verbosity_; 00193 } 00194 else 00195 return -1; 00196 } 00197 00198 std::string EngagementParams::getLogFile() 00199 { 00200 // Grab the instance of the params class 00201 EngagementParams *params = EngagementParams::getParams(); 00202 00203 // Make sure it exists, and return the log directory 00204 if (params) 00205 { 00206 // If the parameters have not been retrieved, retrieve them 00207 if (!params->retrieved_parameters_) 00208 EngagementParams::retrieveParameters(); 00209 00210 return params->log_file_; 00211 } 00212 else 00213 return ""; 00214 } 00215 00216 00217 std::string EngagementParams::getLogDirectory() 00218 { 00219 // Grab the instance of the params class 00220 EngagementParams *params = EngagementParams::getParams(); 00221 00222 // Make sure it exists, and return the log directory 00223 if (params) 00224 { 00225 // If the parameters have not been retrieved, retrieve them 00226 if (!params->retrieved_parameters_) 00227 EngagementParams::retrieveParameters(); 00228 00229 return params->log_directory_; 00230 } 00231 else 00232 return ""; 00233 } 00234 00235 void EngagementParams::setStartTime(unsigned long val) 00236 { 00237 // Grab the instance of the params 00238 EngagementParams *params = EngagementParams::getParams(); 00239 00240 // Make sure it exists 00241 if (params) 00242 { 00243 // Set the start time of the logger 00244 params->start_time_ = val; 00245 } 00246 } 00247 00248 unsigned long EngagementParams::getStartTime() 00249 { 00250 // Grab the instance of the params 00251 EngagementParams *params = EngagementParams::getParams(); 00252 00253 // Make sure it exists, and return the start time 00254 if (params) 00255 return params->start_time_; 00256 else 00257 return 0; 00258 } 00259 00260 void EngagementParams::createNodeHandles() 00261 { 00262 // Grab the instance of the params 00263 EngagementParams *params = EngagementParams::getParams(); 00264 00265 // Make sure it exists 00266 if (params) 00267 { 00268 // Create all the configuration namespaces 00269 params->base_handle_ = new ros::NodeHandle(); 00270 params->internal_handle_ = new ros::NodeHandle("~"); 00271 params->conf_handle_ = 00272 new ros::NodeHandle(*(params->internal_handle_), 00273 engagement::CONF_NAMESPACE); 00274 params->conf_dir_gaze_handle_ = 00275 new ros::NodeHandle(*(params->conf_handle_), 00276 engagement::DIRECTED_GAZE_NAMESPACE); 00277 params->conf_mf_gaze_handle_ = 00278 new ros::NodeHandle(*(params->conf_handle_), 00279 engagement::MUTUAL_FACIAL_GAZE_NAMESPACE); 00280 params->conf_adjacency_pair_handle_ = 00281 new ros::NodeHandle(*(params->conf_handle_), 00282 engagement::ADJACENCY_PAIR_NAMESPACE); 00283 params->conf_backchannel_handle_ = 00284 new ros::NodeHandle(*(params->conf_handle_), 00285 engagement::BACKCHANNEL_NAMESPACE); 00286 00287 // Create all the vision namespaces 00288 params->vision_handle_ = 00289 new ros::NodeHandle(*(params->base_handle_), 00290 engagement::VISION_NAMESPACE); 00291 00292 // Create all the collaboration namespaces 00293 params->collab_handle_ = 00294 new ros::NodeHandle(*(params->base_handle_), 00295 engagement::COLLAB_NAMESPACE); 00296 00297 // Create all the performing namespaces 00298 params->performing_handle_ = 00299 new ros::NodeHandle(*(params->base_handle_), 00300 engagement::PERFORMING_NAMESPACE); 00301 00302 // Create all the recognition namespaces 00303 params->recog_handle_ = 00304 new ros::NodeHandle(*(params->base_handle_), 00305 engagement::RECOGNITION_NAMESPACE); 00306 params->recog_robot_handle_ = 00307 new ros::NodeHandle(*(params->recog_handle_), 00308 engagement::ROBOT_NAMESPACE); 00309 params->recog_human_handle_ = 00310 new ros::NodeHandle(*(params->recog_handle_), 00311 engagement::HUMAN_NAMESPACE); 00312 } 00313 } 00314 00315 void EngagementParams::destroyNodeHandles() 00316 { 00317 // Grab the instance of the params 00318 EngagementParams *params = EngagementParams::getParams(); 00319 00320 // Make sure it exists 00321 if (params) 00322 { 00323 // Shutdown and destroy the base handle 00324 if (params->base_handle_) 00325 { 00326 params->base_handle_->shutdown(); 00327 00328 delete params->base_handle_; 00329 params->base_handle_ = NULL; 00330 } 00331 00332 // Shutdown and destroy the vision handle 00333 if (params->vision_handle_) 00334 { 00335 params->vision_handle_->shutdown(); 00336 00337 delete params->vision_handle_; 00338 params->vision_handle_ = NULL; 00339 } 00340 00341 // Shutdown and destroy the collab handle 00342 if (params->collab_handle_) 00343 { 00344 params->collab_handle_->shutdown(); 00345 00346 delete params->collab_handle_; 00347 params->collab_handle_ = NULL; 00348 } 00349 00350 // Shutdown and destroy the performing handle 00351 if (params->performing_handle_) 00352 { 00353 params->performing_handle_->shutdown(); 00354 00355 delete params->performing_handle_; 00356 params->performing_handle_ = NULL; 00357 } 00358 00359 // Shutdown and destroy the recog handle 00360 if (params->recog_handle_) 00361 { 00362 params->recog_handle_->shutdown(); 00363 00364 delete params->recog_handle_; 00365 params->recog_handle_ = NULL; 00366 } 00367 00368 // Shutdown and destroy the recog human handle 00369 if (params->recog_human_handle_) 00370 { 00371 params->recog_human_handle_->shutdown(); 00372 00373 delete params->recog_human_handle_; 00374 params->recog_human_handle_ = NULL; 00375 } 00376 00377 // Shutdown and destroy the recog robot handle 00378 if (params->recog_robot_handle_) 00379 { 00380 params->recog_robot_handle_->shutdown(); 00381 00382 delete params->recog_robot_handle_; 00383 params->recog_robot_handle_ = NULL; 00384 } 00385 00386 // Shutdown and destroy the internal handle 00387 if (params->internal_handle_) 00388 { 00389 params->internal_handle_->shutdown(); 00390 00391 delete params->internal_handle_; 00392 params->internal_handle_ = NULL; 00393 } 00394 00395 // Shutdown and destroy the conf handle 00396 if (params->conf_handle_) 00397 { 00398 params->conf_handle_->shutdown(); 00399 00400 delete params->conf_handle_; 00401 params->conf_handle_ = NULL; 00402 } 00403 00404 // Shutdown and destroy the conf directed gaze handle 00405 if (params->conf_dir_gaze_handle_) 00406 { 00407 params->conf_dir_gaze_handle_->shutdown(); 00408 00409 delete params->conf_dir_gaze_handle_; 00410 params->conf_dir_gaze_handle_ = NULL; 00411 } 00412 00413 // Shutdown and destroy the conf mutual facial gaze handle 00414 if (params->conf_mf_gaze_handle_) 00415 { 00416 params->conf_mf_gaze_handle_->shutdown(); 00417 00418 delete params->conf_mf_gaze_handle_; 00419 params->conf_mf_gaze_handle_ = NULL; 00420 } 00421 00422 // Shutdown and destroy the conf adjacency pair handle 00423 if (params->conf_adjacency_pair_handle_) 00424 { 00425 params->conf_adjacency_pair_handle_->shutdown(); 00426 00427 delete params->conf_adjacency_pair_handle_; 00428 params->conf_adjacency_pair_handle_ = NULL; 00429 } 00430 00431 // Shutdown and destroy the conf backchannel handle 00432 if (params->conf_backchannel_handle_) 00433 { 00434 params->conf_backchannel_handle_->shutdown(); 00435 00436 delete params->conf_backchannel_handle_; 00437 params->conf_backchannel_handle_ = NULL; 00438 } 00439 } 00440 } 00441 00442 ros::NodeHandle *EngagementParams::getBaseHandle() 00443 { 00444 // Grab the instance of the params 00445 EngagementParams *params = EngagementParams::getParams(); 00446 00447 // Make sure it exists 00448 if (params) 00449 return params->base_handle_; 00450 else 00451 return NULL; 00452 } 00453 00454 ros::NodeHandle *EngagementParams::getInternalHandle() 00455 { 00456 // Grab the instance of the params 00457 EngagementParams *params = EngagementParams::getParams(); 00458 00459 // Make sure it exists 00460 if (params) 00461 return params->internal_handle_; 00462 else 00463 return NULL; 00464 } 00465 00466 ros::NodeHandle *EngagementParams::getConfHandle() 00467 { 00468 // Grab the instance of the params 00469 EngagementParams *params = EngagementParams::getParams(); 00470 00471 // Make sure it exists 00472 if (params) 00473 return params->conf_handle_; 00474 else 00475 return NULL; 00476 } 00477 00478 ros::NodeHandle *EngagementParams::getVisionHandle() 00479 { 00480 // Grab the instance of the params 00481 EngagementParams *params = EngagementParams::getParams(); 00482 00483 // Make sure it exists 00484 if (params) 00485 return params->vision_handle_; 00486 else 00487 return NULL; 00488 } 00489 00490 ros::NodeHandle *EngagementParams::getCollabHandle() 00491 { 00492 // Grab the instance of the params 00493 EngagementParams *params = EngagementParams::getParams(); 00494 00495 // Make sure it exists 00496 if (params) 00497 return params->collab_handle_; 00498 else 00499 return NULL; 00500 } 00501 00502 ros::NodeHandle *EngagementParams::getPerformingHandle() 00503 { 00504 // Grab the instance of the params 00505 EngagementParams *params = EngagementParams::getParams(); 00506 00507 // Make sure it exists 00508 if (params) 00509 return params->performing_handle_; 00510 else 00511 return NULL; 00512 } 00513 00514 ros::NodeHandle *EngagementParams::getRecogHandle() 00515 { 00516 // Grab the instance of the params 00517 EngagementParams *params = EngagementParams::getParams(); 00518 00519 // Make sure it exists 00520 if (params) 00521 return params->recog_handle_; 00522 else 00523 return NULL; 00524 } 00525 00526 ros::NodeHandle *EngagementParams::getRecogHumanHandle() 00527 { 00528 // Grab the instance of the params 00529 EngagementParams *params = EngagementParams::getParams(); 00530 00531 // Make sure it exists 00532 if (params) 00533 return params->recog_human_handle_; 00534 else 00535 return NULL; 00536 } 00537 00538 ros::NodeHandle *EngagementParams::getRecogRobotHandle() 00539 { 00540 // Grab the instance of the params 00541 EngagementParams *params = EngagementParams::getParams(); 00542 00543 // Make sure it exists 00544 if (params) 00545 return params->recog_robot_handle_; 00546 else 00547 return NULL; 00548 } 00549 00550 ros::NodeHandle *EngagementParams::getConfDirGazeHandle() 00551 { 00552 // Grab the instance of the params 00553 EngagementParams *params = EngagementParams::getParams(); 00554 00555 // Make sure it exists 00556 if (params) 00557 return params->conf_dir_gaze_handle_; 00558 else 00559 return NULL; 00560 } 00561 00562 ros::NodeHandle *EngagementParams::getConfMFGazeHandle() 00563 { 00564 // Grab the instance of the params 00565 EngagementParams *params = EngagementParams::getParams(); 00566 00567 // Make sure it exists 00568 if (params) 00569 return params->conf_mf_gaze_handle_; 00570 else 00571 return NULL; 00572 } 00573 00574 ros::NodeHandle *EngagementParams::getConfAdjacencyPairHandle() 00575 { 00576 // Grab the instance of the params 00577 EngagementParams *params = EngagementParams::getParams(); 00578 00579 // Make sure it exists 00580 if (params) 00581 return params->conf_adjacency_pair_handle_; 00582 else 00583 return NULL; 00584 } 00585 00586 ros::NodeHandle *EngagementParams::getConfBackchannelHandle() 00587 { 00588 // Grab the instance of the params 00589 EngagementParams *params = EngagementParams::getParams(); 00590 00591 // Make sure it exists 00592 if (params) 00593 return params->conf_backchannel_handle_; 00594 else 00595 return NULL; 00596 } 00597 00598 const char *EngagementParams::getRecogTag() 00599 { 00600 std::string temp = "[" + engagement::RECOGNITION_TYPE + "]:"; 00601 EngagementParams *params = EngagementParams::getParams(); 00602 00603 // Make sure it exists 00604 if (params) 00605 { 00606 // If the parameters have not been retrieved, retrieve them 00607 if (!params->retrieved_parameters_) 00608 EngagementParams::retrieveParameters(); 00609 00610 // Add the recog string before the given string 00611 std::string result = "\033[" + 00612 boost::lexical_cast<std::string>(params->recog_fg_color_) + "m" + 00613 "\033[" + boost::lexical_cast<std::string>(params->recog_bg_color_) + 00614 "m" + temp + "\033[0m "; 00615 00616 return result.c_str(); 00617 } 00618 00619 return (temp + " ").c_str(); 00620 } 00621 00622 const char *EngagementParams::getAPTag() 00623 { 00624 std::string temp = "[ " + engagement::ADJACENCY_PAIR_TYPE + "]:"; 00625 EngagementParams *params = EngagementParams::getParams(); 00626 00627 // Make sure the it exists 00628 if (params) 00629 { 00630 // If the parameters have not been retrieved, retrieve them 00631 if (!params->retrieved_parameters_) 00632 EngagementParams::retrieveParameters(); 00633 00634 // Add the recog string before the given string 00635 std::string result = "\033[" + 00636 boost::lexical_cast<std::string>(params->ap_fg_color_) + "m" + 00637 "\033[" + boost::lexical_cast<std::string>(params->ap_bg_color_) + 00638 "m" + temp + "\033[0m "; 00639 00640 return result.c_str(); 00641 } 00642 00643 return (temp + " ").c_str(); 00644 } 00645 00646 const char *EngagementParams::getBCTag() 00647 { 00648 std::string temp = "[ " + engagement::BACKCHANNEL_TYPE + "]:"; 00649 EngagementParams *params = EngagementParams::getParams(); 00650 00651 // Make sure the it exists 00652 if (params) 00653 { 00654 // If the parameters have not been retrieved, retrieve them 00655 if (!params->retrieved_parameters_) 00656 EngagementParams::retrieveParameters(); 00657 00658 // Add the recog string before the given string 00659 std::string result = "\033[" + 00660 boost::lexical_cast<std::string>(params->bc_fg_color_) + "m" + 00661 "\033[" + boost::lexical_cast<std::string>(params->bc_bg_color_) + 00662 "m" + temp + "\033[0m "; 00663 00664 return result.c_str(); 00665 } 00666 00667 return (temp + " ").c_str(); 00668 } 00669 00670 const char *EngagementParams::getDGTag(std::string object) 00671 { 00672 static std::string result = ""; 00673 std::string temp = "[ " + engagement::DIRECTED_GAZE_TYPE + "]:"; 00674 EngagementParams *params = EngagementParams::getParams(); 00675 00676 // Make sure the it exists 00677 if (params) 00678 { 00679 // If the parameters have not been retrieved, retrieve them 00680 if (!params->retrieved_parameters_) 00681 EngagementParams::retrieveParameters(); 00682 00683 // Add the recog string before the given string 00684 result = "\033[" + boost::lexical_cast<std::string>(params->dg_fg_color_) + 00685 "m\033[" + boost::lexical_cast<std::string>(params->dg_bg_color_) + 00686 "m" + temp + "\033[0m "; 00687 00688 // Grab the object tag 00689 std::string object_tag = EngagementParams::getObjectTag(object); 00690 00691 // Append the object tag onto the end of the DG tag 00692 result += object_tag; 00693 00694 return result.c_str(); 00695 } 00696 00697 // Add a space to the name for the result 00698 result = (temp + " "); 00699 00700 return result.c_str(); 00701 } 00702 00703 const char *EngagementParams::getMFGTag() 00704 { 00705 static std::string result = ""; 00706 std::string temp = "[" + engagement::MUTUAL_FACIAL_GAZE_TYPE + "]:"; 00707 EngagementParams *params = EngagementParams::getParams(); 00708 00709 // Make sure the it exists 00710 if (params) 00711 { 00712 // If the parameters have not been retrieved, retrieve them 00713 if (!params->retrieved_parameters_) 00714 EngagementParams::retrieveParameters(); 00715 00716 // Add the recog string before the given string 00717 result = "\033[" + boost::lexical_cast<std::string>(params->mfg_fg_color_) + 00718 "m\033[" + boost::lexical_cast<std::string>(params->mfg_bg_color_) + 00719 "m" + temp + "\033[0m "; 00720 00721 return result.c_str(); 00722 } 00723 00724 result = (temp + " "); 00725 return result.c_str(); 00726 } 00727 00728 const char *EngagementParams::getActorTag(std::string name) 00729 { 00730 static std::string result = ""; 00731 std::string temp = "[" + name + "]:"; 00732 EngagementParams *params = EngagementParams::getParams(); 00733 00734 // Make sure the it exists 00735 if (params) 00736 { 00737 // If the parameters have not been retrieved, retrieve them 00738 if (!params->retrieved_parameters_) 00739 EngagementParams::retrieveParameters(); 00740 00741 // Add the recog string before the given string 00742 result = "\033[" + boost::lexical_cast<std::string>(params->actor_fg_color_) 00743 + "m\033[" + boost::lexical_cast<std::string>(params->actor_bg_color_) 00744 + "m" + temp + "\033[0m "; 00745 00746 return result.c_str(); 00747 } 00748 00749 result = (temp + " "); 00750 return result.c_str(); 00751 } 00752 00753 const char *EngagementParams::getSemaphoreTag() 00754 { 00755 static std::string result = ""; 00756 std::string temp = "[" + engagement::SEMAPHORE_TYPE + "]:"; 00757 EngagementParams *params = EngagementParams::getParams(); 00758 00759 // Make sure the it exists 00760 if (params) 00761 { 00762 // If the parameters have not been retrieved, retrieve them 00763 if (!params->retrieved_parameters_) 00764 EngagementParams::retrieveParameters(); 00765 00766 // Add the recog string before the given string 00767 result = "\033[" + boost::lexical_cast<std::string>(params->sema_fg_color_) 00768 + "m\033[" + boost::lexical_cast<std::string>(params->sema_bg_color_) 00769 + "m" + temp + "\033[0m "; 00770 00771 return result.c_str(); 00772 } 00773 00774 result = (temp + " "); 00775 return result.c_str(); 00776 } 00777 00778 const char *EngagementParams::getStateTag(std::string name) 00779 { 00780 static std::string result = ""; 00781 std::string temp = "[" + name + "]:"; 00782 EngagementParams *params = EngagementParams::getParams(); 00783 00784 // Make sure the it exists 00785 if (params) 00786 { 00787 // If the parameters have not been retrieved, retrieve them 00788 if (!params->retrieved_parameters_) 00789 EngagementParams::retrieveParameters(); 00790 00791 // Add the recog string before the given string 00792 result = "\033[" + boost::lexical_cast<std::string>(params->state_fg_color_) 00793 + "m\033[" + boost::lexical_cast<std::string>(params->state_bg_color_) 00794 + "m" + temp + "\033[0m "; 00795 00796 return result.c_str(); 00797 } 00798 00799 result = (temp + " "); 00800 return result.c_str(); 00801 } 00802 00803 const char *EngagementParams::getObjectTag(std::string object) 00804 { 00805 static std::string result = ""; 00806 // Make sure the object name exists 00807 if (object.size() > 0) 00808 { 00809 std::string temp = "[" + object + "]:"; 00810 std::string color = "0"; 00811 00812 // transform the object string to lower case 00813 std::transform(object.begin(), object.end(), object.begin(), tolower); 00814 00815 // Determine what color the object is 00816 if (object.compare(0, 3, "red") == 0 || 00817 object.compare(0, 6, "orange") == 0) 00818 color = "31"; 00819 else if (object.compare(0, 5, "green") == 0) 00820 color = "32"; 00821 else if (object.compare(0, 6, "yellow") == 0) 00822 color = "33"; 00823 else if (object.compare(0, 4, "blue") == 0) 00824 color = "34"; 00825 else if (object.compare(0, 6, "purple") == 0) 00826 color = "35"; 00827 else if (object.compare(0, 4, "cyan") == 0) 00828 color = "36"; 00829 00830 result = "\033[" + color + "m" + temp + "\033[0m "; 00831 00832 return result.c_str(); 00833 } 00834 00835 result = ""; 00836 return result.c_str(); 00837 } |