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/pose2d.hpp>
00052 #include <ecl/linear_algebra.hpp>
00053
00054
00055
00056
00057
00058 namespace kobuki {
00059
00060
00061
00062
00063
00064 class DockDrive {
00065 public:
00066 enum Station {
00067 NEAR_LEFT=1,
00068 NEAR_CENTER=2,
00069 NEAR_RIGHT=4,
00070 FAR_CENTER=8,
00071 FAR_LEFT=16,
00072 FAR_RIGHT=32,
00073 NEAR = 7,
00074 FAR = 56,
00075 };
00076 enum State {
00077 IDLE,
00078 LOST,
00079 UNKNOWN,
00080 INSIDE_FIELD,
00081 AWAY,
00082 SCAN,
00083 SPIN,
00084 SPIRAL,
00085 FIND_STREAM,
00086 GET_STREAM,
00087 ALIGNED,
00088 ALIGNED_FAR,
00089 ALIGNED_NEAR,
00090 BUMPED,
00091 BUMPED_DOCK,
00092 RUN,
00093 STOP,
00094 DOCKED_IN,
00095 DONE,
00096 };
00097
00098 DockDrive();
00099 ~DockDrive();
00100
00101 bool init(){ return true; }
00102 bool isEnabled() const { return is_enabled; }
00103 bool canRun() const { return can_run; }
00104
00105 void enable() { modeShift("enable"); }
00106 void disable() { modeShift("disable"); }
00107 void modeShift(const std::string& mode);
00108
00109 void update(const std::vector<unsigned char> &signal
00110 , const unsigned char &bumper
00111 , const unsigned char &charger
00112 , const ecl::Pose2D<double> &pose);
00113
00114 void update(const std::vector<unsigned char> &signal
00115 , const unsigned char &bumper
00116 , const unsigned char &charger
00117 , const ecl::Pose2D<double> &pose_update
00118 , const ecl::linear_algebra::Vector3d &pose_update_rates);
00119
00120 void velocityCommands(const double &vx, const double &wz);
00121
00122
00123
00124
00125 double getVX() const { return vx; }
00126 double getWZ() const { return wz; }
00127
00128
00129
00130
00131 State getState() const { return state; }
00132 std::string getStateStr() const { return state_str; }
00133 std::string getDebugStr() const { return debug_str; }
00134
00135
00136
00137
00138 void setMinAbsV(double mav) { min_abs_v = mav; }
00139 void setMinAbsW(double maw) { min_abs_w = maw; }
00140
00141
00142 std::string getDebugStream() { return debug_output; }
00143
00144
00145
00146 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00147
00148 private:
00149 bool is_enabled, can_run;
00150
00151 State state;
00152 std::string state_str, debug_str;
00153 double vx, wz;
00154 std::vector<std::vector<unsigned char> > past_signals;
00155 int bump_remainder;
00156 int dock_stabilizer;
00157 int dock_detector;
00158 double rotated;
00159 double min_abs_v;
00160 double min_abs_w;
00161
00162 void setVel(double v, double w);
00163
00164 std::string binary(unsigned char number) const;
00165
00166 std::string debug_output;
00167 };
00168
00169 }
00170
00171 #endif