dock_drive_debug.cpp
Go to the documentation of this file.
00001 /*
00002  * copyright (c) 2013, Yujin Robot.
00003  * all rights reserved.
00004  *
00005  * redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * neither the name of yujin robot nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * this software is provided by the copyright holders and contributors "as is"
00018  * and any express or implied warranties, including, but not limited to, the
00019  * implied warranties of merchantability and fitness for a particular purpose
00020  * are disclaimed. in no event shall the copyright owner or contributors be
00021  * liable for any direct, indirect, incidental, special, exemplary, or
00022  * consequential damages (including, but not limited to, procurement of
00023  * substitute goods or services; loss of use, data, or profits; or business
00024  * interruption) however caused and on any theory of liability, whether in
00025  * contract, strict liability, or tort (including negligence or otherwise)
00026  * arising in any way out of the use of this software, even if advised of the
00027  * possibility of such damage.
00028  */
00034 /*****************************************************************************
00035 ** includes
00036 *****************************************************************************/
00037 
00038 #include "kobuki_dock_drive/dock_drive.hpp"
00039 
00040 namespace kobuki {
00041 /*************************
00042  * debug prints
00043  *************************/
00044 
00045 /***********************************************************
00046   @breif generates debug string to tell the current status of robot. Signal info + bumper + charger + current velocity + dock detector
00047  ***********************************************************/
00048 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)
00049 {
00050 
00051   std::ostringstream debug_stream;
00052   // pose_update and pose_update_rates for debugging
00053   std::string far_signal  = "[F: "; //far field
00054   std::string near_signal = "[N: "; //near field
00055   for (unsigned int i=0; i<3; i++) {
00056     if (signal_filt[2-i]&DockStationIRState::FAR_LEFT   ) far_signal  += "L"; else far_signal  += "-";
00057     if (signal_filt[2-i]&DockStationIRState::FAR_CENTER ) far_signal  += "C"; else far_signal  += "-";
00058     if (signal_filt[2-i]&DockStationIRState::FAR_RIGHT  ) far_signal  += "R"; else far_signal  += "-";
00059     if (signal_filt[2-i]&DockStationIRState::NEAR_LEFT  ) near_signal += "L"; else near_signal += "-";
00060     if (signal_filt[2-i]&DockStationIRState::NEAR_CENTER) near_signal += "C"; else near_signal += "-";
00061     if (signal_filt[2-i]&DockStationIRState::NEAR_RIGHT ) near_signal += "R"; else near_signal += "-";
00062     far_signal  += " ";
00063     near_signal += " ";
00064   }
00065   far_signal  += "]";
00066   near_signal += "]";
00067   debug_stream << far_signal << near_signal;
00068 
00069   //bumper
00070   {
00071   std::string out = "[B: ";
00072   if (bumper&4) out += "L"; else out += "-";
00073   if (bumper&2) out += "C"; else out += "-";
00074   if (bumper&1) out += "R"; else out += "-";
00075   out += "]";
00076   debug_stream << out;
00077   }
00078 
00079   //charger
00080   {
00081   std::ostringstream oss;
00082   oss << "[C:" << std::setw(2) << (unsigned int)charger;
00083   oss << "(";
00084   if (charger) oss << "ON"; else oss << "  ";
00085   oss << ")]";
00086   debug_stream << oss.str();
00087   }
00088 
00089   //debug_stream << std::fixed << std::setprecision(4)
00090   debug_stream << "[vx: " << std::setw(7) << vx << ", wz: " << std::setw(7) << wz << "]";
00091   debug_stream << "[S: " << state_str << "]";
00092   debug_stream << "[dock_detecotr: : " << dock_detector << " ]";
00093   debug_stream << "[" << debug_str << "]";
00094   //debug_stream << std::endl;
00095   debug_output = debug_stream.str();
00096 
00097   //std::cout << debug_output << std::endl;;
00098 }
00099 
00100 std::string DockDrive::binary(unsigned char number) const {
00101   std::string ret;
00102   for( unsigned int i=0;i<6; i++){
00103     if (number&1) ret = "1" + ret;
00104     else          ret = "0" + ret;
00105     number = number >> 1;
00106   }
00107   return ret;
00108 }
00109 
00110 }


kobuki_dock_drive
Author(s): Younghun Ju
autogenerated on Thu Jun 6 2019 20:24:33