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 std::string getDebugStream() { return debug_output; }
00137
00138
00139
00140 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00141
00142 private:
00143 bool is_enabled, can_run;
00144
00145 State state;
00146 std::string state_str, debug_str;
00147 ecl::Pose2D<double> pose;
00148 double vx, wz;
00149 std::vector<std::vector<unsigned char> > past_signals;
00150 int bump_remainder;
00151 int dock_stabilizer;
00152 int dock_detector;
00153 double rotated;
00154
00155 std::string binary(unsigned char number) const;
00156
00157 std::string debug_output;
00158 };
00159
00160 }
00161
00162 #endif