Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035
00036
00037
00038
00039 #ifndef KOBUKI_DOCK_DRIVE_HPP_
00040 #define KOBUKI_DOCK_DRIVE_HPP_
00041
00042
00043
00044
00045
00046 #include <iostream>
00047 #include <sstream>
00048 #include <iomanip>
00049 #include <cmath>
00050 #include <vector>
00051 #include <ecl/geometry/legacy_pose2d.hpp>
00052 #include <ecl/linear_algebra.hpp>
00053
00054 #include "kobuki_dock_drive/state.hpp"
00055
00056
00057
00058
00059
00060 namespace kobuki {
00061
00062
00063
00064
00065
00066 class DockDrive {
00067 public:
00068 DockDrive();
00069 ~DockDrive();
00070
00071 bool init(){ return true; }
00072 bool isEnabled() const { return is_enabled; }
00073 bool canRun() const { return can_run; }
00074
00075 void enable() { modeShift("enable"); }
00076 void disable() { modeShift("disable"); }
00077 void modeShift(const std::string& mode);
00078
00079 void update(const std::vector<unsigned char> &signal
00080 , const unsigned char &bumper
00081 , const unsigned char &charger
00082 , const ecl::LegacyPose2D<double> &pose);
00083
00084 void velocityCommands(const double &vx, const double &wz);
00085
00086
00087
00088
00089 double getVX() const { return vx; }
00090 double getWZ() const { return wz; }
00091
00092
00093
00094
00095 RobotDockingState::State getState() const { return state; }
00096 std::string getStateStr() const { return state_str; }
00097 std::string getDebugStr() const { return debug_str; }
00098
00099
00100
00101
00102 void setMinAbsV(double mav) { min_abs_v = mav; }
00103 void setMinAbsW(double maw) { min_abs_w = maw; }
00104
00105
00106 std::string getDebugStream() { return debug_output; }
00107
00108
00109
00110 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00111
00112 protected:
00113 void processBumpChargeEvent(const unsigned char& bumper, const unsigned char& charger);
00114 void computePoseUpdate(ecl::LegacyPose2D<double>& pose_update, const ecl::LegacyPose2D<double>& pose);
00115 void filterIRSensor(std::vector<unsigned char>& signal_filt,const std::vector<unsigned char> &signal );
00116 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);
00117 void updateVelocity(const std::vector<unsigned char>& signal_filt, const ecl::LegacyPose2D<double>& pose_update, std::string& debug_str);
00118 RobotDockingState::State determineRobotLocation(const std::vector<unsigned char>& signal_filt,const unsigned char& charger);
00119 bool validateSignal(const std::vector<unsigned char>& signal_filt, const unsigned int state);
00120
00121
00122
00123 void idle(RobotDockingState::State& state,double& vx, double& wz);
00124 void scan(RobotDockingState::State& state,double& vx, double& wz, const std::vector<unsigned char>& signal_filt, const ecl::LegacyPose2D<double>& pose_update, std::string& debug_str);
00125 void find_stream(RobotDockingState::State& state,double& vx, double& wz, const std::vector<unsigned char>& signal_filt);
00126 void get_stream(RobotDockingState::State& state,double& vx, double& wz, const std::vector<unsigned char>& signal_filt);
00127 void aligned(RobotDockingState::State& state,double& vx, double& wz, const std::vector<unsigned char>& signal_filt, std::string& debug_str);
00128 void bumped(RobotDockingState::State& nstate,double& nvx, double& nwz, int& bump_count);
00129
00130
00131 private:
00132 bool is_enabled, can_run;
00133
00134 RobotDockingState::State state;
00135 std::string state_str, debug_str;
00136 double vx, wz;
00137 std::vector<std::vector<unsigned char> > past_signals;
00138 unsigned int signal_window;
00139 int bump_remainder;
00140 int dock_stabilizer;
00141 int dock_detector;
00142 double rotated;
00143 double min_abs_v;
00144 double min_abs_w;
00145 ecl::LegacyPose2D<double> pose_priv;
00146
00147 void setVel(double v, double w);
00148
00149 std::string binary(unsigned char number) const;
00150
00151 std::string debug_output;
00152 std::vector<std::string> ROBOT_STATE_STR;
00153 };
00154
00155 }
00156
00157 #endif