dock_drive_debug.cpp
Go to the documentation of this file.
1 /*
2  * copyright (c) 2013, Yujin Robot.
3  * all rights reserved.
4  *
5  * redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * neither the name of yujin robot nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * this software is provided by the copyright holders and contributors "as is"
18  * and any express or implied warranties, including, but not limited to, the
19  * implied warranties of merchantability and fitness for a particular purpose
20  * are disclaimed. in no event shall the copyright owner or contributors be
21  * liable for any direct, indirect, incidental, special, exemplary, or
22  * consequential damages (including, but not limited to, procurement of
23  * substitute goods or services; loss of use, data, or profits; or business
24  * interruption) however caused and on any theory of liability, whether in
25  * contract, strict liability, or tort (including negligence or otherwise)
26  * arising in any way out of the use of this software, even if advised of the
27  * possibility of such damage.
28  */
34 /*****************************************************************************
35 ** includes
36 *****************************************************************************/
37 
39 
40 namespace kobuki {
41 /*************************
42  * debug prints
43  *************************/
44 
45 /***********************************************************
46  @breif generates debug string to tell the current status of robot. Signal info + bumper + charger + current velocity + dock detector
47  ***********************************************************/
48 void DockDrive::generateDebugMessage(const std::vector<unsigned char>& signal_filt, const unsigned char &bumper, const unsigned char &charger, const ecl::LegacyPose2D<double>& /* pose_update */, const std::string& debug_str)
49 {
50 
51  std::ostringstream debug_stream;
52  // pose_update and pose_update_rates for debugging
53  std::string far_signal = "[F: "; //far field
54  std::string near_signal = "[N: "; //near field
55  for (unsigned int i=0; i<3; i++) {
56  if (signal_filt[2-i]&DockStationIRState::FAR_LEFT ) far_signal += "L"; else far_signal += "-";
57  if (signal_filt[2-i]&DockStationIRState::FAR_CENTER ) far_signal += "C"; else far_signal += "-";
58  if (signal_filt[2-i]&DockStationIRState::FAR_RIGHT ) far_signal += "R"; else far_signal += "-";
59  if (signal_filt[2-i]&DockStationIRState::NEAR_LEFT ) near_signal += "L"; else near_signal += "-";
60  if (signal_filt[2-i]&DockStationIRState::NEAR_CENTER) near_signal += "C"; else near_signal += "-";
61  if (signal_filt[2-i]&DockStationIRState::NEAR_RIGHT ) near_signal += "R"; else near_signal += "-";
62  far_signal += " ";
63  near_signal += " ";
64  }
65  far_signal += "]";
66  near_signal += "]";
67  debug_stream << far_signal << near_signal;
68 
69  //bumper
70  {
71  std::string out = "[B: ";
72  if (bumper&4) out += "L"; else out += "-";
73  if (bumper&2) out += "C"; else out += "-";
74  if (bumper&1) out += "R"; else out += "-";
75  out += "]";
76  debug_stream << out;
77  }
78 
79  //charger
80  {
81  std::ostringstream oss;
82  oss << "[C:" << std::setw(2) << (unsigned int)charger;
83  oss << "(";
84  if (charger) oss << "ON"; else oss << " ";
85  oss << ")]";
86  debug_stream << oss.str();
87  }
88 
89  //debug_stream << std::fixed << std::setprecision(4)
90  debug_stream << "[vx: " << std::setw(7) << vx << ", wz: " << std::setw(7) << wz << "]";
91  debug_stream << "[S: " << state_str << "]";
92  debug_stream << "[dock_detecotr: : " << dock_detector << " ]";
93  debug_stream << "[" << debug_str << "]";
94  //debug_stream << std::endl;
95  debug_output = debug_stream.str();
96 
97  //std::cout << debug_output << std::endl;;
98 }
99 
100 std::string DockDrive::binary(unsigned char number) const {
101  std::string ret;
102  for( unsigned int i=0;i<6; i++){
103  if (number&1) ret = "1" + ret;
104  else ret = "0" + ret;
105  number = number >> 1;
106  }
107  return ret;
108 }
109 
110 }
Simple module for the docking drive algorithm.
std::string debug_output
Definition: dock_drive.hpp:151
std::string state_str
Definition: dock_drive.hpp:135
void generateDebugMessage(const std::vector< unsigned char > &signal_filt, const unsigned char &bumper, const unsigned char &charger, const ecl::LegacyPose2D< double > &pose_update, const std::string &debug_str)
std::string binary(unsigned char number) const


kobuki_dock_drive
Author(s): Younghun Ju
autogenerated on Fri Sep 18 2020 03:22:00